Ubuntu 22.04
Sponsored Link

TensorFlow : Docker छवि का उपयोग करें (CPU)2023/09/21

 
TensorFlow स्थापित करें जो मशीन लर्निंग लाइब्रेरी है।
इस उदाहरण पर, GPU समर्थन के बिना TensorFlow आधिकारिक Docker छवि स्थापित करें और इसे कंटेनरों पर चलाएं।
[1]
[2] TensorFlow Docker (केवल CPU) स्थापित करें।
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

# कंटेनर चलाएँ

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)

# हैलो वर्ल्ड टेस्ट स्क्रिप्ट बनाएं और इसे कंटेनर पर चलाएं

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] TensorFlow Docker Image स्थापित करें जिसमें 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

# कंटेनर को डेमॉन के रूप में चलाएँ

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

# यूआरएल की पुष्टि करें

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

Currently running servers:
http://0.0.0.0:8888/?token=d3a7a2bd19e9bf986ff54b7280812d5de75c93d06e4898ce :: /tf
  उपरोक्त URL तक पहुंच, फिर Jupyter Notebook का उपयोग करना संभव है।
मिलान सामग्री