我安装pytorch的机器是win10,显卡是intel的集成显卡,没有CUDA。
根据pytorch官方文档执行了pip方式的安装,通过官方代码验证安装是否成功时,报错ImportError: DLL load failed
网上介绍的解决办法试了都无效,最后呢,发现在官方页面上选择安装方式时错误地选了CUDA 10,其安装命令是:
pip install torch===1.3.0 torchvision===0.4.1 -f https://download.pytorch.org/whl/torch_stable.html
既然报错,就卸载pytorch后重新安装pip uninstall torch,然后用新的命令:
pip3 install torch==1.3.0+cpu torchvision==0.4.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
重新安装后验证成功,
验证代码:
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
运行后控制台输出了:
tensor([[0.2046, 0.8287, 0.2682],
[0.4860, 0.8590, 0.8934],
[0.7030, 0.7179, 0.4960],
[0.4162, 0.9527, 0.6863],
[0.9376, 0.8952, 0.3812]])