版权声明:本文博主原创,有需要请联系我。 https://blog.csdn.net/myGFZ/article/details/80175327
导言
最近在Ubuntu16.04上面安装tensorflow时,常会用到使用pip安装各种软件和依赖。其实也就是使用pip安装python的各种库时遇到的速度慢的问题。
这是因为,直接使用pip指令安装时,默认是国外的下载源,这会导致下载速度很慢,严重影响进度。所以在安装时把下载源更换为国内的时,下载速度会显著提升。
一、国内的源
国内有很多可以使用的下载源,列两个用的比较多的:
1、豆瓣:http://pypi.douban.com/simple/
2、清华:https://pypi.tuna.tsinghua.edu.cn/simple
我这次安装主要使用的是清华的pip源,很方便。
二、使用方法
1、临时使用
在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:我想要安装tensorflow带gpu 1.4.0的版本:
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.4.0
这里使用pip3是因为我在python3.5里面使用。如果使用python2.7的话,就直接使用pip指令就好。
2、永久修改
1)、linux下
linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2)、windows下
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple