Debian 12 bookworm
Sponsored Link

TensorFlow : Use Docker Image (CPU)2023/07/14

 
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                       f9de31709f1f   7 days ago    1.64GB

# 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])))"

2023-07-14 08:20:31.036699: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.Tensor(640.3597, 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

2023-07-14 08:21:08.274859: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, 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               30902b4c7482   7 days ago    1.92GB
tensorflow/tensorflow   latest                       f9de31709f1f   7 days ago    1.64GB

# run container as daemon

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

7f5c428050d93c9cea1b6962411f7995168659bd4d3281150465d623edddb4f6

root@dlp:~#
docker ps

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

# confirm URL

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

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