admin管理员组

文章数量:1626227

安装Tensorflow(2.2.0)

    • 安装aconda
    • 进入aconda prompt
    • 指令操作:
    • pycharm配置
    • 清华镜像

安装aconda

进入aconda prompt

指令操作:

  • 输入:
 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 

再接着输入:
conda config --set show_channel_urls yes
这两行代码用来改成连接清华镜像的

  • 接下来安装Tensorflow环境,在Anaconda Prompt中输入:
conda create -n tensorflow python=3.7.6

安装完使用指令查看环境是否安装成功

conda info --envs

看到上面这些activate tensorflow

我们要安装的是CPU版本,那么在命令下紧接着输入:
打开anaconda prompt

CPU版本:

pip install tensorflow==2.2.0 -i https://pypi.doubanio.com/simple

GPU版本:

pip install tensorflow-gpu==2.2.0 -i https://pypi.doubanio.com/simple

二选一即可,
安装完成后,
在anaconda prompt中以此输入python、import tensorflow

你也可以自己选择对应的Tensorflow版本,可以在清华镜像中查看

测试

在Anaconda Prompt窗口中输入: python

进入python后输入:


import tensorflow as tf
tf.__version__
tf.__path__  

pycharm配置

清华镜像

https://mirrors.tuna.tsinghua.edu/pypi/web/simple/tensorflow/

其他方式:
使用清华开源镜像安装tensorflow
安装tensorflow时,如果使用直接安装速度相对较慢,采取清华大学的镜像会提高速度。
GPU版本安装方法:
pip install tensorflow-gpu==1.8 -i https://pypi.tuna.tsinghua.edu/simple

pip install tensorflow==1.8 -i https://pypi.tuna.tsinghua.edu/simple

清华源:https://pypi.tuna.tsinghua.edu/simple
豆瓣源:https://pypi.doubanio/simple

安装gpu报错:
Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问
参考文章:https://blog.csdn/weixin_44322778/article/details/122344787

完成安装过程如下图所示:

anaconda promot中指令:

(tensorflow) C:\Users\cgh>pip install tensorflow==1.15 -i https://pypi.tuna.tsinghua.edu.cn/simple

(tensorflow) C:\Users\cgh>pip install tensorflow-gpu==1.15 -i https://pypi.tuna.tsinghua.edu.cn/simple

本文标签: 清华镜像Windowstensorflow