【发布时间】: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