Torch not compiled with CUDA enabled, torch.cuda.is_available() returns True

I have installed pytorch enable with cuda versions (torch 2.1.1+cu121). But Iam facing “AssertionError: Torch not compiled with CUDA enabled”.

torch.cuda.is_available() = True.

I tried re-installing many times. But still failed. Can please someone help.

The binaries work for me:

python -c "import torch; print(torch.__version__); print(torch.randn(1).cuda())"
tensor([0.0681], device='cuda:0')

so you might need to check if you have e.g. multiple PyTorch installations in your current environment and uninstall the wrong ones.