请问pip install pytorch具体有哪些坑,可以绕过吗?
据说pip安pytorch会把自己坑死,您在用的时候具体发现有哪些坑呢?
在官网选好环境就行了,没什么坑,就是可能下载慢一点。
(pytorch模型部署以及学习NLP以及模型部署,可以关注一下我的专栏)
不是 pip install pytorch 而是 pip install torch ...
除此之外,貌似没有遇到过什么坑,速度慢的话,选择国内pip源就行了,如清华的pip源就挺快的。
从隔壁conda过来的,还是要推荐一下矩池云上提供的一键换源的脚本。这个收集的是我见过最全的pip国内镜像源了。
git clone https://github.com/matpool/matools.git
bash /matools/mirrors/switch_apt_source.sh
bash /matools/mirrors/switch_conda_source.sh
bash /matools/mirrors/switch_pip_source.sh
只需要用上面的命令就可以一键换源了。
如果在其他地方可以用
阿里云:http://mirrors.aliyun.com/pypi/simple/"
中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣:https://pypi.doubanio.com/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
腾讯云:https://mirrors.cloud.tencent.com/pypi/simple/
浙江大学:http://mirrors.zju.edu.cn/pypi/web/simple/
网易:http://mirrors.163.com/pypi/simple/
华为云:https://repo.huaweicloud.com/repository/pypi/simple
北京外国语大学:https://mirrors.bfsu.edu.cn/pypi/web/simple
上海交通大学:https://mirrors.sjtug.sjtu.edu.cn/pypi/web/simple
南京大学:https://mirrors.nju.edu.cn/pypi/web/simple
使用办法如下
临时使用
pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple pytorch
设为默认方法1
升级 pip 到最新的版本 (&>=10.0.0) 后进行配置:
pip install pip -U
pip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple
如果您到 pip 默认源的网路连接较差,临时使用镜像源来升级 pip:
pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple pip -U
设为默认方法2
编辑 pip
配置文件,将 index-url
修改为
https://mirrors.bfsu.edu.cn/pypi/web/simple
pip
的配置文件一般位于(如果没有,请直接创建):
- Unix 环境:
$HOME/.config/pip/pip.conf
- macOS:
$HOME/Library/Application
Support/pip/pip.conf
- Windows:
%APPDATA%pippip.ini
修改pip.conf
文件配置示例如下:
[global]
index-url = https://mirrors.nju.edu.cn/pypi/web/simple
format = columns
希望可以帮助到大家
泻药
一般我是添加个清华镜像源(直接装我感觉要装一天
然后pip install + 指定版本
如 pip install pytorch=0.4.1 cuda90
这个就是装cuda9.0版本的0.4.1版本的pytorch
我觉得我可能懂你
$ pipenv install torch --skip-lock
Installing torch…
Adding torch to Pipfiles [packages]…
Installation Succeeded
Installing dependencies from Pipfile…
An error occurred while installing stanza! Will try again.
An error occurred while installing torch! Will try again.
================================ 4/4 - 00:00:32
Installing initially failed dependencies…
================================ 2/2 - 00:00:12
[pipenv.exceptions.InstallError]: File "c:userspurplappdatalocalprogramspythonpython38libsite-packagespipenvclicommand.py", line 235, in install
[pipenv.exceptions.InstallError]: retcode = do_install(
[pipenv.exceptions.InstallError]: File "c:userspurplappdatalocalprogramspythonpython38libsite-packagespipenvcore.py", line 1983, in do_install
[pipenv.exceptions.InstallError]: do_init(
[pipenv.exceptions.InstallError]: File "c:userspurplappdatalocalprogramspythonpython38libsite-packagespipenvcore.py", line 1246, in do_init
[pipenv.exceptions.InstallError]: do_install_dependencies(
[pipenv.exceptions.InstallError]: File "c:userspurplappdatalocalprogramspythonpython38libsite-packagespipenvcore.py", line 862, in do_install_dependencies
[pipenv.exceptions.InstallError]: _cleanup_procs(procs, False, failed_deps_queue, retry=False)
[pipenv.exceptions.InstallError]: File "c:userspurplappdatalocalprogramspythonpython38libsite-packagespipenvcore.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: [Looking in indexes: https://mirrors.aliyun.com/pypi/simple/, https://pypi.tuna.tsinghua.edu.cn/simple, Collecting stanza, Using cached https://mirrors.aliyun.com/pypi/packages/27/9c/60689521a971a57dd02d2925105efedefa9dccd76c9a0b92566683d43e89/stanza-1.0.1-py3-none-any.whl (193 kB), Collecting protobuf, Using cached https://mirrors.aliyun.com/pypi/packages/27/9c/ef816295b4b40298fd0a17bf8f0ba6cf3e0c44cb2ce72257168e09996b8b/protobuf-3.11.3-py2.py3-none-any.whl (434 kB)]
[pipenv.exceptions.InstallError]: [ERROR: Could not find a version that satisfies the requirement torch&>=1.3.0 (from stanza) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2), ERROR: No matching distribution found for torch&>=1.3.0 (from stanza)]
ERROR: ERROR: Package installation failed...
这是我直接安装torch的错误
后来根据
官网?pytorch.org的来
pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
emmmmmmmmmmm,终于不报错了,安装成功了
conda 清华源
推荐使用conda install pytorch安装,conda会把pytorch相相应版本的支持包一起下载,掉坑的几率小一点
安装可参考 PyTorchversions/网址:
选择合适版本即可
或者选择最新版本:PyTorch ,然后选择复制箭头命令,如下即可
要是想下载速度快的话,使用清华镜像,下面命令即可:
pip install torchvision --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple
推荐阅读: