刷写镜像
更新python3版本
自动从SSD启动
手动指定启动位置
# 卸载office
$ sudo apt-get remove --purge libreoffice*
# 设置从sd卡启动
$ cd /boot/extlinux/
$ sudo cp extlinux.conf extlinux.conf_bak
$ sudo vim extlinux.conf
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 nv-auto-config
将 `/dev/mmcblk0p1`改为: `/dev/sda1`: (sda1与自己创建的分区名相关)
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/sda1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 nv-auto-config
安装cuda与tensorrt
将所有的都安装上去
配置cuda及tensorrt
$ sudo vim /etc/profile
export CUDA_HOME=/usr/local/cuda
export PATH=${CUDA_HOME}/bin:${PATH}
export PATH=/usr/src/tensorrt/bin:$PATH
# for fix 'illegal instruction'
export OPENBLAS_CORETYPE=ARMV8
安装Dev基础环境
nvidia@ubuntu:~$ sudo apt-get install -y build-essential cmake libavcodec-dev libavformat-dev libavutil-dev libeigen3-dev libglew-dev libgtk2.0-dev libgtk-3-dev libjpeg-dev libpng-dev libpostproc-dev libswscale-dev libtbb-dev libtiff5-dev libv4l-dev libxvidcore-dev libx264-dev qt5-default zlib1g-dev pkg-config
安装jetson-stats
nvidia@ubuntu:~$ sudo apt-get install python3-pip
nvidia@ubuntu:~$ sudo python3 -m pip install pip --upgrade
nvidia@ubuntu:~$ sudo -H python3 -m pip install -U jetson-stats
jetson-stats控制不了风扇转速的话
Jetson Xavier NX Series and Jetson AGX Xavier Series — Jetson Linux
Developer Guide 34.1 documentation (nvidia.com)
nvidia@ubuntu:~$ sudo systemctl start nvfancontrol.service
nvidia@ubuntu:~$ sudo cat /var/lib/nvfancontrol/status
FAN1:FAN_PROFILE:quiet
FAN1:FAN_GOVERNOR:pid
FAN1:FAN_CONTROL:open_loop
nvidia@ubuntu:~$ cat /etc/nvfancontrol.conf
#
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
POLLING_INTERVAL 2
<FAN 1>
TMARGIN DISABLED
FAN_GOVERNOR pid {
STEP_SIZE 10
}
FAN_PROFILE quiet {
#TEMP HYST PWM RPM
0 0 0 0
46 8 130 2850
60 8 160 3660
68 7 200 4600
76 7 255 6000
108 0 255 6000
}
FAN_PROFILE cool {
#TEMP HYST PWM RPM
0 0 0 0
35 8 140 3200
45 8 170 3900
53 7 200 4600
61 7 255 6000
108 0 255 6000
}
THERMAL_GROUP 0 {
GROUP_MAX_TEMP 108
#Thermal-Zone Coeffs Max-Temp
CPU-therm 30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
GPU-therm 30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
AUX-therm 40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
}
FAN_DEFAULT_CONTROL open_loop
FAN_DEFAULT_PROFILE quiet
FAN_DEFAULT_GOVERNOR pid
nvidia@ubuntu:~$
nvidia@ubuntu:~$ sudo vim /etc/nvfancontrol.conf
nvidia@ubuntu:~$ cat /etc/nvfancontrol.conf
#
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
POLLING_INTERVAL 2
<FAN 1>
TMARGIN DISABLED
FAN_GOVERNOR pid {
STEP_SIZE 10
}
FAN_PROFILE quiet {
#TEMP HYST PWM RPM
0 0 0 0
46 8 130 2850
60 8 160 3660
68 7 200 4600
76 7 255 6000
108 0 255 6000
}
FAN_PROFILE cool {
#TEMP HYST PWM RPM
0 0 0 0
35 8 160 3660
45 8 200 4600
53 7 255 6000
61 7 255 6000
108 0 255 6000
}
THERMAL_GROUP 0 {
GROUP_MAX_TEMP 108
#Thermal-Zone Coeffs Max-Temp
CPU-therm 30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
GPU-therm 30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
AUX-therm 40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
}
FAN_DEFAULT_CONTROL open_loop
FAN_DEFAULT_PROFILE cool
FAN_DEFAULT_GOVERNOR pid
nvidia@ubuntu:~$
nvidia@ubuntu:~$ sudo systemctl stop nvfancontrol.service
nvidia@ubuntu:~$ sudo rm -rf /var/lib/nvfancontrol/status
nvidia@ubuntu:~$ sudo systemctl start nvfancontrol.service
nvidia@ubuntu:~$ sudo cat /var/lib/nvfancontrol/status
FAN1:FAN_PROFILE:cool
FAN1:FAN_GOVERNOR:pid
FAN1:FAN_CONTROL:open_loop
nvidia@ubuntu:~$
编译opencv gpu
查看镜像自带版本
nvidia@ubuntu:~/workspace/buildOpenCV$ python3
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.getBuildInformation())
General configuration for OpenCV 4.5.4 =====================================
Version control: 4.5.4-8-g3e4c170df4
Platform:
Timestamp: 2022-01-18T10:01:01Z
Host: Linux 5.10.65-tegra aarch64
CMake: 3.16.3
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline: NEON FP16
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 9.3.0)
C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,--gc-sections -Wl,--as-needed
Linker flags (Debug): -Wl,--gc-sections -Wl,--as-needed
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt
3rdparty dependencies:
OpenCV modules:
To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python2 python3 stitching ts video videoio
Disabled: world
Disabled by dependency: -
Unavailable: java
Applications: tests perf_tests examples apps
Documentation: NO
Non-free algorithms: NO
GUI: GTK2
GTK+: YES (ver 2.24.32)
GThread : YES (ver 2.64.6)
GtkGlExt: NO
Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
WEBP: build (ver encoder: 0x020f)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.37)
TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
JPEG 2000: build (ver 2.4.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
FFMPEG: YES
avcodec: YES (58.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.100)
avresample: YES (4.0.0)
GStreamer: YES (1.16.2)
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: TBB (ver 2020.1 interface 11101)
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: NO
Eigen: YES (ver 3.3.7)
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.18)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.18)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5)
install path: lib/python2.7/dist-packages/cv2/python-2.7
Python 3:
Interpreter: /usr/bin/python3 (ver 3.8.10)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.8.so (ver 3.8.10)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.17.4)
install path: lib/python3.8/dist-packages/cv2/python-3.8
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /usr
-----------------------------------------------------------------
>>>
下载opencv
nvidia@ubuntu:~/workspace/opencv$ git clone --branch "4.5.4" https://github.com/opencv/opencv.git
nvidia@ubuntu:~/workspace/opencv$ git clone --branch "4.5.4" https://github.com/opencv/opencv_contrib.git
下载编译opencv脚本:github.com/JetsonHacks…
该lib是针对nano设置,故一些参数需要更改,更改后的lib位于:github.com/zhangningbo…
修改脚本中的参数ARCH_BIN
nvidia@ubuntu:~/workspace/buildOpenCV$ jetson_release -v
'DISPLAY' environment variable not set... skipping surface info
- NVIDIA Jetson UNKNOWN
* Jetpack UNKNOWN [L4T 35.1.0]
* NV Power Mode: MODE_20W_6CORE - Type: 8
* jetson_stats.service: active
- Board info:
* Type: UNKNOWN
* SOC Family: tegra194 - ID:
* Module: UNKNOWN - Board: P3509-000
* Code Name: jakku
* CUDA GPU architecture (ARCH_BIN): NONE
* Serial Number: 1424621088637
- Libraries:
* CUDA: NOT_INSTALLED
* cuDNN: 8.4.1.50
* TensorRT: 8.4.1.5
* Visionworks: NOT_INSTALLED
* OpenCV: 4.5.4 compiled CUDA: NO
* VPI: ii libnvvpi2 2.1.6 arm64 NVIDIA Vision Programming Interface library
* Vulkan: 1.3.203
- jetson-stats:
* Version 3.1.4
* Works on Python 3.8.10
nvidia@ubuntu:~/workspace/buildOpenCV$
jetson-stats针对JetPack 5.0.2不太适配(2022/12/09),那通过cuda提供的sample查询ARCH_BIN
nvidia@ubuntu:~$ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
nvidia@ubuntu:/usr/local/cuda/samples/1_Utilities/deviceQuery$ sudo make
nvidia@ubuntu:/usr/local/cuda/samples/1_Utilities/deviceQuery$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "Xavier"
CUDA Driver Version / Runtime Version 11.4 / 11.4
CUDA Capability Major/Minor version number: 7.2
Total amount of global memory: 6846 MBytes (7178952704 bytes)
(006) Multiprocessors, (064) CUDA Cores/MP: 384 CUDA Cores
GPU Max Clock rate: 1109 MHz (1.11 GHz)
Memory Clock rate: 1109 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 98304 bytes
Total number of registers available per block: 65536
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: No
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 Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
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 = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
Result = PASS
nvidia@ubuntu:/usr/local/cuda/samples/1_Utilities/deviceQuery$
CUDA Capability Major/Minor version number: 7.2即为需要的ARCH_BIN值。
修改完脚本后,开始编译opencv
nvidia@ubuntu:~/workspace/buildOpenCV$ ./buildOpenCV.sh -s /home/nvidia/workspace/opencv
安装torch
nvidia@ubuntu:~/soft$ sudo apt-get install python3-pip libopenblas-base libopenmpi-dev libomp-dev
nvidia@ubuntu:~/soft$ python3 -m pip install Cython
nvidia@ubuntu:~/soft$ wget https://developer.download.nvidia.com/compute/redist/jp/v50/pytorch/torch-1.12.0a0+2c916ef.nv22.3-cp38-cp38-linux_aarch64.whl
nvidia@ubuntu:~/soft$ python3 -m pip install numpy torch-1.12.0a0+2c916ef.nv22.3-cp38-cp38-linux_aarch64.whl
安装jetson_interface
安装pyserial并赋权
$ python3 -m pip install pyserial
$ sudo usermod -a -G dialout nvidia
Jetson性能优化
clocks
nvidia@ubuntu:~$ sudo cat /sys/devices/platform/13e10000.host1x/15340000.vic/power/control
auto
nvidia@ubuntu:~$ sudo vim /sys/devices/platform/13e10000.host1x/15340000.vic/power/control
nvidia@ubuntu:~$ sudo cat /sys/devices/platform/13e10000.host1x/15340000.vic/power/control
on
nvidia@ubuntu:~$ sudo cat /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/governor
wmark_active
nvidia@ubuntu:~$
nvidia@ubuntu:~$ sudo cat /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/governor
wmark_active
nvidia@ubuntu:~$ sudo vim /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/governor
nvidia@ubuntu:~$ sudo cat /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/governor
userspace
nvidia@ubuntu:~$
nvidia@ubuntu:~$ sudo cat /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/available_frequencies
115200000 128000000 140800000 153600000 166400000 179200000 192000000 204800000 217600000 230400000 243200000 256000000 268800000 281600000 294400000 307200000 320000000 332800000 345600000 358400000 371200000 384000000 396800000 409600000 422400000 435200000 448000000 460800000 473600000 486400000 499200000 512000000 524800000 537600000 550400000 563200000 576000000 588800000 601600000
nvidia@ubuntu:~$
nvidia@ubuntu:~$ sudo chmod 644 /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/target_freq
nvidia@ubuntu:~$ sudo echo 601600000 > /sys/devices/platform/13e10000.host1x/15340000.vic/devfreq/15340000.vic/target_freq
一直报错,无奈