本人首先利用anaconda安装了tensorflow2.3,但是需要用到tensorflow1的版本。需要执行以下步骤。
1 安装tensorflow2.x首先下载anaconda 参考本人博客【Deepin 20系统】Linux系统安装Anaconda和Tensorflow-gpu2.3
2 安装tensorflow1.x 2.1 更换镜像(也可跳过)1、在创建虚拟环境的过程中,会通过Internet下载相关的库,可能在国内有些慢。最好的方式是设置国内的镜像。可以使用下面的命令查看Anaconda当前的镜像。
conda config --show channels
2、如果在此之前设置了其他的镜像,可以使用下面的命令删除这些镜像。
conda config --remove channels 镜像名
如果通过以上命令查看镜像是defaults,删除命令是
conda config --remove channels defaluts
3、添加新的镜像。
#以下两条二选一 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
#从channel中安装包时显示channel的url,这样就可以知道包的安装来源了。 conda config --set show_channel_urls yes
4、设置完镜像后,使用conda config --show channels命令,会看到新添加的镜像。
2.2 创建虚拟环境1、同上创建一个TensorFlow1.x版本的环境,注意1.x版本最高只能对应Python3.6
conda create -n tf1 python=3.6 conda activate tf1
2、安装tensorflow-gpu 1.15版本
pip install tensorflow-gpu==1.15
如果报错pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.
因为超过设定的timeout,以下指令二选一. 自定义timeout,并指定清华镜像源
pip --default-timeout=100 install tensorflow-gpu==1.15 -i https://pypi.tuna.tsinghua.edu.cn/simple
指定豆瓣镜像源
pip --default-timeout=100 install tensorflow-gpu==1.15 -i https://pypi.douban.com/simple
1、切换回base虚拟环境命令
conda deactivate
2、 进入自己创建的虚拟环境
conda activate tf1