3
3

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.

初心者が機械学習をやってみたら(その4)

Last updated at Posted at 2020-07-18

今回は、開発環境の構築を行います。
使用したイメージファイルは「JetPack 4.3」と言うことで、
NVIDIAのサイトに従い構築していきます。

#1.TensorFlowに必要なシステムパッケージをインストールします。

##1.1.リポジトリ更新
$ sudo apt-get update
実行

リポジトリ更新.
$ sudo apt-get update
Get:1 file:/var/cuda-repo-10-0-local-10.0.326  InRelease
Ign:1 file:/var/cuda-repo-10-0-local-10.0.326  InRelease
Get:2 file:/var/visionworks-repo  InRelease
Ign:2 file:/var/visionworks-repo  InRelease
Get:3 file:/var/visionworks-sfm-repo  InRelease
Ign:3 file:/var/visionworks-sfm-repo  InRelease
Get:4 file:/var/visionworks-tracking-repo  InRelease
Ign:4 file:/var/visionworks-tracking-repo  InRelease
Get:5 file:/var/cuda-repo-10-0-local-10.0.326  Release [574 B]
Get:6 file:/var/visionworks-repo  Release [1,999 B]                         
Get:7 file:/var/visionworks-sfm-repo  Release [2,003 B]                        
Get:8 file:/var/visionworks-tracking-repo  Release [2,008 B]                   
Get:5 file:/var/cuda-repo-10-0-local-10.0.326  Release [574 B]                 
Get:6 file:/var/visionworks-repo  Release [1,999 B]                            
Get:7 file:/var/visionworks-sfm-repo  Release [2,003 B]                        
Get:8 file:/var/visionworks-tracking-repo  Release [2,008 B]                   
Get:9 https://repo.download.nvidia.com/jetson/common r32 InRelease [2,541 B]   
Get:10 https://repo.download.nvidia.com/jetson/t210 r32 InRelease [2,555 B]    
Hit:13 http://ports.ubuntu.com/ubuntu-ports bionic InRelease                   
Hit:15 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease
Hit:17 http://ports.ubuntu.com/ubuntu-ports bionic-backports InRelease
Hit:18 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease
Fetched 5,096 B in 2s (2,197 B/s)                   
Reading package lists... Done

##1.2.必要システムパッケージをインストール

$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
実行

必要システムパッケージインストール.
$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
Reading package lists... Done
Building dependency tree       
Reading state information... Done
zip is already the newest version (3.0-11build1).
zip set to manually installed.
zlib1g-dev is already the newest version (1:1.2.11.dfsg-0ubuntu2).
zlib1g-dev set to manually installed.
The following additional packages will be installed:
  cpp-7 g++-7 gcc-7 gcc-7-base gfortran-7 hdf5-helpers libaec-dev libaec0
  libasan4 libgcc-7-dev libgfortran-7-dev libgfortran4 libhdf5-100
  libhdf5-cpp-100 libjpeg-turbo8 libjpeg-turbo8-dev libstdc++-7-dev libsz2
  libubsan0
Suggested packages:
  gcc-7-locales gcc-7-doc libstdc++6-7-dbg libgcc1-dbg libgomp1-dbg
  libitm1-dbg libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg
  libubsan0-dbg libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg gfortran-doc
  gfortran-7-doc libgfortran4-dbg libcoarrays-dev liblapack-doc libhdf5-doc
  libstdc++-7-doc
The following NEW packages will be installed:
  gfortran gfortran-7 hdf5-helpers hdf5-tools libaec-dev libaec0 libblas-dev
  libgfortran-7-dev libhdf5-100 libhdf5-cpp-100 libhdf5-dev libhdf5-serial-dev
  libjpeg-turbo8-dev libjpeg8-dev liblapack-dev libsz2
The following packages will be upgraded:
  cpp-7 g++-7 gcc-7 gcc-7-base libasan4 libgcc-7-dev libgfortran4
  libjpeg-turbo8 libstdc++-7-dev libubsan0
