Google Coral USB Accelerator を試す その4

TensorFlow Lite Python classification example with Pi Camera を、TPUに差し替えてためそう

$ git clone https://github.com/tensorflow/examples --depth 1
$ cd examples/lite/examples/image_classification/raspberry_pi
$ bash download.sh ~/models

まずは Tensorflow lite で

python3 classify_picamera.py  --model ~/models/mobilenet_v1_1.0_224_quant.tflite  --labels ~/models/labels_mobilenet_quant_v1_224.txt

動きましたが、ハングアップしました。。。

TPUに書き換える

$ cp classify_picamera.py classify_picamera_tpu.py

from tflite_runtime.interpreter import load_delegate interpreter = Interpreter(args.model, experimental_delegates=[load_delegate('libedgetpu.so.1.0')])

$ python3 classify_picamera_tpu.py --model ~/models/mobilenet_v1_1.0_224_quant_edgetpu.tflite --labels ~/models/labels_mobilenet_quant_v1_224.txt
$ python3 classify_picamera_tpu.py --model ~/models/mobilenet_v2_1.0_224_quant_edgetpu.tflite --labels ~/models/imagenet_labels.txt
$ python3 classify_picamera_tpu.py --model ~/models/inception_v4_299_quant_edgetpu.tflite --labels ~/models/imagenet_labels.txt

Detect もためそう

$ cd ~/examples/lite/examples/object_detection/raspberry_pi

$ python3 detect_picamera_tpu.py --model ~/models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite --labels ~/models/coco_labels.txt
$ python3 detect_picamera_tpu.py --model ~/models/mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite --labels ~/models/coco_labels.txt

f:id:pongsuke:20191127140859p:plain

残念!
それはマグカップだ!
ぜひとも Coffee mug と答えて欲しかった。

Google Coral USB Accelerator を試す その3

Posenet をためそう

GitHub - google-coral/project-posenet: Human Pose Detection on EdgeTPU

$ git clone https://github.com/google-coral/project-posenet
$ cd project-posenet
$ sh install_requirements.sh

simple_pose.py

$ python3 simple_pose.py

Inference time: 26ms

Pose Score:  0.61855656
 nose                 x=210  y=152  score=1.0
 left eye             x=224  y=138  score=1.0
 right eye            x=199  y=137  score=1.0
 left ear             x=244  y=135  score=1.0
 right ear            x=182  y=129  score=0.8
 left shoulder        x=268  y=168  score=0.8
 right shoulder       x=160  y=173  score=1.0
 left elbow           x=282  y=255  score=0.6
 right elbow          x=154  y=256  score=0.9
 left wrist           x=236  y=333  score=0.8
 right wrist          x=162  y=299  score=0.6
 left hip             x=324  y=179  score=0.2
 right hip            x=203  y=233  score=0.0
 left knee            x=344  y=86   score=0.8
 right knee           x=170  y=294  score=0.0
 left ankle           x=316  y=175  score=0.1
 right ankle          x=166  y=307  score=0.0

Pose Score:  0.5867945
 nose                 x=398  y=145  score=1.0
 left eye             x=416  y=128  score=1.0
 right eye            x=382  y=127  score=1.0
 left ear             x=457  y=110  score=0.9
 right ear            x=370  y=120  score=0.2
 left shoulder        x=491  y=169  score=0.9
 right shoulder       x=362  y=151  score=0.8
 left elbow           x=465  y=290  score=0.9
 right elbow          x=328  y=246  score=0.8
 left wrist           x=340  y=303  score=0.9
 right wrist          x=233  y=331  score=0.5
 left hip             x=525  y=106  score=0.0
 right hip            x=361  y=161  score=0.3
 left knee            x=501  y=90   score=0.6
 right knee           x=350  y=167  score=0.1
 left ankle           x=504  y=178  score=0.0
 right ankle          x=306  y=176  score=0.1

カメラを使用したデモも、ちゃんと動きました。

Google Coral USB Accelerator を試す その2

f:id:pongsuke:20191127124210j:plain

RPI4でのセットアップメモ

冷却ファンは必須だと思います。

opencv コンパイル

ありがたく従う。

Install OpenCV 4.1.2 for Raspberry Pi 3 or 4 (Raspbian Buster) · GitHub

TensorFlow 2.0 インストール

配布しているので、ありがたく従う。

