Pip在Gtx1660上安装Pytorch 1.7.1 这里 (安装了最新的驱动程序),不识别在我的机器(Windows10)上安装的Cuda工具包10.2。
因为这是一个个人项目,我不想使用Anaconda。
如何解决这个问题?
#安装(10.2 CUDA支持)
pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html#码
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}')#终端
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发布于 2021-01-31 14:47:45
我可能错了,但这是我在他们的包注册表上搜索时发现的。
对于PyTorch 1.7.1 pip安装。关于pytorch.org的说明如下:
## 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然而,CUDA 10.2的支持命令是:
## cu102
pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html这似乎是不对的,因为在命令中任何地方都没有说明CUDA版本。然而,download.pytorch.org通过cu92、cu101、cu102和cu110为这个特定的PyTorch版本提供了支持。
您可以使用:
pip install torch==1.7.0 torchvision==0.8.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html或者从主火炬稳定目录尝试以下操作:
pip install torch==1.7.1+cu102 torchvision==0.8.2+cu102 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.htmlhttps://stackoverflow.com/questions/65980206
复制相似问题