Score:1

unable to get cuda 12 working ubuntu WSL2 (pytorch)

st flag

I've been trying for days now to get cuda working on WSL2 Tried cuda 12 not working, tried to deinstall it all from console. I ran

#instead of cuda12 i gave up on it, went for 11.6.2
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda

wget https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run
sudo sh cuda_11.6.2_510.47.03_linux.run --silent --driver

# altered bashrc :
sudo nano ~/.bashrc   
export PATH=/usr/local/cuda-11.6.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-.6.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda

wget https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run
sudo sh cuda_11.6.2_510.47.03_linux.run

if i type 'nvidia-smi'i get (still 12??.. did everything from console to uninstall it, thats a long list of commands too) Thu Jan 12 17:07:17 2023

sorry unable to get the table right

| NVIDIA-SMI 527.92.01    Driver Version: 528.02      
 CUDA Version: 12.0     |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |

|   0  NVIDIA GeForce ...  On   | 00000000:07:00.0  On |                  N/A |
| 30%   28C    P8    31W / 350W |   2655MiB / 12288MiB |      7%      Default |
                               |                      |                  N/A |

Whatever I do i'm unable to run under WSL2 jupyter, pytorch with cuda support, I've removed and reinstalled WSL2 but nothing seams to work. cudnn didn't like my gcc version for 12 so I gave up on that end, this was all working fine like a month ago, some driver update corrupted it I think and I don't know how to get it all working again under WLS a complete reinstall of windows 11 isn't an option for me, and still then I face the problem I can't get it to work I tried to follow a medium article (but went for 11.6.2 for gcc match) https://medium.com/analytics-vidhya/install-cuda-11-2-cudnn-8-1-0-and-python-3-9-on-rtx3090-for-deep-learning-fcf96c95f7a1

I know more articles about this are at ask ubuntu followed various of them but since version 12 i don't know how to resolve it.

cc flag
The nvidia-smi "cuda 12" just indicates a capability, not what version is installed. There are answers on this site for installing CUDA from the run script, avoiding all the dependencies and nvidia driver problems which pop up when the kernel updates. A local install (override all the .run script locations) allow you to add the gcc,... you want to your local install, to override the system gcc, g++.
Peter avatar
st flag
the weird thing is that cuda 12 cudnn says my system a gforece 3080gtx ti for cuda isnt on the hardware specs at least some installers tell me that
Peter avatar
st flag
@ubfan1 do you mean that overrride gcc and g++ was what i had to try ? i tried so many things .. not sure about that one
cc flag
Your <cuda-install-place>/bin should be early in your PATH, so you may install any gcc you want there and not interfere with the system running a different version.
Peter avatar
st flag
Ok with the intention to run pytorch, .. i just found that pytorch officially doesnt support cuda 12 yet, as of 13-1-2023 so i think i just wait for it, cuda 12 is from the hosting win 11 system not sure if i should put this as an answer
cc flag
Seems like that answer would help other people in your situation, so go ahead, and when the support arrives, you may update it.
Peter avatar
st flag
@ubfan thanks for your help eventually I got it working, after reading the documentation of PyTorch, Nvidea, and Microsoft (and even docker), it all got me confused.
Score:1
st flag

I was a bit misguided here, while indeed pytorch doesnt support cuda 12 yet its binaries come with its own cuda so in short you can get pytorch but internally it uses an older cuda version which is no problem despite WSL2 ubuntu on a newer system will report cuda12. Part of my misguidance was all the nvidea documentation that made me think i needed to install more on the WSL client, its the host Win 11 that needs the toolkit, however the WSL2 client only needs pytorch (no gpu drivers somehow WSL can share the graphics adapter among its host. (not sure if docker will work the same, probaply yes i think).

So to install pytorch

install MD nanno   #those 2 are not required but handy
WSL --update
WSL --install -d Ubuntu
sudo apt update
sudo apt install python3-pip
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117

jupyter-lab --allow-root

Then open your web browser to url displayed in the console Inside a jupyter notebook :

import torch
torch.cuda.current_device()
torch.cuda.get_device_name(torch.cuda.current_device())  #output will be : `NVIDIA GeForce RTX 3080 Ti' or some other card

#in another cell type
!nvidea-smi

Side tip in a browser howto use gpu with pytorch

Notice 1 Also if you're new to WSL, notice that the next time you want to start Ubuntu you might be tempted to type WSL in a windows cmd box, though that's not the way to go, WSL is for setting up a Linux version, what you need to click to get Ubuntu, is a new orange ubuntu icon in your start menu.

Notice 2 This install is quite simple no security configuration jupyterlab is running as root user, at home thats good enough not recomended at work though this is just a plain simple install.

Notice 3 WSL is able to install other Linux versions too, i just use Ubuntu i think in the area of neural networks it's the basic OS. And as for this install you only get a console (no GUI), but thats enough to run jupyter lab, for a config file or so inside this console i recomend nano its a simple text editor, and mc is a norton alike file comander (from the old days), i think thats enough to get you started for the linux side

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.