GitHub - PINTO0309/Tensorflow-bin: Prebuilt binary with Tensorflow Lite enabled (native build). For RaspberryPi / Jetson Nano. And, solved Tensorflow issues #15062,#21574,#21855,#23082,#25120,#25748,#29617,#29704,#30359.

$ uname -m
armv7l

なので、armv7l を使います。

$ sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev
$ sudo pip3 install keras_applications==1.0.8 --no-deps
$ sudo pip3 install keras_preprocessing==1.1.0 --no-deps
$ sudo pip3 install h5py==2.9.0
$ sudo apt-get install -y openmpi-bin libopenmpi-dev
$ sudo apt-get install -y libatlas-base-dev
$ pip3 install -U --user six wheel mock
$ wget https://github.com/PINTO0309/Tensorflow-bin/raw/master/tensorflow-2.0.0-cp37-cp37m-linux_armv7l.whl
$ sudo pip3 uninstall tensorflow
$ sudo -H pip3 install tensorflow-2.0.0-cp37-cp37m-linux_armv7l.whl

# wrapt のエラー対処
$ sudo pip3 install --upgrade --ignore-installed wrapt
$ sudo -H pip3 install tensorflow-2.0.0-cp37-cp37m-linux_armv7l.whl

$ python3 -c "import tensorflow as tf; print(tf.__version__)"
2.0.0

Coral サンプルを動かして遊ぶ

サンプルのインストール

$ echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
$ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install edgetpu-examples

object detect

Object detection example | Coral

$ cd /usr/share/edgetpu/examples/

$ python3 object_detection.py \
--model models/mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite \
--label models/coco_labels.txt \
--input images/grace_hopper.bmp \
--output ${HOME}/object_detection_results.jpg

-----------------------------------------
person
score =  0.87890625
box =  [0.36061957478523254, 16.603958666324615, 513.4191654920578, 596.4085128307343]
-----------------------------------------
tie
score =  0.7890625
box =  [219.4967241883278, 421.0741320848465, 290.2605925798416, 542.6791430711746]
-----------------------------------------
remote
score =  0.12109375
box =  [88.86422845721245, 484.78841257095337, 170.81563928723335, 519.9595828056335]
-----------------------------------------
tie
score =  0.12109375
box =  [204.06080427765846, 398.90483021736145, 309.7189499735832, 469.27534461021423]
-----------------------------------------
tie
score =  0.12109375
box =  [222.6611628830433, 411.52891516685486, 294.7753555178642, 459.50881791114807]
-----------------------------------------
tie
score =  0.12109375
box =  [235.06781673431396, 442.72691202163696, 285.1113055944443, 532.0171551704407]
-----------------------------------------
person
score =  0.12109375
box =  [12.144120335578918, 35.299975633621216, 143.63851302862167, 424.1663646697998]
-----------------------------------------
person
score =  0.08984375
box =  [16.875516951084137, 184.32269310951233, 187.88965493440628, 447.9674062728882]
-----------------------------------------
tie
score =  0.08984375
box =  [195.26302713155746, 344.7151780128479, 329.2432219386101, 449.8947193622589]
-----------------------------------------
person
score =  0.08984375
box =  [3.0382719188928604, 22.73980575799942, 170.4458058476448, 538.9089303016663]
Please check  /home/kiyo/object_detection_results.jpg

f:id:pongsuke:20191127124926j:plain

face detect

$ python3 object_detection.py \
--model models/mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite \
--input images/grace_hopper.bmp \
--output ${HOME}/face_detection_results.jpg

-----------------------------------------
score =  0.99609375
box =  [143.88912090659142, 40.834905445575714, 381.8060402870178, 365.49142384529114]
Please check  /home/kiyo/face_detection_results.jpg

f:id:pongsuke:20191127125006j:plain

Google Coral USB Accelerator を試す その1

Google Coral USB Accelerator を試すことにする。

f:id:pongsuke:20190904163750j:plain

f:id:pongsuke:20190904163726j:plain

f:id:pongsuke:20190904163745j:plain

製品情報

coral.withgoogle.com

