Pytorch GPU via conda not working

I want to run pytorch on GPU (within conda) with the following settings but all attempts failed.

  • Ubuntu 24
  • GPU: RTX 4090
  • Driver Version: 550.120 (checked via nvidia-smi)
  • No system-wide cuda installation
  • pytorch install commands I tried:
    conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
    conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch-nightly -c nvidia

What would you recommend?

Check if the right binary was installed via print(torch.version.cuda). If it’s showing 12.4, the binary might have trouble communicating with the NVIDIA driver.

Thank you but this returns None.
I further checked:

  • gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
  • torch.version is ‘2.4.1’
  • conda list:
    cuda-cudart 12.4.127 0 nvidia
    cuda-cupti 12.4.127 0 nvidia
    cuda-libraries 12.4.1 0 nvidia
    cuda-nvrtc 12.4.127 0 nvidia
    cuda-nvtx 12.4.127 0 nvidia
    cuda-opencl 12.6.77 0 nvidia
    cuda-runtime 12.4.1 0 nvidia
    cuda-version 12.6 3 nvidia
    where I guess the 12.6 version might be causing the issue?

No, I don’t think so as the install command works for me in a new and empty conda environment:

conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
...
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB
    brotli-python-1.0.9        |  py310h6a678d5_8         356 KB
    certifi-2024.8.30          |  py310h06a4308_0         162 KB
    cuda-cudart-12.4.127       |                0         198 KB  nvidia
    cuda-cupti-12.4.127        |                0        16.4 MB  nvidia
    cuda-libraries-12.4.1      |                0           2 KB  nvidia
    cuda-nvrtc-12.4.127        |                0        21.0 MB  nvidia
    cuda-nvtx-12.4.127         |                0          58 KB  nvidia
    cuda-opencl-12.6.77        |                0          25 KB  nvidia
    cuda-runtime-12.4.1        |                0           2 KB  nvidia
    cuda-version-12.6          |                3          16 KB  nvidia
...
    pytorch-2.5.1              |py3.10_cuda12.4_cudnn9.1.0_0        1.46 GB  pytorch
    pytorch-cuda-12.4          |       hc786d27_7           7 KB  pytorch
    pytorch-mutex-1.0          |             cuda           3 KB  pytorch
...
python -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available()); print(torch.randn(1).cuda())"
2.5.1                                                                                                                                                                                                                                                                             
12.4                                                                                                                                                                                                                                                                              
True                                                                                                                                                                                                                                                                              
tensor([0.3827], device='cuda:0')        

However, you could also try to use the pip wheels if you are seeing issues with conda as conda binaries will be deprecated as mentioned here.

Thank you.
Resolved: creating a new (and empty!) conda env helped so the original
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
works now.