【问题标题】:Cuda 10.2 not recognised on Pip installed Pytorch 1.7.1在安装 Pytorch 1.7.1 的 Pip 上无法识别 Cuda 10.2
【发布时间】:2021-01-31 14:23:25
【问题描述】:

Pip 在 Gtx1660(已安装最新驱动程序)上安装 Pytorch 1.7.1 here 无法识别我的机器(Windows10)上安装的 Cuda 工具包 10.2。
由于这是一个个人项目,我不想使用 Anaconda。
如何解决?

#INSTALLATION(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

【问题讨论】:

  • “Torch 未在启用 CUDA 的情况下编译”对我来说听起来是一个非常简单的问题
  • 然而 pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html pytorch.org 上给出的命令,用于 pip 安装带有 CUDA 的 PyTorch 1.71...

标签: pytorch


【解决方案1】:

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

对于 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 通过cu92cu101cu102cu110 为这个特定的 PyTorch 版本提供支持。


您可以使用:

pip install torch==1.7.0 torchvision==0.8.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html

或者从 Torch 主目录尝试这个:

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

【讨论】:

    猜你喜欢
    • 2021-09-09
    • 2020-01-20
    • 1970-01-01
    • 1970-01-01
    • 2019-12-21
    • 2022-12-03
    • 2021-02-27
    • 2021-11-23
    • 2022-08-16
    相关资源
    最近更新 更多