Erstellen Sie mit Docker eine TensorFlow-Betriebsüberprüfungsumgebung

Was du machen willst

Laden Sie das Bild TensorFlow Docker herunter https://www.tensorflow.org/install/docker?hl=ja Dann möchte ich den Container starten und die Funktion des Tensorflusses überprüfen.

Annahme

So installieren Sie Docker https://qiita.com/kenichiro-yamato/items/7e3cb21613784a27409d

Vorherige Bestätigung

Ausführung

[root@docker ~]# docker -v
Docker version 19.03.7, build 7141c199a2

Arbeitsbehälter

[root@docker ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Holen Sie sich ein Bild mit Docker Pull

docker pull tensorflow/tensorflow

Ergebnis

[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

Bestätigen Sie, dass das Bild aufgenommen wurde

[root@docker ~]# docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             SIZE
tensorflow/tensorflow                  latest              623195db36df        7 weeks ago         1.46GB

Starten Sie den Container mit Docker-Lauf

Ändern Sie die Optionsspezifikationen wie Speicherspezifikation, Portspezifikation, Hostspezifikation, Spezifikation für gemeinsam genutzte Verzeichnisse usw. nach Bedarf.

docker run -m 4096m -p 80:80 -d --privileged -h yamato.host -i -t -v /root/share:/share:rw --name tensorflow_container1 tensorflow/tensorflow

Bestätigen Sie den Start des Containers und stellen Sie eine Verbindung her

[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

Verbinden Sie sich mit tensorflow_container1 mit.

[root@docker ~]# docker exec -it tensorflow_container1 /bin/bash

________                               _______________
___  __/__________________________________  ____/__  /________      __
__  /  _  _ \_  __ \_  ___/  __ \_  ___/_  /_   __  /_  __ \_ | /| / /
_  /   /  __/  / / /(__  )/ /_/ /  /   _  __/   _  / / /_/ /_ |/ |/ /
/_/    \___//_/ /_//____/ \____//_/    /_/      /_/  \____/____/|__/

Erfolgreiche Verbindung.

Bestätigung des Ausgangszustands

Sie können bereits Python3 und Pip verwenden.

root@yamato:~# python -V
Python 3.6.9
root@yamato:~# pip

Usage:
  pip <command> [options]

Da vim nicht enthalten ist, installieren Sie es.

apt-get update

nach

apt-get install vim

Dann können Sie vim verwenden.

Erstellen Sie eine Py-Datei und probieren Sie es aus

vim test.py


print ("Hello World! I am Kenichiro Yamato")

Lauf.

python test.py

damit

Hello World! I am Kenichiro Yamato

Wird angezeigt, OK.

Probieren Sie den Tensorflow-Beispielcode aus

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)

Lauf.

python sample.py

Es gibt einige Warnungen und Informationen, aber es scheint zu funktionieren.

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

Recommended Posts

Erstellen Sie mit Docker eine TensorFlow-Betriebsüberprüfungsumgebung
Erstellen einer Docker-Umgebung mit WSL
Erstellen Sie mit Docker eine lokale Couchbase-Umgebung
Erstellen Sie mit Docker eine Node.js-Umgebung
Erstellen Sie mit Laradock eine Docker + Laravel-Umgebung
Erstellen Sie mit Docker eine Wordpress-Entwicklungsumgebung
[Docker] Erstellen Sie die Ausführungsumgebung von Jupyter Lab mit Docker
Erstellen Sie eine Umgebung mit Docker unter AWS
So erstellen Sie eine Rails 6-Umgebung mit Docker
Erstellen Sie mit Docker schnell eine WordPress-Entwicklungsumgebung
[Rails] So erstellen Sie eine Umgebung mit Docker
[Rails API x Docker] Einfache Umgebungskonstruktion mit Shell- und Funktionsprüfung mit Flutter
So erstellen Sie eine Docker-Umgebung mit Gradle for IntelliJ
Erstellen Sie mit Docker eine Ruby2.7.x + Rails6.0.x + MySQL8.0.x-Umgebung
[Docker] Rails 5.2-Umgebungskonstruktion mit Docker
Build Rails (API) x MySQL x Nuxt.js Umgebung mit Docker
Spannende Umweltprüfung mit mkmf
Erstellen Sie DynamoDB local mit Docker
So erstellen Sie mit Docker ~ Express ~ eine [TypeScript + Vue + Express + MySQL] -Umgebung
Erstellen Sie mit Docker eine Vue3-Umgebung!
Erstellen Sie die Node.js-Umgebung mit Docker Compose
Erstellen Sie mit Pleiades 4.8 eine Tomcat 8.5-Umgebung
Umgebungsbau mit Docker für Anfänger
Erstellen Sie mit Docker eine SolrCloud-Überprüfungsumgebung
Erstellen Sie mit Eclipse eine Jooby-Entwicklungsumgebung
[Umgebungskonstruktion mit Docker] Rails 6 & MySQL 8
Erstellen Sie eine Unity-Entwicklungsumgebung auf Docker
Build Go-Entwicklungsumgebung mit WSL2 + Docker Desktop + VSCode (Remote - Container)
Ich habe versucht, mit Docker eine Plant UML Server-Umgebung zu erstellen
So erstellen Sie mit Docker ~ MySQL ~ eine [TypeScript + Vue + Express + MySQL] -Umgebung
So erstellen Sie eine Rails + Vue + MySQL-Umgebung mit Docker [neueste Version 2020/09]
Erstellen Sie mit Docker Compose eine Entwicklungsumgebung für Django + MySQL + nginx
So erstellen Sie mit Docker ~ Sequelize ~ eine [TypeScript + Vue + Express + MySQL] -Umgebung
Überprüfen Sie den Betrieb mit dem Steg mit Maven.
Aufbau einer GPU-Umgebung mit Docker [Version Oktober 2020]
Schienenumgebungskonstruktion mit Docker (persönliche Apokalypse)
Erstellen einer Rails 6- und PostgreSQL-Umgebung mit Docker
Bearbeiten Sie MySQL mit Befehlen in der Docker-Umgebung
Erstellen Sie eine WAS-Ausführungsumgebung aus Docker
Erstellen Sie mit Docker eine Spring Boot-gradle-mysql-Entwicklungsumgebung
[Docker] Erstellen Sie mit Docker eine Node.js + Express + Webpack-Umgebung
Erstellen einer Umgebung für Laravel + MySQL + phpMyadmin mit Docker