我安裝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]])