Skip to content

Instantly share code, notes, and snippets.

@xinzhel
Last active May 30, 2022 08:04
Show Gist options
  • Save xinzhel/6eee594f22cf6b95910dc67c40c21b94 to your computer and use it in GitHub Desktop.
Save xinzhel/6eee594f22cf6b95910dc67c40c21b94 to your computer and use it in GitHub Desktop.
Linux environment setup on Windows (WSL 2)
  1. Install WSL 2 (with separate linux kernel) and Linux distribution
# run the following command in PowerShell
$ wsl --install -d Ubuntu-18.04

# Ubuntu-18.04 is my preferred Linux distribution. You can find all the supported distributions by running
# wsl --list --online
  • Caveat: you may not launch wsl or Ubuntu without restarting my PC to launch the Ubuntu
  1. Install the CUDA driver by running the exexcutable on Windows
  1. Install CUDA toolkits for creating CUDA applications (e.g., build deep learning models in PyTorch)
  • Although the official guideline recommends using the WSL-specific package, I recommend the regular package for ubuntu. So you can select the specific version of OS and cuda. Therefore, the script suitable for you could be provided from https://developer.nvidia.com/. But REPLACE the last command to install only the toolkit, e.g., apt-get install -y cuda-toolkit-11-1. The following scirpt is just copied for my OS (Ubuntu 18.04 ) and required version of CUDA (11.1). You can change these versions according to your system.
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda-repo-ubuntu1804-11-1-local_11.1.0-455.23.05-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-11-1-local_11.1.0-455.23.05-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1804-11-1-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install -y cuda-toolkit-11-1
  • it should be downloaded at /usr/local/cuda. so you could check intalled cuda version

$ sudo /usr/local/cuda/bin/nvcc --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment