Télécharger l'image Docker TensorFlow https://www.tensorflow.org/install/docker?hl=ja Ensuite, je veux démarrer le conteneur et vérifier le fonctionnement de tensorflow.
Comment installer Docker https://qiita.com/kenichiro-yamato/items/7e3cb21613784a27409d
version
[root@docker ~]# docker -v
Docker version 19.03.7, build 7141c199a2
Conteneur de travail
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker pull tensorflow/tensorflow
résultat
[root@docker ~]# docker pull tensorflow/tensorflow
Using default tag: latest
latest: Pulling from tensorflow/tensorflow
171857c49d0f: Pull complete
419640447d26: Pull complete
61e52f862619: Pull complete
40085aa86d3c: Pull complete
b827fdfa00c7: Pull complete
134f84527676: Pull complete
e1f30e7788ed: Pull complete
a13925316d82: Pull complete
5decca4d86ff: Pull complete
70c56a3cd1fa: Pull complete
Digest: sha256:c57fb9628d80872ece8640a22bd0153b2cc8d62d21d79f4d99c3b237a728b62e
Status: Downloaded newer image for tensorflow/tensorflow:latest
docker.io/tensorflow/tensorflow:latest
Confirmez que l'image a été acquise
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tensorflow/tensorflow latest 623195db36df 7 weeks ago 1.46GB
Modifiez les spécifications des options telles que la spécification de la mémoire, la spécification du port, la spécification d'hôte, la spécification de répertoire partagé, etc. selon vos besoins.
docker run -m 4096m -p 80:80 -d --privileged -h yamato.host -i -t -v /root/share:/share:rw --name tensorflow_container1 tensorflow/tensorflow
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62f578fc0279 tensorflow/tensorflow "/bin/bash" 11 seconds ago Up 10 seconds 0.0.0.0:80->80/tcp tensorflow_container1
docker exec -it tensorflow_container1 /bin/bash
Connectez-vous à tensorflow_container1 avec.
[root@docker ~]# docker exec -it tensorflow_container1 /bin/bash
________ _______________
___ __/__________________________________ ____/__ /________ __
__ / _ _ \_ __ \_ ___/ __ \_ ___/_ /_ __ /_ __ \_ | /| / /
_ / / __/ / / /(__ )/ /_/ / / _ __/ _ / / /_/ /_ |/ |/ /
/_/ \___//_/ /_//____/ \____//_/ /_/ /_/ \____/____/|__/
Connexion réussie.
Vous pouvez déjà utiliser python3 et pip.
root@yamato:~# python -V
Python 3.6.9
root@yamato:~# pip
Usage:
pip <command> [options]
Puisque vim n'est pas inclus, installez-le.
apt-get update
après
apt-get install vim
Ensuite, vous pouvez utiliser vim.
vim test.py
print ("Hello World! I am Kenichiro Yamato")
Courir.
python test.py
donc
Hello World! I am Kenichiro Yamato
Est affiché, OK.
vi sample.py
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)
Courir.
python sample.py
Il y a quelques avertissements et informations, mais cela semble fonctionner.
2020-11-18 10:00:09.352555: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2020-11-18 10:00:09.352579: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2020-11-18 10:00:10.743602: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2020-11-18 10:00:10.743630: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)
2020-11-18 10:00:10.743654: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (yamato.host): /proc/driver/nvidia/version does not exist
2020-11-18 10:00:10.743940: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-11-18 10:00:10.752038: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3599995000 Hz
2020-11-18 10:00:10.752747: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4e64770 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-11-18 10:00:10.752763: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
Epoch 1/5
1875/1875 [==============================] - 3s 2ms/step - loss: 0.2193 - accuracy: 0.9347
Epoch 2/5
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0972 - accuracy: 0.9705
Epoch 3/5
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0676 - accuracy: 0.9789
Epoch 4/5
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0525 - accuracy: 0.9831
Epoch 5/5
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0423 - accuracy: 0.9862
313/313 [==============================] - 0s 1ms/step - loss: 0.0640 - accuracy: 0.9801