1、下载anaconda并安装
2、创建新的环境:
conda create -n tensorflow python=3.7
3、激活环境:
source activate tensorflow
若退出环境:
source deactivate
4、安装tensorflow
pip install tensorflow
5、此时安装好运行会报错( Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA):
完美解决方法:
在github网站上使用支持AVX2的版本进行安装:
网站链接:https://github.com/lakshayg/tensorflow-build
看好版本后复制下载URL,使用
pip install --ignore-installed --upgrade "URL"
进行安装
6、测试代码:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))