Features
Google Edge TPU ML accelerator coprocessor
USB 3.0 Type-C socket
Supports Debian Linux on host CPU
Requirementslink
Any Linux computer with a USB port
Debian 6.0 or higher, or any derivative thereof (such as Ubuntu 10.0+)
System architecture of either x86-64 or ARM32/64 with ARMv8 instruction set
And yes, this means Raspberry Pi is supported. However, we officially support only Raspberry Pi 2/3 Model B/B+ running Raspbian. Unofficially, support for Raspberry Pi Zero is also available (install the TAR from GitHub on your Pi Zero, instead of the one below).

Also note that you should connect to a USB 3.0 port for the fastest inferencing speed; if you connect to a USB 2.0 port, inferencing is much slower.

USB 3.0?

Also note that you should connect to a USB 3.0 port for the fastest inferencing speed; if you connect to a USB 2.0 port, inferencing is much slower.

USB3.0じゃないと、おそくなるよー、、、と言うことだ。

購入

Google Coral Edge TPU USB Accelerator G950-01456-01の通販ならマルツオンライン

TPUってなに?

テンサー・プロセッシング・ユニット(Tensor processing unit、TPU)はGoogleが開発した機械学習に特化した特定用途向け集積回路(ASIC) テンソル・プロセッシング・ユニット - Wikipedia

Coral USB Accelerator は何がすごい?

省電力で、非力なマシンでのAI推論を実現する。

セットアップ

注意事項その1 周波数と温度

Caution: During installation, you'll be asked, "Would you like to enable the maximum operating frequency?" Enabling this option improves the the inferencing speed but it also causes the USB Accelerator to become very hot to the touch during operation and might cause burn injuries. If you're not sure you need the increased performance, type N and press Enter to use the default operating frequency. (You can change this later by simply re-running the install script.)

最大の周波数にする? みたいなオプションが出るが、 Yes にすると、かなり熱くなるということだ。

注意事項その2 Pythonのバージョン

セットアップスクリプトでは、 Python3.5 が指定されているらしい。

別に3.5 upper ならいいらしいので、3.6を使用する場合などは、 python3 と書き換えて構わないらしい。

けども! 3.7 は正式にサポート出来ていないから、3.7を使用する場合には、以下のコマンドを実行せよ! とのことだ。

RPI3B+ でエラー

$ sudo rpi-update

$ python3 --version
Python 3.7.3

$ sudo edgetpu_api/install.sh
 ...
Would you like to enable the maximum operating frequency? Y/N
Y

 ...

Done.
Installing device rule file [/etc/udev/rules.d/99-edgetpu-accelerator.rules]...
Done.
Installing Edge TPU runtime library [/usr/lib/aarch64-linux-gnu/libedgetpu.so.1.0]...
cp: 通常ファイル '/usr/lib/aarch64-linux-gnu/libedgetpu.so.1.0' を作成できません: そのようなファイルやディレクトリは
ありません

あれまぁ・・・。

$ uname -m
aarch64

$ getconf LONG_BIT
32

どうやら、aarch64として設定しようとしてくれているけど、普通に Raspbian buster をインストールした場合、32bit で動いているら、そして、クロスコンパイラ?(よくわかっていません)も、はいっていないから、インストールの切り分けを修正する必要が有った。

なお、rpi-update しない状態では、

 $ uname -m
armv7l

ということで、普通に入りました。

Python 3.7 対応

cd /usr/local/lib/python3.7/dist-packages/edgetpu/swig/
        
sudo cp _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so _edgetpu_cpp_wrapper.cpython-37m-arm-linux-gnueabihf.so

PRI4

$ uname -m
armv7l

GitHub - leswright1977/RPi4-Google-Coral: Google Coral on the Raspberry Pi 4

こちらを使用させていただく。

$ sudo edgetpu_api/install.sh
 ...
Done.
Installing device rule file [/etc/udev/rules.d/99-edgetpu-accelerator.rules]...
Done.
Installing Edge TPU runtime library [/usr/lib/arm-linux-gnueabihf/libedgetpu.so.1.0]...
Done.
Installing Edge TPU Python API...
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./edgetpu_api/edgetpu-2.11.1-py3-none-any.whl
Installing collected packages: edgetpu
Successfully installed edgetpu-2.11.1
Done.
Lib Fu.

接続

指す!

$ lsusb
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 1a6e:089a Global Unichip Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

サンプルスクリプトの実行

$ cd /usr/local/lib/python3.7/dist-packages/edgetpu/demo/
$ python3 classify_image.py --model ~/Downloads/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --label ~/Downloads/inat_bird_labels.txt --image ~/Downloads/parrot.jpg
INFO: Initialized TensorFlow Lite runtime.
---------------------------
Ara macao (Scarlet Macaw)
Score :  0.76171875

