Ubuntu 22.04
Sponsored Link

TensorFlow : Use Docker Image (CPU)2022/09/08

 
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).
root@dlp:~#
docker pull tensorflow/tensorflow:latest
root@dlp:~#
docker images

REPOSITORY              TAG              IMAGE ID       CREATED        SIZE
tensorflow/tensorflow   latest           976c17ec6daa   34 hours ago   1.46GB

# run container

root@dlp:~#
docker run --rm tensorflow/tensorflow:latest \
python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

2022-09-08 05:46:54.777140: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-09-08 05:46:57.014887: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.Tensor(-654.6173, shape=(), dtype=float32)

# create Hello World test script and run it on container

root@dlp:~#
vi hello_tensorflow.py
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow World!')
tf.print(hello)

root@dlp:~#
docker run --rm -v $PWD:/tmp -w /tmp tensorflow/tensorflow:latest python3 ./hello_tensorflow.py

2022-09-08 05:48:16.886674: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-09-08 05:48:18.236757: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Hello, TensorFlow World!
[3] Install TensorFlow Docker Image with Jupyter Notebook.
root@dlp:~#
docker pull tensorflow/tensorflow:latest-jupyter
root@dlp:~#
docker images

REPOSITORY              TAG              IMAGE ID       CREATED        SIZE
tensorflow/tensorflow   latest-jupyter   c94342dbd1e8   34 hours ago   1.68GB
tensorflow/tensorflow   latest           976c17ec6daa   34 hours ago   1.46GB

# run container as daemon

root@dlp:~#
docker run -dt -p 8888:8888 tensorflow/tensorflow:latest-jupyter

a2c4cd0c12f8d36b24e54edc257099cba7581c1ed6d14864595879e6e47f49b6

root@dlp:~#
docker ps

CONTAINER ID   IMAGE                                  COMMAND                  CREATED         STATUS         PORTS                                       NAMES
a2c4cd0c12f8   tensorflow/tensorflow:latest-jupyter   "bash -c 'source /et…"   8 seconds ago   Up 7 seconds   0.0.0.0:8888->8888/tcp, :::8888->8888/tcp   unruffled_fermat

# confirm URL

root@dlp:~#
docker exec a2c4cd0c12f8 bash -c "jupyter notebook list"

Currently running servers:
http://0.0.0.0:8888/?token=d3a7a2bd19e9bf986ff54b7280812d5de75c93d06e4898ce :: /tf
  Access to the URL above, then it's possible to use Jupyter Notebook.
Matched Content