安装代码
用nvidia-smi 查看cuda版本
在官网查看命令,比如10.1可得到命令:
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch
或
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
实践中出现的问题与解决
需要安装更新的情况
version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/caffe2/
driver is too old的问题
需要降低版本的情况
RuntimeError: CUDA error: no kernel image is available for execution on the device
显卡算力不足 | (https://github.com/pytorch/pytorch/issues/31285#issuecomment-739139454) |
---|---|
安装低版本的 pytorch,对算力要求低,但是某些功能可能无法实现 | |
cudatoolkit与cuda版本不一致 | nvidia-smi |
版本不匹配的情况
***.pth is a zip archive (did you mean to use torch.jit.load()?)
import torch ,numpy报错(之前能有效运行)
之前的环境没有问题,刚才打开突然报错,
Please note and check the following:
* The Python version is: Python3.7 from "E:\****\python.exe"
* The NumPy version is: "*****"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
然后搜索到的解决方式都为:
在Environment Variables
中添加name = PATH,value =
# 根据自己的环境改变
E:\Anaconda3;
E:\Anaconda3\Library\mingw-w64\bin;
E:\Anaconda3\Library;
E:\Anaconda3\Lib\site-packages;
E:\Anaconda3\Scripts;
E:\Anaconda3\envs\pytorch\Library\bin
实践效果不好,重装了一个环境,能够运行。