10 upgraded, 16 newly installed, 0 to remove and 302 not upgraded.
Need to get 39.5 MB of archives.
After this operation, 58.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]   # Yを入力してください。
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libjpeg-turbo8 arm64 1.5.2-0ubuntu5.18.04.4 [91.5 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libasan4 arm64 7.5.0-3ubuntu1~18.04 [335 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libubsan0 arm64 7.5.0-3ubuntu1~18.04 [117 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 g++-7 arm64 7.5.0-3ubuntu1~18.04 [8,077 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 gcc-7 arm64 7.5.0-3ubuntu1~18.04 [7,772 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libstdc++-7-dev arm64 7.5.0-3ubuntu1~18.04 [1,471 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libgcc-7-dev arm64 7.5.0-3ubuntu1~18.04 [833 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libgfortran4 arm64 7.5.0-3ubuntu1~18.04 [248 kB]
Get:9 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 cpp-7 arm64 7.5.0-3ubuntu1~18.04 [7,046 kB]
Get:10 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 gcc-7-base arm64 7.5.0-3ubuntu1~18.04 [18.3 kB]
Get:11 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libgfortran-7-dev arm64 7.5.0-3ubuntu1~18.04 [300 kB]
Get:12 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 gfortran-7 arm64 7.5.0-3ubuntu1~18.04 [7,465 kB]
Get:13 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 gfortran arm64 4:7.4.0-1ubuntu2.3 [1,344 B]
Get:14 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 hdf5-helpers arm64 1.10.0-patch1+docs-4 [12.3 kB]
Get:15 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libaec0 arm64 0.3.2-2 [16.7 kB]
Get:16 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libsz2 arm64 0.3.2-2 [4,926 B]
Get:17 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libhdf5-100 arm64 1.10.0-patch1+docs-4 [1,010 kB]
Get:18 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 hdf5-tools arm64 1.10.0-patch1+docs-4 [329 kB]
Get:19 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libblas-dev arm64 3.7.1-4ubuntu1 [87.2 kB]
Get:20 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libhdf5-cpp-100 arm64 1.10.0-patch1+docs-4 [102 kB]
Get:21 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libjpeg-turbo8-dev arm64 1.5.2-0ubuntu5.18.04.4 [203 kB]
Get:22 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libaec-dev arm64 0.3.2-2 [14.8 kB]
Get:23 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libhdf5-dev arm64 1.10.0-patch1+docs-4 [2,502 kB]
Get:24 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libhdf5-serial-dev all 1.10.0-patch1+docs-4 [2,898 B]
Get:25 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libjpeg8-dev arm64 8c-2ubuntu8 [1,550 B]
Get:26 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 liblapack-dev arm64 3.7.1-4ubuntu1 [1,393 kB]
Fetched 39.5 MB in 39s (1,022 kB/s)                                            
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 144420 files and directories currently installed.)
Preparing to unpack .../00-libjpeg-turbo8_1.5.2-0ubuntu5.18.04.4_arm64.deb ...
Unpacking libjpeg-turbo8:arm64 (1.5.2-0ubuntu5.18.04.4) over (1.5.2-0ubuntu5.18.04.3) ...
Preparing to unpack .../01-libasan4_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking libasan4:arm64 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../02-libubsan0_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking libubsan0:arm64 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../03-g++-7_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking g++-7 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../04-gcc-7_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking gcc-7 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../05-libstdc++-7-dev_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking libstdc++-7-dev:arm64 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../06-libgcc-7-dev_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking libgcc-7-dev:arm64 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../07-libgfortran4_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking libgfortran4:arm64 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../08-cpp-7_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking cpp-7 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Preparing to unpack .../09-gcc-7-base_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking gcc-7-base:arm64 (7.5.0-3ubuntu1~18.04) over (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package libgfortran-7-dev:arm64.
Preparing to unpack .../10-libgfortran-7-dev_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking libgfortran-7-dev:arm64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package gfortran-7.
Preparing to unpack .../11-gfortran-7_7.5.0-3ubuntu1~18.04_arm64.deb ...
Unpacking gfortran-7 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package gfortran.
Preparing to unpack .../12-gfortran_4%3a7.4.0-1ubuntu2.3_arm64.deb ...
Unpacking gfortran (4:7.4.0-1ubuntu2.3) ...
Selecting previously unselected package hdf5-helpers.
Preparing to unpack .../13-hdf5-helpers_1.10.0-patch1+docs-4_arm64.deb ...
Unpacking hdf5-helpers (1.10.0-patch1+docs-4) ...
Selecting previously unselected package libaec0:arm64.
Preparing to unpack .../14-libaec0_0.3.2-2_arm64.deb ...
Unpacking libaec0:arm64 (0.3.2-2) ...
Selecting previously unselected package libsz2:arm64.
Preparing to unpack .../15-libsz2_0.3.2-2_arm64.deb ...
Unpacking libsz2:arm64 (0.3.2-2) ...
Selecting previously unselected package libhdf5-100:arm64.
Preparing to unpack .../16-libhdf5-100_1.10.0-patch1+docs-4_arm64.deb ...
Unpacking libhdf5-100:arm64 (1.10.0-patch1+docs-4) ...
Selecting previously unselected package hdf5-tools.
Preparing to unpack .../17-hdf5-tools_1.10.0-patch1+docs-4_arm64.deb ...
Unpacking hdf5-tools (1.10.0-patch1+docs-4) ...
Selecting previously unselected package libblas-dev:arm64.
Preparing to unpack .../18-libblas-dev_3.7.1-4ubuntu1_arm64.deb ...
Unpacking libblas-dev:arm64 (3.7.1-4ubuntu1) ...
Selecting previously unselected package libhdf5-cpp-100:arm64.
Preparing to unpack .../19-libhdf5-cpp-100_1.10.0-patch1+docs-4_arm64.deb ...
Unpacking libhdf5-cpp-100:arm64 (1.10.0-patch1+docs-4) ...
Selecting previously unselected package libjpeg-turbo8-dev:arm64.
Preparing to unpack .../20-libjpeg-turbo8-dev_1.5.2-0ubuntu5.18.04.4_arm64.deb ...
Unpacking libjpeg-turbo8-dev:arm64 (1.5.2-0ubuntu5.18.04.4) ...
Selecting previously unselected package libaec-dev:arm64.
Preparing to unpack .../21-libaec-dev_0.3.2-2_arm64.deb ...
Unpacking libaec-dev:arm64 (0.3.2-2) ...
Selecting previously unselected package libhdf5-dev.
Preparing to unpack .../22-libhdf5-dev_1.10.0-patch1+docs-4_arm64.deb ...
Unpacking libhdf5-dev (1.10.0-patch1+docs-4) ...
Selecting previously unselected package libhdf5-serial-dev.
Preparing to unpack .../23-libhdf5-serial-dev_1.10.0-patch1+docs-4_all.deb ...
Unpacking libhdf5-serial-dev (1.10.0-patch1+docs-4) ...
Selecting previously unselected package libjpeg8-dev:arm64.
Preparing to unpack .../24-libjpeg8-dev_8c-2ubuntu8_arm64.deb ...
Unpacking libjpeg8-dev:arm64 (8c-2ubuntu8) ...
Selecting previously unselected package liblapack-dev:arm64.
Preparing to unpack .../25-liblapack-dev_3.7.1-4ubuntu1_arm64.deb ...
Unpacking liblapack-dev:arm64 (3.7.1-4ubuntu1) ...
Setting up libaec0:arm64 (0.3.2-2) ...
Setting up libblas-dev:arm64 (3.7.1-4ubuntu1) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/blas/libblas.so to provide /usr/lib/aarch64-linux-gnu/libblas.so (libblas.so-aarch64-linux-gnu) in auto mode
Setting up libjpeg-turbo8:arm64 (1.5.2-0ubuntu5.18.04.4) ...
Setting up gcc-7-base:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up libjpeg-turbo8-dev:arm64 (1.5.2-0ubuntu5.18.04.4) ...
Setting up libjpeg8-dev:arm64 (8c-2ubuntu8) ...
Setting up hdf5-helpers (1.10.0-patch1+docs-4) ...
Setting up libsz2:arm64 (0.3.2-2) ...
Setting up liblapack-dev:arm64 (3.7.1-4ubuntu1) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/lapack/liblapack.so to provide /usr/lib/aarch64-linux-gnu/liblapack.so (liblapack.so-aarch64-linux-gnu) in auto mode
Setting up libasan4:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up libgfortran4:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up libubsan0:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up libaec-dev:arm64 (0.3.2-2) ...
Setting up libgcc-7-dev:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up cpp-7 (7.5.0-3ubuntu1~18.04) ...
Setting up libstdc++-7-dev:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up libgfortran-7-dev:arm64 (7.5.0-3ubuntu1~18.04) ...
Setting up libhdf5-100:arm64 (1.10.0-patch1+docs-4) ...
Setting up gcc-7 (7.5.0-3ubuntu1~18.04) ...
Setting up g++-7 (7.5.0-3ubuntu1~18.04) ...
Setting up hdf5-tools (1.10.0-patch1+docs-4) ...
Setting up gfortran-7 (7.5.0-3ubuntu1~18.04) ...
Setting up gfortran (4:7.4.0-1ubuntu2.3) ...
update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/f95.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f95) doesn't exist
update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f77 (f77) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/f77.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f77) doesn't exist
Setting up libhdf5-cpp-100:arm64 (1.10.0-patch1+docs-4) ...
Setting up libhdf5-dev (1.10.0-patch1+docs-4) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/pkgconfig/hdf5-serial.pc to provide /usr/lib/aarch64-linux-gnu/pkgconfig/hdf5.pc (hdf5.pc) in auto mode
Setting up libhdf5-serial-dev (1.10.0-patch1+docs-4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

#2.pip3インストールとアップグレードします。

##2.1.pip3インストール

sudo apt-get install python3-pip
実行

pip3インストール.
$ sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (9.0.1-2.3~ubuntu1.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 302 not upgraded.

##2.2.pip3アップグレード

sudo sudo pip3 install -U pip testresources setuptools
実行

pip3アップグレード.
$ sudo pip3 install -U pip testresources setuptools
Collecting pip
  Downloading https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl (1.5MB)
     |████████████████████████████████| 1.5MB 2.6MB/s 
Collecting testresources
  Downloading https://files.pythonhosted.org/packages/45/4d/79a9a1f71de22fbc6c6433ac135f68d005de72fbe73e2137d2e77da9252c/testresources-2.0.1-py2.py3-none-any.whl
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/8e/11/9e10f1cad4518cb307b484c255cae61e97f05b82f6d536932b1714e01b47/setuptools-49.2.0-py3-none-any.whl (789kB)
     |████████████████████████████████| 798kB 11.1MB/s 
Collecting pbr>=1.8
  Downloading https://files.pythonhosted.org/packages/96/ba/aa953a11ec014b23df057ecdbc922fdb40ca8463466b1193f3367d2711a6/pbr-5.4.5-py2.py3-none-any.whl (110kB)
     |████████████████████████████████| 112kB 17.8MB/s 
Installing collected packages: pip, pbr, testresources, setuptools
  Found existing installation: pip 19.3.1
    Uninstalling pip-19.3.1:
      Successfully uninstalled pip-19.3.1
  Found existing installation: setuptools 39.0.1
    Uninstalling setuptools-39.0.1:
      Successfully uninstalled setuptools-39.0.1
Successfully installed pbr-5.4.5 pip-20.1.1 setuptools-49.2.0 testresources-2.0.1

#3.Pythonパッケージの依存関係をインストールします。

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
実行

Pythonパッケージ依存関係インストール.
$ 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

Collecting numpy==1.16.1
  Downloading numpy-1.16.1.zip (5.1 MB)
     |████████████████████████████████| 5.1 MB 9.3 kB/s 
Collecting future==0.17.1
  Downloading future-0.17.1.tar.gz (829 kB)
     |████████████████████████████████| 829 kB 17.0 MB/s 
Collecting mock==3.0.5
  Downloading mock-3.0.5-py2.py3-none-any.whl (25 kB)
Collecting h5py==2.9.0
  Downloading h5py-2.9.0.tar.gz (287 kB)
     |████████████████████████████████| 287 kB 18.2 MB/s 
Collecting keras_preprocessing==1.0.5
  Downloading Keras_Preprocessing-1.0.5-py2.py3-none-any.whl (30 kB)
Collecting keras_applications==1.0.8
  Downloading Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
     |████████████████████████████████| 50 kB 1.2 MB/s 
Collecting gast==0.2.2
  Downloading gast-0.2.2.tar.gz (10 kB)
Collecting futures
  Downloading futures-3.1.1-py3-none-any.whl (2.8 kB)
Collecting protobuf
  Downloading protobuf-3.12.2-py2.py3-none-any.whl (443 kB)
     |████████████████████████████████| 443 kB 17.7 MB/s 
Collecting pybind11
  Downloading pybind11-2.5.0-py2.py3-none-any.whl (296 kB)
     |████████████████████████████████| 296 kB 20.0 MB/s 
Requirement already satisfied, skipping upgrade: six in /usr/lib/python3/dist-packages (from mock==3.0.5) (1.11.0)
Requirement already satisfied, skipping upgrade: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf) (49.2.0)
Building wheels for collected packages: numpy, future, h5py, gast
  Building wheel for numpy (setup.py) ... done
  Created wheel for numpy: filename=numpy-1.16.1-cp36-cp36m-linux_aarch64.whl size=7332433 sha256=0972cb10d25b738703b20714867a0a77af0b428cf3f7bfc5b74c53d29af5af82
  Stored in directory: /home/dlinano/.cache/pip/wheels/11/6e/75/98ac58953d51b83c763aaa04971aa962fb4b0af518b8b2f0c0
  Building wheel for future (setup.py) ... done
  Created wheel for future: filename=future-0.17.1-py3-none-any.whl size=490929 sha256=7af5cb8137b6c67b542ef96660ce779063bbc1e56bd7c15de9a9612fc172f58b
  Stored in directory: /home/dlinano/.cache/pip/wheels/c4/f0/e2/8e4ecc9e1b12a428a7657ba683576d3e79d0a75982f63e8fd2
  Building wheel for h5py (setup.py) ... done
  Created wheel for h5py: filename=h5py-2.9.0-cp36-cp36m-linux_aarch64.whl size=3943156 sha256=dea51c5286230ddc4337ab516d65d3ded98b3c25e0f4f96b4109c1795459bd2c
  Stored in directory: /home/dlinano/.cache/pip/wheels/de/4b/ce/760cffd13ccc473d7d266fd6029ac25396a149b36e1dfd3564
  Building wheel for gast (setup.py) ... done
  Created wheel for gast: filename=gast-0.2.2-py3-none-any.whl size=7635 sha256=e270d69786b152eb2c6ad1af93dc9849ae78b03c4b5e9d0835f08b550ef3fc3f
  Stored in directory: /home/dlinano/.cache/pip/wheels/19/a7/b9/0740c7a3a7d1d348f04823339274b90de25fbcd217b2ee1fbe
Successfully built numpy future h5py gast
Installing collected packages: numpy, future, mock, h5py, keras-preprocessing, keras-applications, gast, futures, protobuf, pybind11
  Attempting uninstall: numpy
    Found existing installation: numpy 1.18.1
    Uninstalling numpy-1.18.1:
      Successfully uninstalled numpy-1.18.1
  Attempting uninstall: protobuf
    Found existing installation: protobuf 3.0.0
    Uninstalling protobuf-3.0.0:
      Successfully uninstalled protobuf-3.0.0
Successfully installed future-0.17.1 futures-3.1.1 gast-0.2.2 h5py-2.9.0 keras-applications-1.0.8 keras-preprocessing-1.0.5 mock-3.0.5 numpy-1.16.1 protobuf-3.12.2 pybind11-2.5.0

#4.TensorFlowのインストールします。

今回は「JetPack 4.3」なので「v43」としました。

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

TensorFlowインストール.
$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v43 tensorflow
Looking in indexes: https://pypi.org/simple, https://developer.download.nvidia.com/compute/redist/jp/v43
Collecting tensorflow
  Downloading https://developer.download.nvidia.com/compute/redist/jp/v43/tensorflow/tensorflow-2.1.0%2Bnv20.3-cp36-cp36m-linux_aarch64.whl (236.9 MB)
     |████████████████████████████████| 236.9 MB 434 bytes/s 
Requirement already satisfied: wheel>=0.26; python_version >= "3" in /usr/lib/python3/dist-packages (from tensorflow) (0.30.0)
Collecting google-pasta>=0.1.6
  Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 759 kB/s 
Collecting keras-preprocessing>=1.1.0
  Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 278 kB/s 
Requirement already satisfied: gast==0.2.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.2.2)
Requirement already satisfied: protobuf>=3.8.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (3.12.2)
Collecting six>=1.12.0
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting scipy==1.4.1; python_version >= "3"
  Downloading scipy-1.4.1.tar.gz (24.6 MB)
     |████████████████████████████████| 24.6 MB 25 kB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.2.1-py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 31 kB/s 
Collecting astor>=0.6.0
  Downloading astor-0.8.1-py2.py3-none-any.whl (27 kB)
Requirement already satisfied: numpy<2.0,>=1.16.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.16.1)
Collecting tensorflow-estimator<2.2.0,>=2.1.0rc0
  Downloading tensorflow_estimator-2.1.0-py2.py3-none-any.whl (448 kB)
     |████████████████████████████████| 448 kB 15.9 MB/s 
Collecting wrapt>=1.11.1
  Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting grpcio>=1.8.6
  Downloading grpcio-1.30.0.tar.gz (19.7 MB)
     |████████████████████████████████| 19.7 MB 8.4 kB/s 
Requirement already satisfied: keras-applications>=1.0.8 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.0.8)
Collecting absl-py>=0.7.0
  Downloading absl-py-0.9.0.tar.gz (104 kB)
     |████████████████████████████████| 104 kB 14.7 MB/s 
Collecting termcolor>=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting tensorboard<2.2.0,>=2.1.0
  Downloading tensorboard-2.1.1-py3-none-any.whl (3.8 MB)
     |████████████████████████████████| 3.8 MB 13.8 MB/s 
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.8.0->tensorflow) (49.2.0)
Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras-applications>=1.0.8->tensorflow) (2.9.0)
Collecting requests<3,>=2.21.0
  Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 69 kB/s 
Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (0.16.0)
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.19.1-py2.py3-none-any.whl (91 kB)
     |████████████████████████████████| 91 kB 1.6 MB/s 
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting markdown>=2.6.8
  Downloading Markdown-3.2.2-py3-none-any.whl (88 kB)
     |████████████████████████████████| 88 kB 1.1 MB/s 
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (2018.1.18)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (2.6)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python3/dist-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (1.22)
Collecting rsa<5,>=3.1.4; python_version >= "3"
  Downloading rsa-4.6-py3-none-any.whl (47 kB)
     |████████████████████████████████| 47 kB 773 kB/s 
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.1.1-py3-none-any.whl (10 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 18.6 MB/s 
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard<2.2.0,>=2.1.0->tensorflow) (1.3.0)
Collecting pyasn1>=0.1.3
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 836 kB/s 
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 12.1 MB/s 
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version < "3.8"->markdown>=2.6.8->tensorboard<2.2.0,>=2.1.0->tensorflow) (0.6.0)
Requirement already satisfied: more-itertools in /usr/local/lib/python3.6/dist-packages (from zipp>=0.5->importlib-metadata; python_version < "3.8"->markdown>=2.6.8->tensorboard<2.2.0,>=2.1.0->tensorflow) (8.0.2)
Building wheels for collected packages: scipy, wrapt, grpcio, absl-py, termcolor
  Building wheel for scipy (PEP 517) ... |^[[18~done
  Created wheel for scipy: filename=scipy-1.4.1-cp36-cp36m-linux_aarch64.whl size=43345680 sha256=976547cdfb084a66930adf8254f67ff419f4d8f57182b85d34d86ef44e890155
  Stored in directory: /home/dlinano/.cache/pip/wheels/a7/ec/8f/659245440bf344b931b59491d6a8022f82cf4a79c665c585c3
  Building wheel for wrapt (setup.py) ... done
  Created wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_aarch64.whl size=68906 sha256=9ca4dd5dde0855806220f5fc25f1c32de431620902de5997a30372b1f44ea869
  Stored in directory: /home/dlinano/.cache/pip/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63
  Building wheel for grpcio (setup.py) ... done
  Created wheel for grpcio: filename=grpcio-1.30.0-cp36-cp36m-linux_aarch64.whl size=22176960 sha256=3393167775a536875ac5f5fb312aaaf8e49c0d691e3254f2525aaedc353c891a
  Stored in directory: /home/dlinano/.cache/pip/wheels/1a/ac/d0/12bc45a1e87a416c765a1b54627c2939d53c3008859a0371e1
  Building wheel for absl-py (setup.py) ... done
  Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=119396 sha256=f4c87d4e576f03b10af7f73f09cc14dff9adce6525bb2c1ff8e8c8ce9bf69498
  Stored in directory: /home/dlinano/.cache/pip/wheels/c3/af/84/3962a6af7b4ab336e951b7877dcfb758cf94548bb1771e0679
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=5679 sha256=cdb5d55874f41967186bdec8d96f93c1f4c2205918c979e73c28b002169f809a
  Stored in directory: /home/dlinano/.cache/pip/wheels/93/2a/eb/e58dbcbc963549ee4f065ff80a59f274cc7210b6eab962acdc
Successfully built scipy wrapt grpcio absl-py termcolor
Installing collected packages: six, google-pasta, keras-preprocessing, scipy, opt-einsum, astor, tensorflow-estimator, wrapt, grpcio, absl-py, termcolor, requests, pyasn1, rsa, cachetools, pyasn1-modules, google-auth, oauthlib, requests-oauthlib, google-auth-oauthlib, markdown, tensorboard, tensorflow
  Attempting uninstall: six
    Found existing installation: six 1.11.0
    Uninstalling six-1.11.0:
      Successfully uninstalled six-1.11.0
  Attempting uninstall: keras-preprocessing
    Found existing installation: Keras-Preprocessing 1.0.5
    Uninstalling Keras-Preprocessing-1.0.5:
      Successfully uninstalled Keras-Preprocessing-1.0.5
  Attempting uninstall: requests
    Found existing installation: requests 2.18.4
    Uninstalling requests-2.18.4:
      Successfully uninstalled requests-2.18.4
  Attempting uninstall: oauthlib
    Found existing installation: oauthlib 2.0.6
    Uninstalling oauthlib-2.0.6:
      Successfully uninstalled oauthlib-2.0.6
Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.1.1 google-auth-1.19.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.30.0 keras-preprocessing-1.1.2 markdown-3.2.2 oauthlib-3.1.0 opt-einsum-3.2.1 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.24.0 requests-oauthlib-1.3.0 rsa-4.6 scipy-1.4.1 six-1.15.0 tensorboard-2.1.1 tensorflow-2.1.0+nv20.3.tf2 tensorflow-estimator-2.1.0 termcolor-1.1.0 wrapt-1.12.1

#5.TensorFlowインストール確認します。

$ python3
import tensorflow

TensorFlowインストール確認.
$ python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
2020-07-17 05:29:18.293314: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.0
2020-07-17 05:29:22.202343: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer.so.6
2020-07-17 05:29:22.306360: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer_plugin.so.6

#6.PyMongoのインストールします。

PythonからMongoDBにアクセスするためのライブラリ「PyMongo」をインストールします。

$ sudo pip3 install pymongo
実行

PyMongoインストール.
$ sudo pip3 install pymongo
[sudo] password for dlinano: # パスワードを入力してください。
Collecting pymongo
  Downloading pymongo-3.10.1-cp36-cp36m-manylinux2014_aarch64.whl (459 kB)
     |████████████████████████████████| 459 kB 5.1 MB/s 
Installing collected packages: pymongo
Successfully installed pymongo-3.10.1

#7.kerasのインストールします。

Pythonにて機械学習するためには、ほぼ必須?なPythonの深層学習ライブラリをインストールします。

##7.1.必要システムパッケージをインストール

必要システムパッケージインストール.
$ sudo apt install libatlas-base-dev gfortran
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gfortran is already the newest version (4:7.4.0-1ubuntu2.3).
Suggested packages:
  libatlas-doc liblapack-doc
The following NEW packages will be installed:
  libatlas-base-dev libatlas3-base
0 upgraded, 2 newly installed, 0 to remove and 302 not upgraded.
Need to get 4,740 kB of archives.
After this operation, 33.4 MB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libatlas3-base arm64 3.10.3-5 [2,097 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 libatlas-base-dev arm64 3.10.3-5 [2,643 kB]
Fetched 4,740 kB in 5s (900 kB/s)              
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libatlas3-base:arm64.
(Reading database ... 144722 files and directories currently installed.)
Preparing to unpack .../libatlas3-base_3.10.3-5_arm64.deb ...
Unpacking libatlas3-base:arm64 (3.10.3-5) ...
Selecting previously unselected package libatlas-base-dev:arm64.
Preparing to unpack .../libatlas-base-dev_3.10.3-5_arm64.deb ...
Unpacking libatlas-base-dev:arm64 (3.10.3-5) ...
Setting up libatlas3-base:arm64 (3.10.3-5) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/atlas/libblas.so.3 to provide /usr/lib/aarch64-linux-gnu/libblas.so.3 (libblas.so.3-aarch64-linux-gnu) in auto mode
update-alternatives: using /usr/lib/aarch64-linux-gnu/atlas/liblapack.so.3 to provide /usr/lib/aarch64-linux-gnu/liblapack.so.3 (liblapack.so.3-aarch64-linux-gnu) in auto mode
Setting up libatlas-base-dev:arm64 (3.10.3-5) ...
update-alternatives: using /usr/lib/aarch64-linux-gnu/atlas/libblas.so to provide /usr/lib/aarch64-linux-gnu/libblas.so (libblas.so-aarch64-linux-gnu) in auto mode
update-alternatives: using /usr/lib/aarch64-linux-gnu/atlas/liblapack.so to provide /usr/lib/aarch64-linux-gnu/liblapack.so (liblapack.so-aarch64-linux-gnu) in auto mode
Processing triggers for libc-bin (2.27-3ubuntu1) ...

##7.2.kerasをインストールします。

$ sudo pip3 install keras==2.3.1
実行

$ sudo pip3 install keras==2.3.1
Collecting keras==2.3.1
  Downloading Keras-2.3.1-py2.py3-none-any.whl (377 kB)
     |████████████████████████████████| 377 kB 6.5 MB/s 
Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.6/dist-packages (from keras==2.3.1) (1.0.8)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from keras==2.3.1) (1.15.0)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from keras==2.3.1) (1.1.2)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from keras==2.3.1) (3.12)
Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from keras==2.3.1) (1.4.1)
Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from keras==2.3.1) (1.16.1)
Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras==2.3.1) (2.9.0)
Installing collected packages: keras
  Attempting uninstall: keras
    Found existing installation: Keras 2.4.3
    Uninstalling Keras-2.4.3:
      Successfully uninstalled Keras-2.4.3
