1、打开Anaconda Prompt
2、搭建TensorFlow的环境:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
conda create -n tensorflow python=3.5
3、在用户目录下找到文件 .condarc
环境搭建完成:
4、安装(CPU)版的TensorFlow:
// 启动TensorFlow:
activate tensorflow
conda install tensorflow
5、测试TensorFlow是否安装完成
终端进入python:
输入:
import tensorflow as tf
hello = tf.constant("hello, tensorflow!")
sess = tf.Session()
print(sess.run(hello))输出: b'hello, tensorflow!',即成功!!!
6、在Jupiter中使用TensorFlow
准备工作:
- 安装ipython,安装jupyter
conda install ipython
conda install jupyter- 输入:
ipython kernelspec install-self --user- 看到类似这个结果
Installed kernelspec python3 in C:\Users\XXX\Jupyter\kernels\python3 即可以了!
打开Anaconda Jupiter 稍等一会
复制网址,浏览器打开
新建python3文件
输入:
import tensorflow as tf
tf.__version__输出:
即安装成功!
7、安装成功后,每次使用 TensorFlow 的时候都需要激活 conda 环境
//查看环境
conda info --envs
//激活环境
activate tensorflow
//关闭环境
deactivate tensorflow