Tensorflow 安装
pip
TensorFlow 2
pip install --upgrade pip
pip install tensorflow
pip install tf-nightly
说明:
TensorFlow 1.x
# CPU 版本
tensorflow==1.15
# GPU 版本
tensorflow-gpu==1.15
conda
conda install tensorflow-gpu==1.15.0
Docker
docker pull tensorflow/tensorflow:latest # Download latest stable image
docker run -it -p 8888:8888 tensorflow/tensorflow:latest-jupyter # Start Jupyter server
demo
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(hello))
python hello.py