ガイドがここにあります。
https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html
Jetpack 4.4 です。
# Install system packages required by TensorFlow
$ sudo apt-get update
$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
# Install and upgrade pip3.
$ sudo apt-get install python3-pip
$ sudo pip3 install -U pip testresources setuptools
Install the Python package dependencies.
$ sudo pip3 install -U numpy==1.16.1 future==0.17.1 mock==3.0.5 h5py==2.9.0 keras_preprocessing==1.0.5 keras_applications==1.0.8 gast==0.2.2 futures protobuf pybind11
# Installing TensorFlow
$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow
最後の install tensrflow に は、かなり時間がかかりました。
Tensrflow Version 確認
$ python3 -c "import tensorflow as tf; print(tf.version.VERSION)"
2.1.0
Tensorflow を試す – Mnist
コードは、公式のチュートリアルです。
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(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='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, verbose=2)
実行結果は・・・
60000/60000 [==============================] - 14s 225us/sample - loss: 0.2976 - acc: 0.9134
Epoch 2/5
60000/60000 [==============================] - 11s 187us/sample - loss: 0.1400 - acc: 0.9573
Epoch 3/5
60000/60000 [==============================] - 11s 184us/sample - loss: 0.1071 - acc: 0.9671
Epoch 4/5
60000/60000 [==============================] - 11s 183us/sample - loss: 0.0851 - acc: 0.9735
Epoch 5/5
60000/60000 [==============================] - 11s 183us/sample - loss: 0.0738 - acc: 0.9766
10000/10000 - 1s - loss: 0.0770 - acc: 0.9752
でした。