Code not compiling, torch not working with CUDA?

When I try and run my program I get the error: raise AssertionError(“Torch not compiled with CUDA enabled”) AssertionError: Torch not compiled with CUDA enabled.

nvcc --version returns:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:24:09_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0

and nvidia-sim gives:

| NVIDIA-SMI 511.65       Driver Version: 511.65       CUDA Version: 11.6     |
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  On |                  N/A |
|  0%   59C    P2    52W / 225W |   1955MiB /  8192MiB |      3%      Default |
|                               |                      |                  N/A |

I don’t know why my CUDA version says 11.6 when I installed 11 .3 through the nvidia site.
I’m not sure why this errors still occuring but print(torch.version.cuda) returns “None” and torch.cuda.is_available() returns “False”.

I installed torch with “conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch”, thanks.

The reported CUDA version via nvidia-smi depends on the driver and does not necessarily match the installed CUDA toolkit including the compiler.

I guess the CPU-only release was installed or you have multiple installations in your current conda environment. Check the install logs and make sure the right release is installed and is the only one in your env.

Thanks a lot, fixed the issue. My environment had multiple versions installed.