Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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 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.
sudo mv /etc/apt/preferences.d/cuda-repository-pin-600
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/
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