Edge TPU 向けの Modelたち

coral.withgoogle.com

SPI を使用する - JETSON NANO 開発者キット その5

SPI を使用したい!

ところが、デフォルトではOFFになっている。
そして、ONにするのが、想像以上に面倒であった・・・。

Jetson NanoのSPIを有効にする – RT Robot Shop Blog

メモ

$ lsusb 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 0955:7f21 NVidia Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

$ git clone https://github.com/rt-net/JetsonNano_DT_SPI.git
$ cd JetsonNano_DT_SPI/ 

$ ./run.sh

 yes/no ?

*** The [DTB] has been updated successfully. ***

リカバリーモードを解除(ジャンパーピンを抜く)して、起動

$ sudo cat /sys/kernel/debug/tegra_gpio
Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
 A: 0:0 64 40 40 04 00 00 000000
 B: 0:1 f0 00 00 00 00 00 000000
 C: 0:2 00 00 00 00 00 00 000000
 D: 0:3 00 00 00 00 00 00 000000
 E: 1:0 40 00 00 00 00 00 000000
 F: 1:1 00 00 00 00 00 00 000000
 G: 1:2 0c 00 00 04 00 00 000000
 H: 1:3 fd 99 00 60 00 00 000000
 I: 2:0 07 05 00 02 00 00 000000
 J: 2:1 f0 00 00 00 00 00 000000
 K: 2:2 00 00 00 00 00 00 000000
 L: 2:3 00 00 00 00 00 00 000000
 M: 3:0 00 00 00 00 00 00 000000
 N: 3:1 00 00 00 00 00 00 000000
 O: 3:2 00 00 00 00 00 00 000000
 P: 3:3 00 00 00 00 00 00 000000
 Q: 4:0 00 00 00 00 00 00 000000
 R: 4:1 00 00 00 00 00 00 000000
 S: 4:2 a0 80 00 00 00 00 000000
 T: 4:3 01 01 00 00 00 00 000000
 U: 5:0 00 00 00 00 00 00 000000
 V: 5:1 03 00 00 02 00 00 000000
 W: 5:2 00 00 00 00 00 00 000000
 X: 5:3 78 08 08 70 00 60 606000
 Y: 6:0 06 00 00 02 00 00 000000
 Z: 6:1 0f 08 08 00 00 02 020600
AA: 6:2 00 00 00 00 00 00 000000
BB: 6:3 01 00 00 00 00 00 000000
CC: 7:0 12 00 00 10 00 12 121200
DD: 7:1 01 00 00 00 00 00 000000
EE: 7:2 00 00 00 00 00 00 000000
FF: 7:3 00 00 00 00 00 00 000000

spidev_test

Jetson/TX2 SPI - eLinux.org

動作テストには、19pin と 21pin を直結して、 spidev_test しれってかいてある。

ソースコードが見当たらなかったので、拾ってきてコンパイルした。

$ sudo CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- make

spidev_fdx.c と spidev_test.c

$ sudo ./spidev_test
 -D /dev/spidev0.0 
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
RX | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  | ................................

$ sudo ./spidev_test -D /dev/spidev0.0 
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  | ......@.......................

Jetso nano セットアップ 2019-05-31 ver

2代目をセットアップする機会があったのでメモ

f:id:pongsuke:20190716162434p:plain
jetson nano

img は 2019-05-31 ver

Getting Started With Jetson Nano Developer Kit | NVIDIA Developer

Miscro SDカードを SD card formatter でクイックフォーマット

Etcher で、IMGを焼き付ける

物理的に差し込んで、電源を入れる

許諾にOKを出し、言語設定等を済ませる

Applying changes で、停止する・・・?

https://devtalk.nvidia.com/default/topic/1049751/jetson-nano/hangs-at-first-boot-at-quot-waiting-for-unattended-upgr-to-exit-quot-/

フォーラムにありますが、45分待てば良いとのこと。

キャンセルしても問題ないでしょうが、今回は待ってみました。
確かに、45分ほど経過し、再起動しました。

初期設定

IP固定

起動時GUIになっているので、GUIで設定しました。

右上のバーからnetwrok設定を選択肢、ipv4 setting をいじる。
再起動

