TensorFlow : Install Docker Image (CPU)2020/07/27 |
Install TensorFlow which is the Machine Learning Library.
On this example, Install TensorFlow official Docker Image without GPU support and run it on Containers.
|
|
[1] | |
[2] | Install TensorFlow Docker (CPU only). |
# pull TensorFlow 2.0 with Python3 image root@dlp:~# docker pull tensorflow/tensorflow:2.0.0-py3
docker images REPOSITORY TAG IMAGE ID CREATED SIZE tensorflow/tensorflow 2.0.0-py3 90f5cb97b18f 9 months ago 1.07GB # run container root@dlp:~# docker run --rm tensorflow/tensorflow:2.0.0-py3 \ python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))" 2020-07-27 01:36:18.348693: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2801540000 Hz 2020-07-27 01:36:18.349039: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x3dee3d0 executing computations on platform Host. Devices: 2020-07-27 01:36:18.349066: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version tf.Tensor(-181.85336, shape=(), dtype=float32) import tensorflow as tf hello = tf.constant('Hello, TensorFlow World!') tf.print(hello) docker run --rm -v $PWD:/tmp -w /tmp tensorflow/tensorflow:2.0.0-py3 python ./hello_tensorflow.py 2020-07-27 01:36:50.966974: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2801540000 Hz 2020-07-27 01:36:50.967719: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4a4f5a0 executing computations on platform Host. Devices: 2020-07-27 01:36:50.967870: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version Hello, TensorFlow World! |
[3] | Install TensorFlow Docker Image with Jupyter Notebook. |
# pull TensorFlow 2.0 with Python3/Jupyter image root@dlp:~# docker pull tensorflow/tensorflow:2.0.0-py3-jupyter
docker images REPOSITORY TAG IMAGE ID CREATED SIZE tensorflow/tensorflow 2.0.0-py3-jupyter c652a4fc8a4f 9 months ago 1.22GB tensorflow/tensorflow 2.0.0-py3 90f5cb97b18f 9 months ago 1.07GB # run container as daemon root@dlp:~# docker run -dt -p 8888:8888 tensorflow/tensorflow:2.0.0-py3-jupyter a7ba54773b6366a3005d1a6b65047d4207428e64f87a3ae8ef318eefc656dedfroot@dlp:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a7ba54773b63 tensorflow/tensorflow:2.0.0-py3-jupyter "bash -c 'source /et…" 23 seconds ago Up 22 seconds 0.0.0.0:8888->8888/tcp busy_lamport # confirm URL root@dlp:~# docker exec a7ba54773b63 bash -c "jupyter notebook list" Currently running servers: http://0.0.0.0:8888/?token=2448b0793ae5233727251a0d97de93e438c4aa638e317e03 :: /tf |
Accessto the URL above, then it's possible to use Jupyter Notebook. |
|