Bend icon indicating copy to clipboard operation
Bend copied to clipboard

WSL2 and CUDA (CUDA not available)

Open nerdworldDE opened this issue 1 year ago • 1 comments

Even tho CUDA is available, the bend run-cu tells me otherwise:

Error reading result from hvm. Output :
CUDA not available!

grafik

nerdworldDE avatar May 18 '24 22:05 nerdworldDE

Have you installed cuda after installing hvm? If you did, please try reinstalling HVM

developedby avatar May 19 '24 00:05 developedby

Hello, I too face the same issue with WSL2 and CUDA. I did try reinstalling both HVM and bend-lang as @developedby suggested, but it yields the same error "CUDA not available".

StoneSteel27 avatar May 19 '24 08:05 StoneSteel27

Same here, I reinstalled hvm and bend but it still did not work, everything is also up to date aswell.

2HwN9wL 1

Devesh-N avatar May 19 '24 09:05 Devesh-N

If you run nvcc --version what does it show? Also, when installing HVM does it show a warning saying that CUDA was not found and will not be available?

developedby avatar May 19 '24 10:05 developedby

Have you installed cuda after installing hvm? If you did, please try reinstalling HVM

According to the CUDA on WSL guide by Nvidia there is no need to install anything besides the current GPU drivers on the host system: https://docs.nvidia.com/cuda/wsl-user-guide/index.html#getting-started-with-cuda-on-wsl-2

If you run nvcc --version what does it show?

nvcc doesn't seem to be installed, which might be the problem here, even tho i can find the libcuda.so files in the /usr/lib folders

nerdworldDE avatar May 19 '24 10:05 nerdworldDE

nvcc --version

On wsl I get Command 'nvcc' not found, but can be installed with: but on windows is works just fine And when installing hvm cargo I get: updating, installing, compiling and finished messages, no warnings

Devesh-N avatar May 19 '24 10:05 Devesh-N

hvm-cu is a CUDA program, so to compile it you need to have nvcc installed. I'll update the guide to be more explicit

developedby avatar May 19 '24 10:05 developedby

nvcc --version

On wsl I get Command 'nvcc' not found, but can be installed with: but on windows is works just fine And when installing hvm cargo I get: updating, installing, compiling and finished messages, no warnings

Is there not a warning saying warning: [email protected]: WARNING: CUDA compiler not found. HVM will not be able to run on GPU.? You need nvcc just to install HVM, later you only need CUDA to run it.

If running hvm run-cu or bend run-cu shows CUDA not available you should have seen the warning when installing HVM. Can you confirm to that it doesn't appear? Just to make sure that there is a problem with the build script

developedby avatar May 19 '24 10:05 developedby

So I'll need to install nvidia-cuda-toolkit and then reinstall the hvm ?

Devesh-N avatar May 19 '24 10:05 Devesh-N

I installed the CUDA Toolkit which also gets the nvcc binary:

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=runfile_local

nerdworldDE avatar May 19 '24 10:05 nerdworldDE

So I'll need to install nvidia-cuda-toolkit and then reinstall the hvm ?

I'm not sure the exact package on WSL2 is, but yes, you need the cuda sdk/toolkit

developedby avatar May 19 '24 10:05 developedby

No I can confirm, I received no such warning. I am now installing the toolkit and I will keep you updated

Devesh-N avatar May 19 '24 10:05 Devesh-N

I installed the CUDA Toolkit which also gets the nvcc binary:

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=runfile_local

This worked out! After adding the binary folder to the PATH and reinstalling HVM it works now.

nerdworldDE avatar May 19 '24 10:05 nerdworldDE

I installed the CUDA Toolkit which also gets the nvcc binary: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=runfile_local

This worked out! After adding the binary folder to the PATH and reinstalling HVM it works now.

This is exactly what I did earlier but it didn't work so I uninstalled it

Devesh-N avatar May 19 '24 10:05 Devesh-N

This is exactly what I did earlier but it didn't work so I uninstalled it

Have you checked the folder with the binaries? (/usr/local/cuda-12.4/bin) and added them to your PATH?

nerdworldDE avatar May 19 '24 10:05 nerdworldDE

No, I did not add them to the path. I am repeating those steps now and when they will be done, I will add it and reload my shell

Devesh-N avatar May 19 '24 10:05 Devesh-N

UPDATE: The issue is now resolved.

Steps to fix the issue: Run this: (assumes you are using x86_64 wsl2 ubuntu)

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda-repo-wsl-ubuntu-12-4-local_12.4.1-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-12-4-local_12.4.1-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-4

then run sudo apt install nvidia-cuda-toolkit in bash OR add the toolkit to path

Devesh-N avatar May 19 '24 10:05 Devesh-N