swapメモリ作成
$ git clone https://github.com/JetsonHacksNano/installSwapfile
$ cd installSwapfile/
$ ./installSwapfile

$ free
              total        used        free      shared  buff/cache   available
Mem:        4058432      640544     3000412       19096      417476     3248224
Swap:       6291452           0     6291452

Vino

Getting Started with the NVIDIA Jetson Nano Developer Kit

上記の通りに一通りやった結果として、先にログインして有れば起動する状態になりました。

Versionなど

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

$ python --version
Python 2.7.15+

$ python3 --version
Python 3.6.8

$ python -c "import cv2; print (cv2.__version__)"
3.3.1

$ python3 -c "import cv2; print (cv2.__version__)"
3.3.1

ファンを付ける

$ sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'

起動時に有効にしたいので、/etc/rc.local にも入れておく。

CUDA サンプル

$ cp -a /usr/local/cuda-10.0/samples/ ~/
$ cd samples
$ make -j 4

$ cd ./1_Utilities/deviceQuery
$ ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA Tegra X1"
  CUDA Driver Version / Runtime Version          10.0 / 10.0
  CUDA Capability Major/Minor version number:    5.3
  Total amount of global memory:                 3963 MBytes (4155834368 bytes)
  ( 1) Multiprocessors, (128) CUDA Cores/MP:     128 CUDA Cores
  GPU Max Clock rate:                            922 MHz (0.92 GHz)
  Memory Clock rate:                             13 Mhz
  Memory Bus Width:                              64-bit
  L2 Cache Size:                                 262144 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 32768
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            Yes
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            No
  Supports Cooperative Kernel Launch:            No
  Supports MultiDevice Co-op Kernel Launch:      No
  Device PCI Domain ID / Bus ID / location ID:   0 / 0 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.0, CUDA Runtime Version = 10.0, NumDevs = 1
Result = PASS

vnc4server

フレームバッファリングがおかしいのか、チカチカしたり、更新が遅れたりするのと、コンソールでログインが必須なので、vnc4server に切り替える。

また、ログインに成功しても、デスクトップが出ないので、gnome-panel などを入れて、xstartup を修正する。

こちらから学びました

2019年04月19日 : limepikoのblog

$ sudo apt-get intall vnc4server
$ sudo apt install gnome-panel gnome-settings-daemon metacity

$ cat ~/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &

export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
exec gnome-session &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

Tensorflow

TensorFlow For Jetson Platform :: Deep Learning Frameworks Documentation

$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.13.1

GPIOについて - JETSON NANO 開発者キット その5

f:id:pongsuke:20190806165343j:plain

GPIOについて

Jetson Nano GPIO - JetsonHacks

Raspberry Pi の 40pin と互換性があるとこのと。

特に、最初から img に含まれている

GitHub - NVIDIA/jetson-gpio: A Python library that enables the use of Jetson's GPIOs

は、RPi.GPIO と強い互換性があるらしい。

電圧は 3.3V

Pin layout

NVIDIA Jetson Nano J41 Header Pinout - JetsonHacks

jetson-gpio

ガイドを見ると、user を GPIO グループに参加させるなど、RPIに似ている。

RPIでは、デフォルトの pi user が、最初から GPIOに入っていて、誰でもすぐに試せるが、Jetson nano では、グループ作成からやるっぽい。

jetson-gpio

$ ls /opt/nvidia/jetson-gpio/
doc  etc  lib  samples

$ sudo pip3 install Jetson.GPIO

$ sudo groupadd -f -r gpio
$ sudo usermod -a -G gpio your_user_name

$ sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
$ sudo udevadm control --reload-rules && sudo udevadm trigger

動作テスト

import RPi.GPIO as GPIO
import time

output_pin  = 21

def main():
    # Pin Setup:
    # Board pin-numbering scheme
    GPIO.setmode(GPIO.BCM)
    # set pin as an output pin with optional initial state of HIGH
    GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.HIGH)

    print("Starting demo now! Press CTRL+C to exit")
    curr_value = GPIO.HIGH
    try:
        while True:
            time.sleep(1)
            # Toggle the output every second
            print("Outputting {} to pin {}".format(curr_value, output_pin))
            GPIO.output(output_pin, curr_value)
            curr_value ^= GPIO.HIGH
    finally:
        GPIO.cleanup()

if __name__ == '__main__':
    main()

チカチカしました。