前沿. 如果不使用SD卡来烧录可以考虑下面这个方法
https://huaweicloud.csdn.net/635667b1d3efff3090b5db5b.html
[Nvidia Jetson ]设备-Nvidia Jetson Nano刷机安装EMMC镜像(不使用sdkmanager工具)
0. 常用指令
命令 | 描述 |
---|---|
lspcu | 查看cpu |
free -m | 查看内存 |
df -h | 查看空间 |
lsusb | 查看usb设备 |
ls /dev/vid* | 查看摄像头 |
uname -a | 查看内核信息 |
lsb_release -a | 查看系统信息 |
1.下载镜像
- Jetson Download Center(需翻墙) :
https://developer.nvidia.com/embedded/downloads
##官方下载地址 可选择NX和nano
## https://developer.nvidia.com/zh-cn/embedded/downloads#?search=Jetson%20Xavier%20NX%20Developer%20Kit%20User%20Guide
如果想要下载Jetson xaiver NX的镜像可以参考这个网址:https://developer.nvidia.com/zh-cn/embedded/jetpack
- 点击DOWNLOADS那个链接即可开始下载。目前4.5.1是jetpack最新版本,如果需要其它版本下面也有,按需下载即可。由于我不是NX系列的,所以选择的是左边中间那个下载。如果一直下不下来你可以选择复制下载链接去迅雷下载(速度很慢但是可以行得通)。
- 下载好了之后就可以开始烧录镜像(这里需要准备一个SD卡(这个卡应该先格式化哟),用于烧录),格式化的软件为SD Card Formatter: https://www.sdcard.org/downloads/formatter/
2. 烧录镜像
- 下载,安装并启动Etcher。
- 我选择的是第一个.下载好了之后就可以打开,打开之后的界面如下.
单击“选择图像”,然后选择较早下载的压缩镜像文件(如果找不到就改一下后缀即可)。
插入您的microSD卡。如果没有连接其他外部驱动器,则Etcher将自动选择microSD卡作为目标设备。否则,请单击“更改”并选择正确的设备。
然后点击Flash开始烧录镜像!Wait 20mintus approximately
- 烧录完成之后直接插入到嵌入式平台上的SD卡位置,然后连接所有的线然后开机。
3. 开机
开机过程中需要进行相关选择,这里和Ubuntu选择是一样的,默认即可。
4. 开机设置
4.1 散热风扇控制
一开始风扇是不会自己转的,需要自己设置,255是最大转速,可以根据需要自己调整
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
创建/etc/rc.local(18.04没有rc.local),并添加如下内容:
#!/bin/bash
sleep 10
sudo /usr/bin/jetson_clocks
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
添加rc.local可执行权限
sudo chmod 755 /etc/rc.local
重启即可
sudo reboot
4.2 Chinese语言包
先找到system setting 点击language support 点击install/remove languages 选中 Chinese(simplified)安装,安装好了之后就可以执行下面操作
安装ibus框架,在Terminal中输入:
sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4
- 切换到ibus框架下:
im-config -s ibus
- 安装拼音引擎:
sudo apt-get install ibus-pinyin
- 调出ibus Preference来添加该拼音输入法:
sudo ibus-setup
Finally!在弹出的对话框中添加Chinese-Pinyin输入法就OK啦~
- 系统输入法设置:在System Settings–>Text Entry中添加上Chinses(Pinyin)IBus拼音输入法,并将Show current input source in the menu bar勾选上,这样就会在系统的菜单条上显示输入法切换的图标了。如果没找到重启一下就有了/
4.3 将中文目录改为英文目录
#打开终端,在终端中输入命令:
export LANG=en_US
xdg-user-dirs-gtk-update
#在弹出的窗口中询问是否将目录转化为英文路径,同意并关闭.
#转回中文在终端中输入命令:
export LANG=zh_CN
4.4 pip安装与切换软件源
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
由于ubuntu默认的软件源是国外的源,下载速度非常慢,而且经常链接中断,非常不稳定。so,we have to change the source of software to install environment.please follow me.
- First,we will cope the original file:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
- Then,open the file
sudo gedit /etc/apt/sources.list
- Addition the source of software.
#Ubuntu 官方源
deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ gutsy-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
#阿里云
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
#网易163
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
#中科大
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security multiverse
deb http://archive.ubuntu.org.cn/ubuntu-cn/ feisty main restricted universe multiverse
- Update the file
sudo apt-get update
sudo apt-get dist-upgrade # 涉及核心的升级,通常会对系统功能产生实际的影响,可能在需要的情况下卸载一些已经安装的软件也可能安装一些额外的软件,通常应该谨慎操作,特别是有未完成的工作,但是在允许的情况下应该尽力升级,应为可能涉及一些重大的核心升级,比如安全。
sudo apt-get upgrade # 不会对系统产生重大的影响,可以在任何时候运行。
4.5 安装pip3
sudo apt-get install libhdf5-serial-dev hdf5-tools zlib1g-dev zip libjpeg8-dev libhdf5-dev python3-pip
- install other fundamental environment
pip3 install -U numpy
pip3 install -U h5py
pip3 install -U grpcio absl-py py-cpuinfo psutil portpicker grpcio six mock requests gast astor termcolor
4.6 安装CUDA
jetson nano默认已经安装了CUDA10.2,但是直接运行 nvcc -V是不会成功的,需要你把CUDA的路径写入环境变量中。
sudo gedit ~/.bashrc
在最后添加
export CUBA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-10.2/bin:$PATH
然后保存退出
source ~/.bashrc
4.7 安装opencv
通过终端opencv_version
可查看jetson nano自带的4.1.1的版本
因此我们也不需要重新进行编译,直接使用就好了
通过python3/import cv2可查看
4.8 安装torch2trt
git clone git://github.com/NVIDIA-AI-IOT/torch2trt
cd torch2trt
sudo -s
python setup.py install
运行成功
5. 显示CSI摄像头
1.如何是开机插上的摄像头就应该先关机重启之后才会显示
2.开机,输入ls /dev/video* 看看是不是有摄像头设备
3.输入nvgstcapture 一般来说就可以将摄像头直接打开,如果需要关闭直接关闭终端就好了
4.要是不显示就更新一下,sudo apt-get update sudo apt-get upgrade
如果要看如何调用摄像头就看下面这个文章
https://blog.csdn.net/m0_51004308/article/details/116541877
6. 增加Swap交换空间
由于Jetson nano的内存只有4GB,且与显存共用,后期编译torchvision,生成TensorRT推理引擎文件不够用,这里提前增加swap内存。
方式1
sudo fallocate -l 4G /var/swapfile
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
sudo bash -c 'echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab'
方式2
sudo gedit /etc/systemd/nvzramconfig.sh
通过vim打开nvzramconfig.sh,按"i"进入"insert"模式,修改mem= ( ( ( " (((" ((("{totalmem}" / 2 / “ N R D E V I C E S " ) ∗ 1024 ) ) 为 m e m = {NRDEVICES}") * 1024))为mem= NRDEVICES")∗1024))为mem\=(((” t o t a l m e m " ∗ 2 / " {totalmem}" * 2 / " totalmem"∗2/"{NRDEVICES}“) * 1024)),按"ESC"退出"insert"模式,输入”:wq"保存并退出,输入"reboot"重启开发板。