windows下使用pip安装torch模块,出现错误:
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\xxx\AppData\Local\Temp\pip-install-yqzlud5w\torch\
方法一
尝试参考文章:https://mp.weixin.qq.com/s/u5uIjnABGXTJGo4Z3_dZQw
指定安装包的方法,指定安装包进行安装。
方法二
创建一个环境
打开Anaconda prompt,输入:
conda create -n myroot python=3.5
myroot为自己定义的环境名称,对应的python3.5版本。
然后输入:
activate myroot
激活环境。
通过:
python --version
nvcc --version
分别查看python和cuda版本。
安装 pytorch
根据python和cuda的版本选择安装GPU或CPU版本:
#使用conda安装
'conda,cuda8,python3.5': conda install pytorch -c pytorch
'conda,cuda9.0,python3.5': conda install pytorch cuda90 -c pytorch
'conda,cuda9.1,python3.5': conda install pytorch cuda91
'conda,cudanone,python3.5': conda install pytorch-cpu -c pytorch
'conda,cuda8,python3.6': conda install pytorch -c pytorch
'conda,cuda9.0,python3.6': conda install pytorch cuda90 -c pytorch
'conda,cuda9.1,python3.6': conda install pytorch cuda91 -c pytorch
'conda,cudanone,python3.6': conda install pytorch-cpu -c pytorch
#使用pip安装
'pip,cudanone,python3.5': pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.0-cp35-cp35m-win_amd64.whl
'pip,cuda8,python3.5': pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.0-cp35-cp35m-win_amd64.whl
'pip,cuda9.0,python3.5': pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.0-cp35-cp35m-win_amd64.whl
'pip,cuda9.1,python3.5': pip3 install http://download.pytorch.org/whl/cu91/torch-0.4.0-cp35-cp35m-win_amd64.whl
'pip,cudanone,python3.6': pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.0-cp36-cp36m-win_amd64.whl
'pip,cuda8,python3.6': pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.0-cp36-cp36m-win_amd64.whl
'pip,cuda9.0,python3.6': pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.0-cp36-cp36m-win_amd64.whl
'pip,cuda9.1,python3.6': pip3 install http://download.pytorch.org/whl/cu91/torch-0.4.0-cp36-cp36m-win_amd64.whl
安装成功: