---
title: Getting started with CUDA on Ubuntu on WSL 2
description: At Build 2020 Microsoft announced support for GPU compute on Windows
  Subsystem for Linux 2. Ubuntu is the leading Linux distribution for WSL and a sponsor
  of WSLConf. Canonical, the publisher of Ubuntu, provides enterprise support for
  Ubuntu on WSL through Ubuntu Advantage. This guide will walk early adopters through
  the steps on turning  […]
url: https://canonical.com/blog/getting-started-with-cuda-on-ubuntu-on-wsl-2?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[haydenb](https://canonical.com/blog/author/haydenb "More about haydenb")

17 June 2020

# Getting started with CUDA on Ubuntu on WSL 2

[AIML](https://canonical.com/blog/tag/aiml)
[GPU](https://canonical.com/blog/tag/gpu)
[jupyter notebook](https://canonical.com/blog/tag/jupyter-notebook)
[nvidia](https://canonical.com/blog/tag/nvidia)
[Ubuntu WSL](https://canonical.com/blog/tag/ubuntu-wsl)

---

Share the article

At Build 2020 Microsoft announced [support for GPU compute on Windows Subsystem for Linux 2](https://ubuntu.com/blog/new-gpu-and-gui-features-announced-for-wsl-at-build). Ubuntu is the leading Linux distribution for WSL and a sponsor of [WSLConf](https://www.youtube.com/playlist?list=PLwFSk464RMxnZkvZ1HKrlNyj-s6Zq4fWe). Canonical, the publisher of Ubuntu, provides enterprise support for Ubuntu on WSL through [Ubuntu Advantage](https://ubuntu.com/advantage).

This guide will walk early adopters through the steps on turning their Windows 10 devices into a CUDA development workstation with Ubuntu on WSL.

For our purposes we will be setting up Jupyter Notebook in Docker with CUDA on WSL. These instructions can be adapted to set up other CUDA GPU compute workloads on WSL.

#### **Install Windows 10 Insiders Dev Channel**

To begin, we need the latest Windows 10 Insider build released today, June 17, 2020. You will need to register as a [Windows Insider](https://insider.windows.com/en-us/) if you have not already, enroll your device in the Dev Channel (previously known as the ‘Fast Ring’), and then upgrade to Windows 10 build number 20150 or above.

Consult the [Windows Insider documentation](https://docs.microsoft.com/en-us/windows-insider/at-home/get-started) for more information on registering as an Insider, enrolling your device, and upgrading your machine to the Dev Channel.

#### **Enable WSL 2**

In future updates to Windows you will simply need to use the following to enable WSL:

```
wsl --install
```

For now, open PowerShell as Administrator.

First enable WSL 1:

```
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```

Then enable WSL 2:

```
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
```

Restart Windows 10:

```
Restart-Computer
```

This step will become redundant in the future after WSL 2 becomes the default, but for now return to PowerShell and make WSL 2 your default *before* installing Ubuntu:

```
wsl.exe --set-default-version 2
```

To read more about Ubuntu on WSL, visit [ubuntu.com/wsl](http://ubuntu.com/wsl). For a more detailed look at enabling WSL on Windows, check out our [tutorial](https://ubuntu.com/tutorials/tutorial-ubuntu-on-windows). To convert existing WSL 1 installs to WSL 2, see my [blog on the general availability of WSL 2](https://ubuntu.com/blog/ubuntu-on-wsl-2-is-generally-available).

#### **Install Ubuntu on WSL**

Install Ubuntu from the [Microsoft Store](https://www.microsoft.com/store/productId/9NBLGGH4MSV6):

For other ways to install Ubuntu on WSL, see our [WSL wiki](https://wiki.ubuntu.com/WSL#Ubuntu_on_WSL).

#### **Install Windows Terminal**

Optionally, you may install the new Windows Terminal from the [Microsoft Store](https://www.microsoft.com/store/productId/9N0DX20HK701). It is has many features, such as GPU acceleration and customizability, that improves the Ubuntu experience on WSL over the traditional Windows console.

Windows Terminal can also be installed from the project’s [GitHub page](https://github.com/microsoft/terminal).

#### **Setup Ubuntu on WSL**

Open Ubuntu from the Windows Start Menu and configure your WSL user. This user is separate from your Windows user:

If you downloaded Windows Terminal you can then close the old console and re-open Ubuntu from the drop-down options in the new Terminal:

Now check to make sure you are running the correct WSL 2 Linux kernel.

In Ubuntu:

```
uname -r
```

You will need kernel 4.19.121 or higher. If you *do not* have kernel 4.19.121, first try:

```
wsl.exe --update
```

If that does not work, make sure you have ‘Receive updates for other Microsoft products when you update Windows’ checked:

And then re-run Windows updates:

#### **Install Nvidia Drivers on Windows 10**

Next, [download](https://devblogs.nvidia.com/announcing-cuda-on-windows-subsystem-for-linux-2/) the appropriate driver for your GeForce or Quadro Nvidia card.

In the next few months, the NVIDIA driver will be distributed via Windows Update, which will manually downloading and installing the driver unnecessary.

You will need to join the [Nvidia Developer Program](https://developer.nvidia.com/developer-program) for early access to the driver for now. You can read more about CUDA on WSL on the [Nvidia Developer blog](https://devblogs.nvidia.com/announcing-cuda-on-windows-subsystem-for-linux-2/).

#### **Install Docker in WSL**

```
sudo apt -y install docker.io
```

#### Install Nvidia Container Toolkit

Set the distribution variable, import the Nvidia repository GPG key, and then add the Nvidia repositories to the Ubuntu apt package manager:

```
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -

curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container-experimental.list | sudo tee /etc/apt/sources.list.d/libnvidia-container-experimental.list
```

Refresh the Ubuntu apt repositories and then install the Nvidia runtime:

```
sudo apt update && sudo apt install -y nvidia-docker2
```

Close all open terminals of Ubuntu, open a PowerShell terminal, and manually shutdown Ubuntu:

```
wsl.exe --shutdown Ubuntu
```

#### **Test GPU Compute**

Open a new Ubuntu terminal and start Docker:

```
sudo service docker stop
```

And then run:

```
docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
```

If everything is configured correctly, the output should resemble:

#### Start A TensorFlow Container

Open a new Ubuntu terminal and run:

```
docker run -u $(id -u):$(id -g) -it --gpus all -p 8888:8888 tensorflow/tensorflow:latest-gpu-py3-jupyter
```

Open a second Ubuntu terminal, type wslview, copy and paste the notebook URL, but then edit the URL from 127.0.0.1 *to* localhost:

```
wslview http://localhost:8888/?token=a83a1ad288a7bf1bd1deb694c8a7f19223c8d0baa7d5fb3c
```

Your default browser on Windows will launch with a GPU-accelerated Jupyter notebook:

You are now all set to begin using TensorFlow with CUDA on Ubuntu WSL.

#### Related blog posts

* Ubuntu: [Ubuntu on WSL 2 Is Generally Available](https://ubuntu.com/blog/ubuntu-on-wsl-2-is-generally-available)
* Ubuntu: [New GPU and GUI features announced for WSL at Build](https://ubuntu.com/blog/new-gpu-and-gui-features-announced-for-wsl-at-build)
* Microsoft: [GPU Compute, WSL Install and WSL Update arrive in the latest Insider build for the Windows Subsystem for Linux](https://devblogs.microsoft.com/commandline/gpu-compute-wsl-install-and-wsl-update-arrive-in-the-windows-insiders-fast-ring-for-the-windows-subsystem-for-linux/)
* Nvidia: [Announcing CUDA on Windows Subsystem for Linux 2](https://devblogs.nvidia.com/announcing-cuda-on-windows-subsystem-for-linux-2/)

#### **Additional resources**

* [Awesome TensorFlow](http://Awesome TensorFlow)
* [Jupyter Docker Stacks](https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html)
* [PyTorch](https://pytorch.org/)
* [TensorFlow Tutorials](https://www.tensorflow.org/tutorials)
* [NVIDIA Drivers for CUDA on WSL](https://developer.nvidia.com/cuda/wsl/download)
* [CUDA on WSL User Guide](https://docs.nvidia.com/cuda/wsl-user-guide/index.html#abstract)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Canonical joins the Open Secure AI Alliance](https://canonical.com/blog/open-secure-ai-alliance)

Canonical is now part of the Open Secure AI Alliance, announced by NVIDIA with partners across cloud computing, cybersecurity, enterprise software, open source foundations, and...

[Canonical](https://canonical.com/blog/author/canonical)

28 August 2026

[### Securing AI agent workflows on Ubuntu with the new NVIDIA OpenShell snap](https://canonical.com/blog/nvidia-openshell-ubuntu-announcement)

By packaging OpenShell as a snap, Canonical is enabling enterprises to confidently run next-generation agentic workflows across local devices, hybrid environments, and private clouds.

[Canonical](https://canonical.com/blog/author/canonical)

1 June 2026

[### Run NVIDIA Nemotron 3 Nano Omni locally in a single command](https://canonical.com/blog/nvidia-nemotron-3-nano-omni)

Today, NVIDIA introduced the NVIDIA Nemotron™ 3 Nano Omni, a highly-efficient multimodal model designed to understand and reason across video, audio, images, and language....

[Canonical](https://canonical.com/blog/author/canonical)

28 April 2026

[### Canonical welcomes NVIDIA’s donation of the GPU DRA driver to CNCF](https://canonical.com/blog/canonical-nvidia-kubecon-2026)

At KubeCon Europe in Amsterdam, NVIDIA announced that it will donate the GPU Dynamic Resource Allocation (DRA) Driver to the Cloud Native Computing Foundation (CNCF). This...

[Abdelrahman Hosny](https://canonical.com/blog/author/abdelrahman-hosny-m)

24 March 2026
