Does Pytorch work with CUDA 12.5?

Hello! I’m new to PyTorch with CUDA and I’m trying to set it up on WSL. My CUDA version is 12.5, but the version matrix goes up to 12.4. Is this outdated or should I downgrade my CUDA for Pytorch to work?

Thanks a lot

Your locally installed CUDA toolkit won’t be used unless you build PyTorch from source or a custom CUDA extension since the PyTorch binaries ship with its own CUDA dependencies.

1 Like

I’m also having issues getting CUDA and PyTorch to work.

I have CUDA 12.5 installed and PyTorch 2.2 installed in my Anaconda environment, however when checking if my GPU is available it always returns FALSE.

I’m running this relatively simple script to check if available:

import torch

Check if CUDA is available

if torch.cuda.is_available():
print(“CUDA is available. GPU will be used.”)
device = torch.device(‘cuda’)
else:
print(“CUDA is not available. CPU will be used.”)
device = torch.device(‘cpu’)

Print out the device being used

print(f"Device being used: {device}")

Create a tensor and move it to the GPU

tensor = torch.rand(3, 3).to(device)
print(tensor)

Very frustrating as I am trying to train a custom YOLO model on my GPU at present following updating my laptop to a i7-13800H with a RTX-4060 8GB GPU.

hello, I am trying to install the pytorch version compatible with cuda 12.5 but I have not been successful. cuda 12.1 is currently active on the website. But I cannot find a version compatible with 12.5. When I install 12.1, cuda is active but I get the following error.

import torch
torch.cuda.is_available()
/home/user/conda/lib/python3.10/site-packages/torch/cuda/init.py:118: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 500: named symbol not found (Triggered internally at …/c10/cuda/CUDAFunctions.cpp:108.)
return torch._C._cuda_getDeviceCount() > 0
False

Translated with DeepL.com (free version)

hello, I am trying to install the pytorch version compatible with cuda 12.5 but I have not been successful. cuda 12.1 is currently active on the website. But I cannot find a version compatible with 12.5. When I install 12.1, cuda is active but I get the following error.

import torch
torch.cuda.is_available()
/home/user/conda/lib/python3.10/site-packages/torch/cuda/init.py:118: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 500: named symbol not found (Triggered internally at …/c10/cuda/CUDAFunctions.cpp:108.)
return torch._C._cuda_getDeviceCount() > 0
False

You can install any PyTorch binary with CUDA support (11.8, 12.1, or 12.4) as long as your NVIDIA driver is properly installed and can communicate with your GPU, which does not seem to be the case.

We are sometimes seeing similar issues and just yesterday it seems a restart of the laptop was needed.

1 Like

I changed my nvidia driver and my problem was solved, thank you

Just wanted to double down and confirm the restart worked for me… Kept checking if my GPU was being used through the torch commands in my notebook and it said False. Did everything, installed the torch, cuda 12.5, etc and it didn’t work until I read your message about the restart… then it said true :slight_smile: .

i have pytorch version 2.2 and cuda 12.5. No gpu shown. tried restarting the laptop. still no difference. pls help.

UPDATE : I changed conda environment and used python venv and it worked.

Hello guys :slight_smile:

I’m facing a similar situation here. I purchased a RTX 4080 SUPER which was released earlier this year. Its cuda 12.5 out of the box.

Tried having PyTorch recognize gpu : fail
Tried downgrading the driver in order to be able to use 12.4 or earlier : fail - no such drivers exists for this gpu.

Had to replace the gpu by a RTX 3080 instead… Wanted to use the more recent one but hitting a wall.

Any ideas ?

Update : We did install the cuda toolkits and even the toolkit is unable to provide a suitable driver for the RTX 4080 SUPER, its not recognizing the gpu

That’s not true and you can install any recent driver, such as 550.90.07 , by selecting the right GPU here:

image

It seems you are facing more setup issues unrelated to PyTorch so make sure your system is able to recognize and use the GPU before installing PyTorch.

Perfect. Will have to go as you say. If its supposed to work, we should be able to figure it out :wink: