

You'll need to install it using the following command: sudo apt install -y python3Īfter you've configured python and pip, you can install pytorch using the following command: pip3 install torch torchvision torchaudio I've found that Anaconda is rather broken these days, so I prefer to install PyTorch using pip.Ī clean installation of Ubuntu 22.04 doesn't have Python 3.x installed yet.

There are several ways to install PyTorch. It takes, depending on your connection, a few minutes to download all the files.Īfter installing the CUDA toolkit, you can now download PyTorch.
#Nvidia cuda toolkit for desktop how to#
The website provides neat instructions on how to install the toolkit. I'm using PyTorch 1.13 which needs CUDA 11.7, so I downloaded the CUDA toolkit for WSL-Ubuntu from the developer site. The correct way to install CUDA on WSL can be found in the Nvidia manual. If you install the regular CUDA toolkit in Ubuntu on WSL2 you'll overwrite the libcuda file with one that isn't routed. There's a specific libcuda version installed in the OS that routes all commands to the GPU in your host system. WSLg maps your GPU driver from Windows in the Ubuntu installation. The key here is to get the right CUDA installation. I've broken my installation with this trick. If you do that, I can assure you that you will have to reinstall Ubuntu. You maybe tempted to head on over to the Nvidia developer site and download CUDA directly. With WSL configured and Ubuntu installed, let's move on to installing the CUDA toolkit Installing CUDA on Ubuntu 22.04 in WSL2 To install the WSLg extension, you can follow the instructions in the WSLg repository on Github.Īfter installing WSLg, you can go ahead and install Ubuntu 22.04 from the Windows store. So far though I haven't experienced anything blocking to be honest. It's still in preview so it may contain bugs. This works for Intel, AMD, and Nvidia GPUs.

This extension allows WSL2 to use your GPU. The key to running deep learning frameworks like PyTorch on Windows 11 is the WSLg extension. Configuring Ubuntu with WSLg on Windows 11 In this quick post I'll show you how I configured my Ubuntu 22.04 installation on Windows 11 to run CUDA and PyTorch. Needless to say, I needed another solution. Which is really nice for data sciency stuff, but not great for my Powerpoint and Excel since LibreOffice sucks big time. Recently, I even decided to convert my laptop to Ubuntu 22.04 for the time being. Often I run into problems with my tools not working properly on Windows. Working with machine-learning code in Windows can be quite a hassle.