Successfully installed keras-2.3.1

#8.sklearnをインストールします。

$ sudo pip3 install sklearn
実行

$ sudo pip3 install sklearn
Collecting sklearn
  Downloading sklearn-0.0.tar.gz (1.1 kB)
Collecting scikit-learn
  Downloading scikit-learn-0.23.1.tar.gz (7.2 MB)
     |████████████████████████████████| 7.2 MB 31 kB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn) (0.16.0)
Requirement already satisfied: scipy>=0.19.1 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn) (1.4.1)
Collecting threadpoolctl>=2.0.0
  Downloading threadpoolctl-2.1.0-py3-none-any.whl (12 kB)
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn) (1.16.1)
Building wheels for collected packages: sklearn, scikit-learn
  Building wheel for sklearn (setup.py) ... done
  Created wheel for sklearn: filename=sklearn-0.0-py2.py3-none-any.whl size=2397 sha256=048efbbb0de80a06122f8675a12034535782dc5e10dc077884d74012d0db48d4
  Stored in directory: /home/dlinano/.cache/pip/wheels/23/9d/42/5ec745cbbb17517000a53cecc49d6a865450d1f5cb16dc8a9c
  Building wheel for scikit-learn (PEP 517) ... -^[[done
  Created wheel for scikit-learn: filename=scikit_learn-0.23.1-cp36-cp36m-linux_aarch64.whl size=17314152 sha256=8d04b101a87ed0f63e45f1a5a2e67f2d225a5ca7cb08159027d3033022bcbf2c
  Stored in directory: /home/dlinano/.cache/pip/wheels/60/b6/1c/27b7551bfaab917703c272d3757f3cee4868028217a266de1b
Successfully built sklearn scikit-learn
Installing collected packages: threadpoolctl, scikit-learn, sklearn
Successfully installed scikit-learn-0.23.1 sklearn-0.0 threadpoolctl-2.1.0

#9.jetson-statsをインストールします。

あると便利なjetsonの状態モニタをインストールします。

$ sudo pip3 install jetson-stats
実行

sudo pip3 install jetson-stats
Collecting jetson-stats
  Downloading jetson-stats-2.1.0.tar.gz (70 kB)
     |████████████████████████████████| 70 kB 1.1 MB/s 
Building wheels for collected packages: jetson-stats
  Building wheel for jetson-stats (setup.py) ... done
  Created wheel for jetson-stats: filename=jetson_stats-2.1.0-py3-none-any.whl size=86460 sha256=52965db6c8b7b48a44777a04211099a39932d655e7d103f9673fa8bc0a57884f
  Stored in directory: /home/dlinano/.cache/pip/wheels/b6/55/b7/fe1d0b5af2e21e44532ed064b90ccf4e2cb0abd40709825282
Successfully built jetson-stats
Installing collected packages: jetson-stats
Successfully installed jetson-stats-2.1.0

以下コマンドで、CPU、GPUなどの情報が表示できます。

sudo jtop
[sudo] password for dlinano:  # いつも通りパスワードを入力して下さい。

#A.その他

私の環境では、
train_test_split(テストデータ分割関数)を使用するために

from sklearn.model_selection import train_test_split

をソースコードの記載し、実行すると

ImportError: /usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block

となってしまうので、

$ export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1

を実行しました。

コマンドラインでは、その端末のみ有効となるため、恒久的に行う場合には、

~/.bashrc
export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1

を追加して下さい。
この対処が正しいかはわかっていませんが、とりあえず実行できるようになりました。

#関連(連載)

初心者が機械学習をやってみたら(その0)
初心者が機械学習をやってみたら(その5)

3
3
0

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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?