Skip to content

Instantly share code, notes, and snippets.

@bannsec
Last active October 17, 2023 02:27
Show Gist options
  • Save bannsec/b42aae02fa5edcffe908115d6f7562cb to your computer and use it in GitHub Desktop.
Save bannsec/b42aae02fa5edcffe908115d6f7562cb to your computer and use it in GitHub Desktop.
WSL2 (Ubuntu 22.04) NVidia Notes.md

Need to uninstall the baked in nvidia drives and install nvidia drivers from the run file:

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=runfile_local

  • Don't install the driver (that'll be wsl passthru), just everything else

Install cublas? After my install of the runfile i didn't actually have this installed, so had to do it manually.

sudo apt install libcublas11

Fix WSL2 (need to run this each time you start wsl2)

pushd .
cd /usr/lib/wsl/lib
sudo rm libcuda.so libcuda.so.1
sudo ln -s libcuda.so.1.1 libcuda.so.1
sudo ln -s libcuda.so.1 libcuda.so
sudo ldconfig
popd

Install docker (wsl2 doesn't have systemd, so will need to start docker when you start wsl2)

curl https://get.docker.com | sh \
  && sudo systemctl --now enable docker

Install NVidia Docker

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:12.2.0-runtime-ubuntu22.04 nvidia-smi
# If nvcc and build tools are needed, use nvidia/cuda:12.2.0-devel-ubuntu22.04

Optional

# Fix screen on wsl by adding this to .bashrc:
if [ ! -d "/run/screen" ]; then
    sudo mkdir -p /run/screen
    sudo chmod 777 /run/screen
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment