Reputation: 1551
Pip
installing Pytorch 1.7.1 here on Gtx1660(latest drivers installed) doesn't recognise the installed Cuda toolkit 10.2 on my machine(Windows10).
As this is a personal project, I don't wish to use Anaconda.
How to resolve this?
#INSTALLATION (10.2 CUDA SUPPORT)
pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
#CODE
import torch
device = torch.device("cuda")
# device = torch.device("cuda:0") #ALSO NOT WORKING
cuda_available = torch.cuda.is_available()
cuda_init = torch.cuda.is_initialized()
print(f'device_current = {device},cuda_available = {cuda_available} and cuda_init = {cuda_init}\n')
torch.cuda.init()
print(f'device_current = {device} and cuda_init = {cuda_init}')
#TERMINAL
device_current = cuda:0,cuda_available = False and cuda_init = False
Traceback (most recent call last):
File "f:\Script\Ai\Pytorch\mod_test\test1.py", line 8, in <module>
torch.cuda.init()
File "C:\Users\User0\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\cuda\__init__.py", line 137, in init
_lazy_init()
File "C:\Users\User0\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\cuda\__init__.py", line 166, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
Upvotes: 1
Views: 8048
Reputation: 145
I had a similar error with multiple versions of pytorch 1.7.1 for cuda 10.2 while having a driver installed with cuda 10.2.
What eventually worked for me was installing pytorch 1.7.1 for cuda 10.1 if that would be a viable option for you?
python -m pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
If you would need pytorch 1.7.1 for cuda 10.2 you could try.
python -m pip install torch==1.7.1+cu102 torchvision==0.8.2+cu102 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Upvotes: 0
Reputation: 40778
I could be wrong, but here is what I found while searching on their package registry.
For a PyTorch 1.7.1 pip
install. The instructions on pytorch.org are:
## cu101
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
## cu110
pip install torch===1.7.1+cu110 torchvision===0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Yet the command for CUDA 10.2 support is:
## cu102
pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
This seems off because the CUDA version is not stated anywhere in the command. Yet download.pytorch.org
provides support for this particular PyTorch version with cu92
, cu101
, cu102
, and cu110
.
You can either use:
pip install torch==1.7.0 torchvision==0.8.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html
or try this instead from the main Torch stable directory:
pip install torch==1.7.1+cu102 torchvision==0.8.2+cu102 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Upvotes: 2