0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NVIDIA Jetson Nano Dev Kit B01に TensorFlow をインストールする

Last updated at Posted at 2020-05-06

インストール手順

1. HDF5 のインストール

$ sudo apt-get install libhdf5-serial-dev hdf5-tools

2. pip のインストール

$ sudo apt-get install python3-pip

3. その他パッケージのインストール

$ sudo apt-get install zlib1g-dev zip libjpeg8-dev libhdf5-dev 
$ sudo pip3 install -U numpy grpcio absl-py py-cpuinfo psutil portpicker grpcio six mock requests gast h5py astor termcolor

4. TensorFlow のインストール

$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu

5. インストールを確認

$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf.__version__)
1.13.1
>>> quit()

上記で TensorFlow のインストールは完了です。

TensorFlow チュートリアル・コードを動作させる

mkdir logs
gedit mnist.py
mnist.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(input_shape=(28, 28)),
  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'])

log_filepath = "./logs/"
tb_cb = tf.keras.callbacks.TensorBoard(log_dir=log_filepath, histogram_freq=1)

model.fit(x_train, y_train, epochs=5, validation_data=(x_test, y_test), callbacks=[tb_cb])
model.evaluate(x_test, y_test)

model.save('mnist.hdf5')

TensorBoard起動

$ tensorboard --logdir=./logs

TensorBorad が起動したら Jetson Nano 上の Chromium ブラウザで localhost:6006 を開きます。

i
i2

保存したモデルを Netron ブラウザ・バージョン で確認

Screenshot from 2020-05-06 13-23-51.png

以上です。

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?