Pytorch installed but GPU not recognized

I have successfully installed pytorch but my GPU is not recognized. I followed the instructions from CUDA Toolkit 12.1 Update 1 Downloads | NVIDIA Developer. I downloaded and ran cuda_12.1.1_windows_network It appeared to have worked but something went wrong.

device config uses GPU if available

device = torch.device(“cuda:0” if torch.cuda.is_available() else “cpu”)
print("device = ", device) ### This prints “cpu”

print(torch.version.cuda) ### this line prints none

print (torch.version) #### this line prints 2.0.0+cpu

any ideas as to what I’ve done wrong and how to fix it?


How did you install PyTorch? Note that you do not need to install a CUDA toolkit to install and use prebuilt PyTorch binaries, as those usually will ship with their own CUDA toolkit.

I would try uninstall PyTorch and installing a binary e.g., via pip3 install torch torchvision torchaudio --index-url

thank you! I took your advice and now pytorch recognizes my GPU