接上篇写入系统后
调整Nano设置
功率设置
设置为最大功率
sprite@sprite-nano:~$ sudo nvpmodel -m1
sprite@sprite-nano:~$ sudo nvpmodel -q
NVPM WARN: fan mode is not set!
NV Power Mode: 5W
1
sprite@sprite-nano:~$ sudo nvpmodel -m0
sprite@sprite-nano:~$ sudo nvpmodel -q
NVPM WARN: fan mode is not set!
NV Power Mode: MAXN
0
# 查看功率模型
sudo nvpmodel -q
# 设置为最大功率状态
sudo nvpmodel -m0
# 设置为5W状态
sudo nvpmodel -m1
高频
查看状态
sudo jetson_clocks --show
执行运行高频模式
sudo jetson_clocks
sudo jetson_clocks --show
sprite@sprite-nano:~$ sudo jetson_clocks --show
SOC family:tegra210 Machine:NVIDIA Jetson Nano Developer Kit
Online CPUs: 0-3
cpu0: Online=1 Governor=schedutil MinFreq=1479000 MaxFreq=1479000 CurrentFreq=1479000 IdleStates: WFI=0 c7=0
cpu1: Online=1 Governor=schedutil MinFreq=1479000 MaxFreq=1479000 CurrentFreq=1479000 IdleStates: WFI=0 c7=0
cpu2: Online=1 Governor=schedutil MinFreq=1479000 MaxFreq=1479000 CurrentFreq=1479000 IdleStates: WFI=0 c7=0
cpu3: Online=1 Governor=schedutil MinFreq=1479000 MaxFreq=1479000 CurrentFreq=1479000 IdleStates: WFI=0 c7=0
GPU MinFreq=921600000 MaxFreq=921600000 CurrentFreq=921600000
EMC MinFreq=204000000 MaxFreq=1600000000 CurrentFreq=1600000000 FreqOverride=1
Fan: PWM=0
NV Power Mode: MAXN
设置交换空间
clone后执行,赋予该文件权限
chomd 777 installSwapfile.sh
./installSwapfile.sh
执行结果:设置交换空间 6G(defalut)
Creating Swapfile at: /mnt
Swapfile Size: 6G
Automount: Y
-rw-r--r-- 1 root root 6.0G 2月 10 10:48 swapfile
-rw------- 1 root root 6.0G 2月 10 10:48 swapfile
Setting up swapspace version 1, size = 6 GiB (6442446848 bytes)
no label, UUID=5c3a1c0f-0f54-46a1-b52a-5a255eccf080
Filename Type Size Used Priority
/dev/zram0 partition 506384 6832 5
/dev/zram1 partition 506384 6828 5
/dev/zram2 partition 506384 6820 5
/dev/zram3 partition 506384 6820 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
换源
有大佬提示,Nano和一般到Ubuntu架构不同,换源可能导致未知问题,此处暂时未换源
- 若需要,也可尝试以下清华源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份原文件sources.list
sudo gedit /etc/apt/sources.list
- 将以下替换原有内容
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
- 更新源
sudo apt-get update
- 更新源
sudo su
apt-get update
apt-get full-upgrade
Nano中带有 CUDA和Cudnn
CUDA
sudo vim ~/.bashrc
添加以下内容
export CUDA_HOME=/usr/local/cuda-10.0
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-10.0/bin:$PATH
更新配置
source ~/.bashrc
查看版本
nvcc -V
安装所需包
- torch
若去官网下载,需要了解当前Nano到jetpack版本
sudo pip3 install jetson-stats
sudo jtop
按5-INFO 可查看Jetpack版本
若使用 pip3 install torch安装指定版本失败,则需要去官网下载,进行本地安装。并根据Jetpack版本,下载合适的版本
- torchvision
pip install 可能会失败,按以下方式安装,选择和torch对应到版本
$ git clone --branch v0.4.0 https://github.com/pytorch/vision.git
$ cd torchvision
$ sudo python3 setup.py install
- 其他包
sudo apt-get install python3-pip libopenblas-base
pip3 install Cython
pip3 install numpy
- 测试环境
python
import torch
若报错
ImportError: libmpi_cxx.so.20: cannot open shared object file: No such file or directory
表示缺少依赖包
# 安装依赖
sudo apt-get install libopenmpi2
再次测试
import torch
torch.__version__
'1.2.0'
- PIL
直接pip install 会报错,原因所缺少PIL依赖包
先执行以下安装依赖
sudo apt install libjpeg-dev zlib1g-dev
再安装pillow
python3 -m pip install -i https://mirrors.aliyun.com/pypi/simple pillow
安装其他类似包按以上语句更快
再次安装仍然出错,pip install 指定版本,安装的确任然所最新的版本8.1.0,后来又经过试验,使用临时清华、豆瓣等源均失败,后来考虑到可能所Jetson Nano到ubuntu架构不一样,不能随意换源,后来换回原来到源,再次安装成功。
- torchvision
这个安装到过程也是特别焦灼,由于Nano 上 ubuntu的特殊性,需要通过git clone方式来安装 Git地址
此处安装的torch 1.2.0 ;torchvision对应版本为0.4.0
# 根据自身到版本进行 调整
git clone --branch v0.4.0 https://github.com/pytorch/vision.git
$ cd torchvision
$ sudo python3 setup.py install
在运行时,报错如下
warning: #warning "Including torch/torch.h for C++ extensions is deprecated. Please include torch/extension.h" [-Wcpp]
经过多次搜索,隔壁有说所pillow版本过高或过低,后来调整来pillow的版本为6.2.2后,又进行来多次安装最终维克塔瑞。
附加
安装PyQt、以及crcmod、opencv-python等包
由于nano环境的特殊性,使用pip install或apt-get安装时,会出现错误,如crcmod库就需要用到一下方法
临时换源
sudo pip3 install crcmod==1.7 -i https://pypi.tuna.tsinghua.edu.cn/simple
但并不是所有包都可以这样,有些包这样安装后,会出现无法使用的问题。
nano显示器
查看当前显示器到分辨率
xrandr
# 结果
Screen 0: minimum 8 x 8, current 1440 x 900, maximum 16384 x 16384
HDMI-0 connected primary 1440x900+0+0 (normal left inverted right x axis y axis) 410mm x 260mm
1440x900 59.90*+ 74.99 59.89
1280x1024 75.03 72.05 70.04 60.00
1024x768 75.03 70.07 60.01
800x600 75.00 72.19 60.32 56.25
720x400 70.04
640x480 75.00 72.81 67.06 59.94
DP-0 disconnected (normal left inverted right x axis y axis)
其中带有*号的为本机到显示器分辨率,以及显示频率
由于使用非HDMI接口(HDMI-DVI)(亲测HDMI-VGA不可用)到显示器,其显示分辨率nano不会自适应,需要通过终端设置
# xrandr -s 分辨率大小_刷新率
xrandr -s 1440*900_60.0
# 若执行提示以下,可暂时忽LUE,将DVI接口插到显示器即可
Size index 1440 is too large, there are only 11 sizes