This indicates that you’ve installed the CPU-only PyTorch binary without a CUDA runtime.
Use the install commands from here and make sure the install log shows that the right binary is selected.
Although the popular belief was that once the torch in uninstalled, it does create problems during installation, I went ahead and installed it.
Here is the outcome:
print(torch.version.cuda)
11.6
print(torch.cuda.is_available())
True
print(torch.cuda.device_count())
1
print(torch.cuda.device_name)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘torch.cuda’ has no attribute ‘device_name’. Did you mean: ‘get_device_name’?
print(torch.cuda.get_device_name())
NVIDIA GeForce GTX 1080 Ti
The lesson learned here is that if this issue occurs then use:
conda uninstall pytorch
to uninstall the pytorch version from the environment otherwise, if you try to reinstall with the new command, in case you have accidentally installed the CPU version, the environment will just get updated with the latest version of the same pytorch 1.12.1-py3.10_cpu_0 or whichever version you have and you would still have the pytorch CPU version.