@WardBrian Thank you for your assistance.
After your reply, I installed Ubuntu 24.04 on WSL2 and performed the following steps, including installing CUDA for WSL2. In my previous environment, Ubuntu 22.04, I had been experimenting with running large language models (LLMs) locally, which resulted in multiple CUDA installations and a convoluted PATHs. Therefore, I installed Ubuntu 24.04 afresh.
I managed to get cmdstanr running on Ubuntu 24.04 as well. However, the performance remains slower than I expected:
- Moved the folder from
home/<user_name>
on Ubuntu 22.04 to/mnt/c/Users/<user_name>/wsl-init
. - Installed Ubuntu 24.04 on WSL2.
- Moved the folder from
/mnt/c/Users/<user_name>/wsl-init
tohome/<user_name>
on Ubuntu 22.04. - Installed the latest NVIDIA Driver from NVIDIA’s website.
- Verified that
libcuda.so
is only located in/usr/lib/wsl/lib/libcuda.so
usingfind /usr/ -name libcuda.so
. - Followed the CUDA on WSL guide:
- Removed the existing key:
sudo apt-key del 7fa2af80
. - Executed the following commands as per the CUDA 12.1.1 installation guide:
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-wsl-ubuntu-12-1-local_12.1.1-1_amd64.deb sudo dpkg -i cuda-repo-wsl-ubuntu-12-1-local_12.1.1-1_amd64.deb sudo cp /var/cuda-repo-wsl-ubuntu-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo apt-get update sudo apt-get -y install cuda
- Removed the existing key:
- Set the PATH:
echo 'export PATH=/usr/local/cuda-12.1/bin${PATH:+:${PATH}}' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc source ~/.bashrc
- Configured WSL not to inherit the Windows PATH:
- Edited
/etc/wsl.conf
to add:[interop] appendWindowsPath = false
- Executed the following in Windows PowerShell:
wsl.exe --shutdown
- Reboot Ubuntu 24.04
- Edited
- Verified that
libcuda.so
exists in/usr/lib/wsl/lib/libcuda.so
and/usr/local/cuda-12.1/targets/x86_64-linux/lib/stubs/libcuda.so
.- This may conflict with the CUDA on WSL documentation.
- Installed essential build tools:
sudo apt -y install build-essential gcc g++ make libtool texinfo dpkg-dev pkg-config gfortran
- Installed OpenBLAS following the OpenBLAS Wiki because I also wanted to install it:
sudo apt update sudo apt install libopenblas-dev
- Attempted GPU model fitting in R, but encountered
clGetPlatformIDs CL_PLATFORM_NOT_FOUND_KHR
error. Fixed it by installinglibpocl-dev
:sudo apt install libpocl-dev
- Tried GPU model fitting in R again. All 4 chains finished successfully with a Mean chain execution time of 293.8 seconds and a Total execution time of 297.9 seconds. However, the performance is still comparable to using CPUs.