Docker 启动TensorFlow

Docker 启动TensorFlow

参考网站:

Running Containers

1、

$ docker run -it --rm tensorflow/tensorflow bash

Start a CPU-only container with Python 2


2、

$ docker run -it --rm --runtime=nvidia tensorflow/tensorflow:latest-gpu-py3 python

Start a GPU container with Python 3, using the Python interpreter.


3、

$ docker run -it --rm -v $(realpath ~/notebooks):/tf/notebooks -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter

Run a Jupyter notebook server with your own notebook directory (assumed here to be ~/notebooks). To use it, navigate to localhost:8888 in your browser.

重点强调第三种方式,启动web页面可视化容器。

创建demo案例:

通过如下截图创建并执行:

www.zeeklog.com - Docker 启动TensorFlow
www.zeeklog.com - Docker 启动TensorFlow

demo代码:

import tensorflow as tf
a = tf.constant(10)
b = tf.constant(32)

with tf.Session():
    c = tf.add(a,b)
    print(c)
    print(c.eval())