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.
Thankyou.

The binaries work for me:

python -c "import torch; print(torch.__version__); print(torch.randn(1).cuda())"
2.1.1+cu121
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.