【Jeston Nano】Environment Configuration - Deploy yolov5

In the previous blog post, the burning of Jeston Nano has been completed, and the power-on configuration operation will continue below.
The JestonNano board needs to be connected to the Internet by directly connecting the network cable on the board, and other methods can be queried by itself.
The content and operation of this article all come from: Jeston Nano Deployment
Add Link Description
Thanks for open source!

1. Jeston Nano system initialization settings

1. Chinese language pack

First find the system setting, click language support, click install/remove languages, select Chinese (simplified) to install, after installation, you can perform the following operations to
install the ibus framework, and enter in the terminal:

sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4

Switch to the ibus framework:

im-config -s ibus

Install the pinyin engine:

sudo apt-get install ibus-pinyin

Bring up ibus Preference to add the pinyin input method:

sudo ibus-setup

System input method setting: Add the Chinses (Pinyin) IBus pinyin input method in System Settings–>Text Entry, and check Show current input source in the menu bar, so that the input method will be displayed on the system menu bar Toggle the icon again. If you can't find it, restart it and there will be /

2. Backup

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list

Delete everything inside and replace with the following

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

3. Replace the source

The image burned by Jetson Nano is from a foreign source. The speed of installing software and upgrading software packages is very slow, and even network errors often occur. The steps to replace the source are as follows: ①Back up the
original source.list file first.

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak  

②Edit source.list, and replace the domestic source

sudo gedit /etc/apt/sources.list

③ Press 'i' to enter the editing state, delete all content, copy and replace the domestic source. (Choose one of Tsinghua University or University of Science and Technology of China here, and save it)

# 清华源
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

# 中科大源
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

④ Update software

# 更新软件
sudo apt-get update
sudo apt-get upgrade

2. Environment configuration, installation package

1.CUDA

Jetson nano has built-in CUDA, but you need to configure environment variables to use it. Just open the command line and add environment variables. Here I am CUDA10.2. If you don’t use my image, you need to fill in the path according to your CUDA version.

#打开终端,输入命令
vi .bashrc

After entering the content of the document, pull it to the bottom and add the following content at the end

export PATH=/usr/local/cuda-10.2/bin${
    
    PATH:+:${
    
    PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_ROOT=/usr/local/cuda

Apply the current configuration to refresh

source ~/.bashrc

Check whether the configuration is successful

nvcc -V

2.pip3

sudo apt-get update
sudo apt-get install python3-pip python3-dev -y

3.jtop

Install the jtop library, which can monitor the working status of your own device CPU and GPU

sudo -H pip3 install jetson-stats
sudo jtop		#运行jtop(第一次可能不行,第二次就好了)  按【q】退出

4. Configure the libraries that may be required

sudo apt-get install build-essential make cmake cmake-curses-gui -y
sudo apt-get install git g++ pkg-config curl -y
sudo apt-get install libatlas-base-dev gfortran libcanberra-gtk-module libcanberra-gtk3-module -y
sudo apt-get install libhdf5-serial-dev hdf5-tools -y
sudo apt-get install nano locate screen -y

5. Install the required dependent environment

sudo apt-get install libfreetype6-dev -y
sudo apt-get install protobuf-compiler libprotobuf-dev openssl -y
sudo apt-get install libssl-dev libcurl4-openssl-dev -y
sudo apt-get install cython3 -y

6. Install the system-level dependencies of opencv, some encoding libraries

sudo apt-get install build-essential -y
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff5-dev libdc1394-22-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev -y
sudo apt-get install libxvidcore-dev libx264-dev -y
sudo apt-get install libatlas-base-dev gfortran -y
sudo apt-get install ffmpeg -y

7. Update CMake

This step is necessary, because many things of the ARM architecture must be compiled from source code

wget http://www.cmake.org/files/v3.13/cmake-3.13.0.tar.gz
tar xpvf cmake-3.13.0.tar.gz cmake-3.13.0/  #解压
cd cmake-3.13.0/
./bootstrap --system-curl	# 漫长的等待,做一套眼保健操...
make -j4 #编译  同样是漫长的等待...
echo 'export PATH=~/cmake-3.13.0/bin/:$PATH' >> ~/.bashrc
source ~/.bashrc #更新.bashrc

8. U disk compatible

The next steps may need to use a USB flash drive to copy large files to the development board, but for large-capacity devices, it may fail to mount, and an installation command can solve it.

sudo apt-get install exfat-utils

3. Install pytorch

The Linux on Jetson nano is actually not an x86 architecture, but an ARM architecture similar to a mobile phone , which leads to many packages on it not being common to those on ordinary Linux. It is also one of the pits that have been stepped on. The package downloaded from the pytorch official website cannot call the graphics card of the development board in actual use (this is a big problem, the computing power of the development board without the graphics card plummets!). The PyTorch here and the following torchvision and other packages need to install the version given by Nvidia's official website.

1. Download pytorch1.8

Some bloggers have already downloaded it, you can directly use the extraction code: yvex

2. Install pytorch1.8

You can download pytorch1.8 on Jeston Nano, and it is recommended to put it on the desktop. sudo pip3 install …# Drag the .whl directly into the command window and let it automatically fill in the file location.
It takes a long time to wait for the installation.
insert image description here

4. Install torchvision0.9.0 version

The versions of PyTorch and torchvision need to be corresponding, and the one downloaded in the previous step is exactly corresponding.

1. Install the required dependencies

sudo apt-get install libopenmpi2
sudo apt-get install libopenblas-dev
sudo apt-get install libjpeg-dev zlib1g-dev

2. Install torchvision0.9.0

A special version matching Jetson nano is also required, and this torchvision is included in the personal link in step 3. Copy the downloaded package to the development board, and it is also recommended to put it on the desktop.

cd torchvision	# 进入到这个包的目录下
export BUILD_VERSION=0.9.0
sudo python3 setup.py install		# 安装(估计要20、30分钟不止吧)

3. Check whether the installation is successful

python3
import torch
import torchvision
print(torch.cuda.is_available())	# 这一步如果输出True那么就成功了!
quit()	# 最后退出python编译

5. Install the packages required by yolov5

Note: If the download process fails due to network reasons, you can add it after the command

 -i https://pypi.tuna.tsinghua.edu.cn/simple

To use the Tsinghua mirror source [It is recommended that you can add it if the download is not smooth]
1.

sudo pip3 install matplotlib==3.2.2
sudo pip3 install --upgrade Cython	#更新一下这个包

2. numpy is a bit special, it already comes with it, but it was installed by apt-get, so uninstall the original one first, and it is also convenient for later package management

sudo apt-get remove python-numpy
sudo pip3 install numpy==1.19.4
sudo pip3 install scipy==1.4.1.	# 这个包安装巨慢,耐心等待

3. I did not specify the version of some packages after this when I installed them. The instructions here are based on the later pip3 list.

sudo pip3 install tqdm==4.61.2
sudo pip3 install seaborn==0.11.1
sudo pip3 install scikit-build==0.11.1	# 安装opencv需要这个包
sudo pip3 install opencv-python==4.5.3.56	# 不出意外也是一个相当漫长的过程
sudo pip3 install tensorboard==2.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
sudo pip3 install --upgrade PyYAML	# 我升级到了5.4.1 也可以sudo pip3 install PyYAML==5.4.1
sudo pip3 install thop
sudo pip3 install pycocotools

Incomplete. . .

Guess you like

Origin blog.csdn.net/weixin_45768644/article/details/131781065