首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cuda 10.2未在已安装Pytorch 1.7.1上识别

Cuda 10.2未在已安装Pytorch 1.7.1上识别
EN

Stack Overflow用户
提问于 2021-01-31 14:23:25
回答 1查看 4.6K关注 0票数 1

Pip在Gtx1660上安装Pytorch 1.7.1 这里 (安装了最新的驱动程序),不识别在我的机器(Windows10)上安装的Cuda工具包10.2。

因为这是一个个人项目,我不想使用Anaconda。

如何解决这个问题?

#安装(10.2 CUDA支持)

代码语言:javascript
复制
pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

#码

代码语言:javascript
复制
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}')

#终端

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-31 14:47:45

我可能错了,但这是我在他们的包注册表上搜索时发现的。

对于PyTorch 1.7.1 pip安装。关于pytorch.org的说明如下:

代码语言:javascript
复制
## 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的支持命令是:

代码语言:javascript
复制
## 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通过cu92cu101cu102cu110为这个特定的PyTorch版本提供了支持。

您可以使用:

代码语言:javascript
复制
pip install torch==1.7.0 torchvision==0.8.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html

或者从主火炬稳定目录尝试以下操作:

代码语言:javascript
复制
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
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65980206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档