因为要跑论文中开源的代码需要安装pytorch1.4,论文中给出的安装命令
# CUDA 10.1
pip install torch==1.4.0 torchvision==0.5.0
运行后出现错误
Could not find a version that satisfies the requirement torch==1.4.0
然后在官网找到安装命令
# CUDA 9.2
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2 -c pytorch
但是这个命令是从官网安装的速度非常拉胯,然后尝试添加-i命令用清华镜像安装
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
报错无效的-i参数,然后用pip安装报错找不到包…
最后解决方法
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
使用上述命令给conda替换镜像源,然后使用conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2
命令安装成功。
总结
使用conda安装没有-i参数,使用pip会找不到包
需要给conda替换镜像源然后再安装,推荐去官网寻找安装命令