🚅

Jetson Nano 高速化

2022/09/25に公開

本記事は、Jetson Nano と互換性のあるJETSON-NANO-DEV-KIT-Bにて確認していますが、Jetson Nanoとは異なる点があるかもしれません。ご了承ください。

jtopを使うためにjetson-statsを入れる

sudo -H pip3 install jetson-stats
sudo reboot
jtop

ファンが回転するようにする

最大

$ echo 255 | sudo tee /sys/devices/pwm-fan/target_pwm
255

停止

$ echo 0 | sudo tee /sys/devices/pwm-fan/target_pwm
0

中間

$ echo 128 | sudo tee /sys/devices/pwm-fan/target_pwm
128

確認

$ cat /sys/devices/pwm-fan/target_pwm
128

使用CPU数とクロック周波数を最大に

電力モード/クロック変更

sudo nvpmodel -m 0
sudo jetson_clocks
sudo nvpmodel -q
NVPM WARN: fan mode is not set!
NV Power Mode: MAXN
0
sudo jetson_clocks --show
$ sudo jetson_clocks --show
SOC family:tegra210  Machine:NVIDIA Jetson Nano Developer Kit
Online CPUs: 0-3
cpu0: Online=1 Governor=schedutil MinFreq=1200000 MaxFreq=1479000 CurrentFreq=1428000 IdleStates: WFI=1 c7=1 
cpu1: Online=1 Governor=schedutil MinFreq=1200000 MaxFreq=1479000 CurrentFreq=1224000 IdleStates: WFI=1 c7=1 
cpu2: Online=1 Governor=schedutil MinFreq=1200000 MaxFreq=1479000 CurrentFreq=1224000 IdleStates: WFI=1 c7=1 
cpu3: Online=1 Governor=schedutil MinFreq=1200000 MaxFreq=1479000 CurrentFreq=1224000 IdleStates: WFI=1 c7=1 
GPU MinFreq=76800000 MaxFreq=921600000 CurrentFreq=76800000
EMC MinFreq=204000000 MaxFreq=1600000000 CurrentFreq=1600000000 FreqOverride=0
Fan: PWM=128
NV Power Mode: MAXN

SWAP領域を拡大

現状確認

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.9G        477M        2.8G         19M        571M        3.2G
Swap:          1.9G          0B        1.9G

設定済の場合は一旦無効化

$ sudo swapoff -a

取得実行

$ git clone https://github.com/JetsonHacksNano/installSwapfile
Cloning into 'installSwapfile'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 37 (delta 0), reused 0 (delta 0), pack-reused 34
Unpacking objects: 100% (37/37), done.
$ cd installSwapfile
/installSwapfile$ ./installSwapfile.sh
Creating Swapfile at:  /mnt
Swapfile Size:  6G
Automount:  Y
[sudo] password for XXXXX: 
-rw-r--r-- 1 root root 6.0G  9月 17 10:32 swapfile
-rw------- 1 root root 6.0G  9月 17 10:32 swapfile
Setting up swapspace version 1, size = 6 GiB (6442446848 bytes)
no label, UUID=
Filename        Type    Size  Used  Priority
/dev/zram0                              partition 507404  0 5
/dev/zram1                              partition 507404  0 5
/dev/zram2                              partition 507404  0 5
/dev/zram3                              partition 507404  0 5
/mnt/swapfile                           file      6291452 0 -1
Modifying /etc/fstab to enable on boot
/mnt/swapfile
Swap file has been created
Reboot to make sure changes are in effect

再確認

/installSwapfile$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.9G        482M        2.8G         19M        581M        3.2G
Swap:          7.9G          0B        7.9G
/installSwapfile$ 

お好みでサイズを変える

# Ubuntu recommends 6GB for 4GB of memory when using suspend
# You can use 1 or 2 if need be
SWAPSIZE=6

起動時に設定させる

起動時設定を/etc/rc.localへ設定

#!/bin/bash
sleep 10
sudo /usr/bin/jetson_clocks
sudo sh -c 'echo 192 > /sys/devices/pwm-fan/target_pwm'

実行可能にする

sudo chmod +x /etc/rc.local

必要に応じて

sudo systemctl restart rc-local.service

Discussion