Win10系统Tensorflow安装
tips :Tensorflow 安装
文章目录
一、安装Anaconda
1、从官网下载Anaconda
最新版本官网下载:(本地地址:D:\软件\Anaconda3-2019.07-Windows-x86_64.exe)
https://www.anaconda.com/distribution/
老版本下载的清华镜像网址:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
2、安装Anaconda
当到选择Advanced Options时,一般勾选两个选项。
3、环境变量测试
(1)检测anoconda环境是否安装成功:
conda --version
(2)查看环境变量配置:
conda info --envs
(3)查看python版本并设置:
conda search --full --name python
conda create --name tensorflow python=3.6
(4)激活tensorflow的环境:
activate tensorflow
(5)检测tensorflow环境添加到anaconda环境变量中。
conda info --envs
(6)退出tensorflow环境:
deactivate
注:Anaconda的官方开发文档:
https://docs.anaconda.com/anaconda/user-guide/getting-started
https://anaconda.org/
4、安装Tensorflow
(1)设置国内代理:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
(2)更新pip:
python -m pip --default-timeout=100 install --upgrade pip
注:设大失效时间
(3)安装Tensorflow:
conda create -n tensorflow python=3.6
pip --default-timeout=100 install --upgrade --ignore-installed tensorflow
(4)测试代码:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
注:国内源
新版ubuntu要求使用https源,要注意。
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
设置pip安装从国内镜像获取:
(1)临时使用:pip install -i 地址
(2)永久设置:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。