Hello TensorFlow

  • 启动Docker
$ docker-machine start default
$ eval "$(docker-machine env default)"
  • 下载TensorFlow容器
$ docker pull gcr.io/tensorflow/tensorflow
  • 启动TensorFlow容器并进入python
$ docker run --rm -it gcr.io/tensorflow/tensorflow python
  • Hello World
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42