Jetson: Difference between revisions

From 太極
Jump to navigation Jump to search
No edit summary
 
(90 intermediate revisions by the same user not shown)
Line 1: Line 1:
General information
= General information=
* Jetson nano https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-nano/.  
* Jetson nano https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-nano/.  
* https://developer.nvidia.com/embedded/jetson-modules
* https://developer.nvidia.com/embedded/jetson-modules
* CPU Tegra X1 4x A57 @ 1.43 GHz (ARMv8), GPU 128 cores of Maxwell generation @ 921 MHz
* CPU Tegra X1 4x A57 @ 1.43 GHz (ARMv8), GPU 128 CUDA cores of Maxwell generation @ 921 MHz (cf [https://smile.amazon.com/EVGA-GeForce-Profile-Graphic-02G-P4-6333-KR/dp/B071LGVBDM/ GeForce GT 1030 SC 2GB GDDR5 Low Profile Graphic Cards] has 384 CUDA cores)
* https://en.wikipedia.org/wiki/Nvidia_Jetson
* https://en.wikipedia.org/wiki/Nvidia_Jetson
* https://elinux.org/Jetson_Nano
* Power consumption: when it is idle, it uses .44A.
* https://www.waveshare.com/wiki/Jetson_Nano_Developer_Kit. Lots of information.


More
More
* [https://youtu.be/4cftyAq_J9g Now One Of The BEST SBCs For Emulation Project ARES On The Jetson Nano] ETA Prime, [https://techtoytinker.com/nvidia-jetson-nano ARES for the Jetson Nano], [https://www.youtube.com/channel/UC6isczC9ShzPqnXTcEbVnTg Tech Toy Tinker Company]
* [https://youtu.be/4cftyAq_J9g Now One Of The BEST SBCs For Emulation Project ARES On The Jetson Nano] ETA Prime, [https://techtoytinker.com/nvidia-jetson-nano ARES for the Jetson Nano], [https://www.youtube.com/channel/UC6isczC9ShzPqnXTcEbVnTg Tech Toy Tinker Company]
* [https://maker.pro/nvidia-jetson/tutorial/introduction-to-cuda-programming-with-jetson-nano Introduction to CUDA Programming With Jetson Nano]
== 4GB vs 2GB ==
[https://www.seeedstudio.com/blog/2020/10/05/compare-nvidia-jetson-nano-2gb-and-jetson-nano-4gb/ Comparison between Jetson Nano 2GB and Jetson Nano 4GB]
== ARMv8, ARMv9 ==
* https://en.wikipedia.org/wiki/ARM_architecture_family
* ARMv8 is an ARM instruction set architecture announced in 2011. It brought a large number of fundamental changes to the instruction set, including the introduction of 64-bit operating capabilities. ARMv8 architecture uses two execution states, AArch32 and AArch64. As the names imply, one is for running 32-bit code and one for 64-bit.
* After ARMv8, which was introduced in 2011, ARM introduced ARMv9 architecture.
* According to ARM, some of the major new features of the ARMv9-A architecture include Realm Management Extension (RME) and Embedded Trace Extension (ETE) and Trace Buffer Extension (TRBE).
* [https://en.wikipedia.org/wiki/Apple_M1 Apple M1 chip] or M2 chip is based on ARMv8.5-A instruction set architecture.
== Images ==
* https://developer.nvidia.com/embedded/downloads
* [https://pythops.com/post/create-your-own-image-for-jetson-nano-board Create your own image for jetson nano board]
* [https://pythops.com/post/create-your-own-image-for-jetson-nano-board Create your own image for jetson nano board]
== Vs Raspberry Pi 4 ==
* The two motherboard are similar:new Raspberry Pi has the same arch and almost the same processor (nvidia one is older). [https://forums.developer.nvidia.com/t/vlc-doesnt-work-on-nvidia-jetson-nano/77353 VLC doesn’t work on Nvidia Jetson Nano]
* [https://www.sunthen.com/blog/Raspberry-Pi-4-vs-NVIDIA-Jetson-Nano Raspberry Pi 4 vs NVIDIA Jetson Nano, Which one is better for your project?] Note that both can handle H265 (4k 60fps)
* No, the Raspberry Pi does not support hardware decoding for the VP9 codec. Note that for 4K videos, '''Raspberry Pi 4B hardware supports only H265 (HEVC) codec'''. You can use a media player like VLC or Kodi to play a 4K 60fps video file. Make sure the video file is encoded with the H265 codec. This means that while it can technically decode '''VP9 video''', it must do so using software decoding, which is much less efficient and may not be able to handle 4K video at 60fps.
* [https://www.makeuseof.com/run-your-raspberry-pi-at-4k-60hz/ Run Your Raspberry Pi at 4K 60Hz]. Note that you still won't be able to select 4K resolution for YouTube videos in the Chromium web browser. Nor can you play 4K 60Hz videos in the VLC multimedia player from the desktop. However, you should be able to play compatible 4K 60Hz HEVC videos in the Kodi media player if you have it installed.
= Get started =
<ul>
<li>[https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-2gb-devkit#next Getting Started with Jetson Nano 2GB Developer Kit]. Jetson 2GB Developer Kit User Guide. How-to guides. NVIDIA AI tutorials and courses.
<li>[https://towardsdatascience.com/getting-started-nvidia-jetson-nano-object-detection-and-classification-161ad566d594 Getting Started: Nvidia Jetson Nano, Object Detection and Classification].
<pre>
sudo apt-get update
sudo apt-get install v4l-utils
v4l2-ctl --list-devices --list-formats
./imagenet-camera.py --camera=/dev/video0
./detectnet-camera.py --camera=/dev/video0
</pre>
</li>
<li>Self-paced, online training from [https://www.nvidia.com/en-us/training/ NVIDIA DEEP LEARNING INSTITUTE]
</ul>
== Hello AI World ==
* https://github.com/dusty-nv/jetson-inference
== Ubuntu 20.04 ==
[https://qengineering.eu/install-ubuntu-20.04-on-jetson-nano.html Install Ubuntu 20.04 on Jetson Nano]
=== Post installation ===
<ul>
<li>Use gparted to increase the partition /dev/mmcblk0 on another computer.
<li>sudo apt install '''openssh-server'''
<li>sudo apt-get install '''avahi-daemon'''
<li>Switch from GNOME to '''LXDE & lightdm''' (cf xfce4). [https://jetsonhacks.com/2020/11/07/save-1gb-of-memory-use-lxde-on-your-jetson/ Save 1GB of Memory! Use LXDE on your Jetson].
<li>Setup tightvncserver. Seee [[Remote_desktop#Tunnel_the_VNC_traffic_through_SSH_connection|Remote Desktop]]. Remember to set up VNC server system at startup. In ".vnc/xstartup", use "startlxde&" instead. For 16:9 ratio, consider 1366×768 or 1280×720.
<li>Install [[Jetson#jtop|jtop]] to monitor CPU/GPU usage, temperature, et al. '''jtop''' is better than tegrastats
<pre>
sudo apt install python3-pip
sudo -H pip3 install -U jetson-stats
</pre>
<li>Remove snap
<pre>
snap list
sudo apt remove --purge snapd
sudo apt-mark hold snapd
</pre>
<li>nano ~/.bashrc. Add a line '''LS_COLORS="di=1;31" '''
<li>Test gst-launch-1.0
<pre>
gst-launch-1.0 filesrc location=Big_Buck_Bunny_4K.mp4 !  \
    qtdemux ! queue ! h264parse ! nvv4l2decoder ! \
    nv3dsink window-width=1280 window-height=720
</pre>
<li>Install exiftool
<pre>
sudo apt install libimage-exiftool-perl
exiftool Big_Buck_Bunny_4K.mp4
</pre>
<li>sudo apt install terminator, neofetch
</ul>
== Fan ==
* [https://www.waveshare.com/wiki/Fan-4020-PWM-5V Fan-4020-PWM-5V] instruction from waveshare.com. (Cf '''DC fan'''. These fans use a three-pin connector with a power supply pin, a ground pin, and a signal pin. DC fans can either run at a constant speed or change speeds as controlled by the motherboard)
* [https://www.amazon.com/Dedicated-Developer-Adjustment-40mm%C3%9740mm%C3%9720mm-Reverse-Proof/dp/B07TD2PCM5/ DC 5V Cooling Fan Compatible with NVIDIA Jetson Nano Developer Kit and B01 Version PWM Speed Adjustment Strong Cooling Air Fan 40mm×40mm×20mm with 4PIN Reverse-Proof Connector] & [https://www.amazon.com/dp/B07TC21414 2 pack]
<pre>
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
</pre>
To stop it just change the 255 to zero, or to slow it down put some value in between the two (its and 8 bit number, so any number between 0 and 255 will operate at a different speed).
== Camera ==
<ul>
<li> ''' ls -l /dev/video0 '''
<li>[https://forums.developer.nvidia.com/t/csi-camera-not-detected-on-jetson-nano/263243 CSI Camera Not Detected on Jetson Nano].
* [https://www.okdo.com/getting-started/get-started-with-jetson-nano-4gb-and-csi-camera/ Nano platform is by default support with Raspberry pi v2, imx219].
* [https://www.raspberrypi.com/products/camera-module-3/ Raspberry Pi Camera Module 3 Wide] (Sony IMX708 12-megapixel, 120 degrees, ultra fast auto focus, video up to 1080p50, 720p100) is not detected.
* [https://github.com/JetsonHacksNano/CSI-Camera Check camera image capabilities], [https://www.mankier.com/1/v4l2-ctl v4l2-ctl - Man Page], [https://jetsonhacks.com/2022/02/02/in-practice-usb-cameras-on-jetson/ In Practice: USB Cameras on Jetson] - At its core, the Jetsons use the Linux kernel module Video Four Linux (version 2) (V4L2).
:<syntaxhighlight lang='bash'>
$ # sudo apt-get install v4l-utils
$ v4l2-ctl --all  # very detailed
$ v4l2-ctl --list-device
vi-output, imx219 6-0010 (platform:54080000.vi:0):
/dev/video0
NVIDIA Tegra Video Input Device (platform:vi):
/dev/media0
$ v4l2-ctl --list-formats-ext # list video formats
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'RG10' (10-bit Bayer RGRG/GBGB)
Size: Discrete 3264x2464
Interval: Discrete 0.048s (21.000 fps)
Size: Discrete 3264x1848
Interval: Discrete 0.036s (28.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1640x1232
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
</syntaxhighlight>
* [https://docs.arducam.com/Nvidia-Jetson-Camera/Introduction-to-Arducam-Jetson-Cameras/ Introduction to Arducam Jetson Cameras], [https://www.arducam.com/product/arducam-imx219-wide-angle-camera-module-for-nvidia-jetson-nano-raspberry-pi-compute-module-4-3-3-b0287/ Arducam IMX219 Camera Module with fisheye lens for NVIDIA® Jetson Nano/Xavier NX/AGX Orin/Orin Nano/Orin NX] supports Jetson nano but not RPi.
<li>[https://forums.developer.nvidia.com/t/turn-on-off-csi-camera/140956 Turn on/off CSI camera]
<pre>
# echo 0 > /sys/kernel/debug/camera-video0/streaming
</pre>
<li>[https://dmccreary.medium.com/getting-your-camera-working-on-the-nvida-nano-336b9ecfed3a Getting Your Camera Working on the Nvidia Nano]
{{Pre}}
$ ls /dev/video0
$ export DISPLAY=:0  # IF WE USE SSH
$ gst-launch-1.0 nvarguscamerasrc ! \
'video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12' ! \
  nvvidconv flip-method=0 ! 'video/x-raw,width=960, height=616' ! \
  nvvidconv ! nvegltransform ! nveglglessink -e
$ gst-launch-1.0 nvarguscamerasrc sensor_id=0 ! \
'video/x-raw(memory:NVMM),width=3280, height=2464, framerate=21/1, format=NV12' ! \
  nvvidconv flip-method=2 ! 'video/x-raw, width=816, height=616' ! \
  nvvidconv ! nvegltransform ! nveglglessink -e
</pre>
<li>[https://www.okdo.com/getting-started/get-started-with-jetson-nano-2gb-and-csi-camera/ Get Started with Jetson Nano 2GB and CSI Camera]
<li>[https://developer.nvidia.com/embedded/learn/tutorials/first-picture-csi-usb-camera Taking Your First Picture with CSI or USB Camera].
<pre>
nvgstcapture-1.0 --automate --capture-auto --image-res=4 -S 3
ls -lt # nvcamtest_XXXX_s00_00000.jpg
# --capture-auto: Do image/video capture in automation mode for count number of times
# -A, --automate: Run application in automation mode
# default resolution is 640 x480; --image-res=2.
# --image-res=4 gives 1920x1080. --image-res=3 gives 1280x720.
# -S, --start-time: Start capture after specified time in seconds. Default = 5 sec (use with --automate or -A only)
# -S 3: automatic after 3 seconds
# --capture-time: Capture video for specified time in seconds. Default = 10 sec (use with --automate and --capture-auto only)
$ nvgstcapture-1.0 --help
...
Supported resolutions in case of NvArgusCamera
  (2) : 640x480
  (3) : 1280x720
  (4) : 1920x1080
  (5) : 2104x1560
  (6) : 2592x1944
  (7) : 2616x1472
  (8) : 3840x2160
  (9) : 3896x2192
  (10): 4208x3120
  (11): 5632x3168
  (12): 5632x4224
</pre>
* You can test if the camera is working by running this pipeline in your terminal: '''nvgstcapture-1.02'''. This command will start capture and preview display it on the screen.
* Press 'j' to capture on image. Press 'q' to quit.
* Press '1' to start video recording. Press '0' to stop recording.
</ul>
= Tips =
== Boot from USB ==
<ul>
<li>https://github.com/jetsonhacks/bootFromUSB 2021, [https://www.jetsonhacks.com/2021/03/10/jetson-nano-boot-from-usb/ Jetson Nano – Boot from USB] 2021
<ul>
<li>Boot Jetson nano from a micro SD card</li>
<li>git clone https://github.com/jetsonhacks/bootFromUSB.git </li>
<li>Disks > Format > GPT > '+' > SSD240 </li>
<li>Mount SSD. ls /dev/sd* </li>
<li>./copyRootToUSB.sh -p /dev/sda1 </li>
<li>cd /media/USERNAME/SSD240/boot/extlinux </li>
<li>sudo cp extlinux.conf extlinux.conf.bak </li>
<li>./partUUID.sh </li>
<li>sudo gedit extlinux.conf </li>
<li>Shutdown. Remove SD card. Bingo. </li>
</ul>
</li>
<li>[https://robroyce.dev/2021/02/11/how-to-boot-jetson-nano-from-usb-3-0-natively-with-jetpack-4-5/ How to Boot Jetson Nano From USB 3.0 (Natively) with Jetpack 4.5] 2021 </li>
<li>[https://tutorial.cytron.io/2020/10/21/nvidia-jetson-nano-boot-from-usb/ Nvidia Jetson Nano Boot from USB] 2020 </li>
<li>[https://jetsonhacks.com/2019/04/25/jetson-nano-run-on-usb-drive/ etson Nano – Run on USB Drive] 2019. Use a '''swap file''', not a swap partition.
</ul>
== Low memory problem in Jetson nano ==
* [https://forums.developer.nvidia.com/t/low-memory-problem-in-jetson-nano/111964  Low memory problem in Jetson nano]
== GPU benchmark ==
* [https://www.arnabkumardas.com/platforms/nvidia/nvidia-jetson-nano-review-and-benchmark/ Nvidia Jetson Nano Review and Benchmark]
* [https://linuxreviews.org/Glmark2 Glmark2]. Glmark2 is an OpenGL 2.0 and ES 2.0 benchmark. glmark2 is a cross-platform tool that can be used to test the performance of the GPU on both platforms with and without CUDA cores.
** '''sudo apt-get install glmark2'''
* [https://wiki.luxcorerender.org/LuxMark_v3 LuxMark]
== System monitor ==
* [https://lambdalabs.com/blog/keeping-an-eye-on-your-gpus-2 Keeping An Eye On Your GPUs - GPU Monitoring Tools Compared]
=== '''jtop''' ===
[https://jetsonhacks.com/2023/02/07/jtop-the-ultimate-tool-for-monitoring-nvidia-jetson-devices/ jtop: The Ultimate Tool for Monitoring NVIDIA Jetson Devices]
<syntaxhighlight lang='bash'>
sudo pip3 install -U jetson-stats
jtop
</syntaxhighlight>
=== Tegrastats Utility ===
* [https://docs.nvidia.com/jetson/archives/r34.1/DeveloperGuide/text/AT/JetsonLinuxDevelopmentTools/TegrastatsUtility.html tegrastats]
* [https://docs.nvidia.com/jetson/archives/r34.1/DeveloperGuide/text/AT/JetsonLinuxDevelopmentTools.html Jetson Linux Development Tools]
=== nvidia-smi ===
<ul>
<li>[https://forums.developer.nvidia.com/t/command-nvidia-smi-on-jetson-nano-not-working/119702 Command nvidia-smi on Jetson Nano not working?] or [https://forums.developer.nvidia.com/t/gpu-usage-info-nvidia-smi-is-not-there/189937 GPU usage info (nvidia-smi is not there)]
<li>[https://developer.nvidia.com/nvidia-system-management-interface System Management Interface SMI]
<li>If the NVIDIA driver is installed correctly, this command will display information about your GPU, including its model, driver version, and usage statistics.
<pre>
nvidia-smi
# OR
dpkg -l | grep nvidia
</pre>
<li>How to install nvidia drivers on x86
<pre>
lspci | grep -i nvidia # obtain info about GPU including the model
sudo apt update
# Method 1
sudo ubuntu-drivers autoinstall #
# Method 2
apt search nvidia-driver
sudo apt install nvidia-driver-xxx
sudo reboot
nvidia-smi
</pre>
</ul>
=== NVIDIA CUDA Toolkit ===
* Install the NVIDIA CUDA Toolkit if you plan to use software that supports GPU acceleration for media processing tasks. Many video transcoding and processing applications can take advantage of CUDA for hardware acceleration.
== jetson_clocks, power mode ==
* [https://forums.developer.nvidia.com/t/what-does-jetson-clocks-do/73788 what does jetson_clocks do?] the jetson_clocks script disables the DVFS governor and locks the clocks to their maximums as defined by the active nvpmodel power mode. So if your '''active nvpmodel mode''' is 10W, jetson_clocks will lock the clocks to their maximums for 10W mode. And if your active nvpmodel is 5W, jetson_clocks will lock the clocks to their maximums for 5W mode.
* [https://jetsonhacks.com/2019/04/10/jetson-nano-use-more-power/ Jetson Nano – Use More Power!] '''nvpmodel'''
* [https://developer.nvidia.com/embedded/learn/jetson-nano-2gb-devkit-user-guide Jetson Nano 2GB Developer Kit User Guide]
** Power Consumption. There are two software-defined power modes for the Jetson module. 10W & 5W.
== Hardware acceleration ==
* [https://forums.developer.nvidia.com/t/hardware-decoding-in-mpv-player/75872 Hardware decoding in mpv player]. '''totem''' is gstreamer based.
* https://github.com/jocover/jetson-ffmpeg
== Youtube streaming ==
[https://youtu.be/xAU2edlXj88 Testing video]. Resolution is 480p. CPU usage is 30-50%, GPU is 50%.
Temperature: CPU 46C, GPU 43.5C (no fan). CPU 24C, GPU 22C (fan 255 & loud). CPU 29C, GPU 27C (fan 75, quiet).
By default, there is no sound b/c the output is analog by default. See [https://forums.developer.nvidia.com/t/jetson-nano-no-sound-output/72238/16 Jetson nano no sound output]. On 2GB, assuming you didn’t choose minimal option for OS installation, go to:
Sound & Video> '''PulseAudio Volume Control'''> Configuration Tab> Built-in Audio: Profile Digital Stereo (HDMI) Output (Leave this as it is)
Change the second profile to “off” (default is on Analog).
== GStreamer, gst-launch-1.0 ==
<ul>
<li>[https://jetsonhacks.com/2019/04/02/jetson-nano-raspberry-pi-camera/ Jetson Nano + Raspberry Pi Camera]
<li>[https://docs.nvidia.com/jetson/archives/r34.1/DeveloperGuide/text/SD/Multimedia/AcceleratedGstreamer.html#video-decode-examples-using-gst-launch-1-0 Video Decode Examples Using gst-launch-1.0] & [https://developer.download.nvidia.com/embedded/L4T/r32_Release_v1.0/Docs/Accelerated_GStreamer_User_Guide.pdf PDF] version.
<li>To test 4K video playback on the NVIDIA Jetson Nano, you can use the GStreamer multimedia framework.
{{Pre}}
sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo apt-get update
sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa \\
  gstreamer1.0-plugins-base gstreamer1.0-plugins-good \\
  gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \\
  gstreamer1.0-libav
sudo apt-get install libgstreamer1.0-dev \\
  libgstreamer-plugins-base1.0-dev \\
  libgstreamer-plugins-good1.0-dev \\
  libgstreamer-plugins-bad1.0-dev
gst-launch-1.0 filesrc location=<4k-video-file-path> ! \
  qtdemux ! h264parse ! omxh264dec ! nveglglessink -e
</pre>
Replace <4k-video-file-path> with the path to your 4K video file. Note that the performance of 4K video playback may depend on other factors such as the bitrate of the video, the overall load on the Jetson Nano, and so on
<li>SSH connection. Running gst-launch-1.0 in the background and run jtop to see the resource. See also [https://stackoverflow.com/a/10408906 How do I use the nohup command without getting nohup.out?]
<pre>
export DISPLAY=:0
nohup gst-launch-1.0 filesrc location=lg-uhd-LG-Greece-and-Norway.mp4 ! \
  qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e \
  >/dev/null 2>&1 &
jtop
</pre>
<li>[https://forums.developer.nvidia.com/t/jetson-nano-2gb-development-kit-4k-video-play-back-question/161190 Jetson Nano 2GB development kit 4k video play back question]. The following is for H.264 Decode (NVIDIA Accelerated Decode).
{{Pre}}
gst-launch-1.0 filesrc location=<filename_h264.mp4> ! \
    qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e
</pre>
{{Pre}}
gst-launch-1.0 uridecodebin uri=file:///home/nvidia/a.mp4 ! \
    nvvidconv ! 'video/x-raw(memory:NVMM),width=1920,height=1080' ! \
    nvoverlaysink
</pre>
<li>mkv file. [https://forums.developer.nvidia.com/t/playing-videos-using-gstreamer-on-jetson-nano/153846 Playing videos using gstreamer on Jetson Nano]
<li>[https://gstreamer.freedesktop.org/documentation/installing/on-linux.html GStreamer on Linux]
<pre>
gst-launch-1.0 filesrc location=vid.mkv ! \
      matroskademux name=dem dem.video_0 ! \
      h265parse ! nvv4l2decoder ! nvvidconv ! \
      video/x-raw ! subtitleoverlay name=sub dem.subtitle_0 ! \
      queue ! sub. sub. ! xvimagesink
</pre>
<li>'''Is "!" the same as "|" ? ''' Ans: No, the "!" and "|" symbols are not the same in the Linux command line. The "!" symbol in a GStreamer pipeline (like in your `gst-launch-1.0` command) is used to separate and link different elements in the pipeline. The "|" symbol, also known as a pipe, is used in the Linux command line to pass the output of one command as input to another¹. This is a form of redirection that is a fundamental part of Unix-like operating systems.
</ul>
=== 4k test videos ===
* [https://pixabay.com/videos/search/4k/ Pixabay], [https://www.pexels.com/search/canyon/ Pexels]
* [https://archive.org/details/big-buck-bunny-2008-4-k-60-fps-blender-animated-short-x-265 Big Buck Bunny (2008) 4K 60FPS Blender Animated Short - x265] 7.1GB, mkv file.
* https://www.demolandia.net/
* https://www.libde265.org/downloads-videos/
* [https://linuxconfig.org/how-to-get-and-change-video-metadata-in-linux exiftool] to check metadata/verify width/height/fps
<pre>
$ exiftool Big_Buck_Bunny_4K_60fps-x265.mkv
ExifTool Version Number        : 11.88
File Name                      : Big_Buck_Bunny_4K_60fps-x265.mkv
Directory                      : .
File Size                      : 7.1 GB
File Modification Date/Time    : 2023:09:14 02:51:04+02:00
File Access Date/Time          : 2023:09:14 02:55:15+02:00
File Inode Change Date/Time    : 2023:09:14 02:54:49+02:00
File Permissions                : rw-r--r--
File Type                      : MKV
File Type Extension            : mkv
MIME Type                      : video/x-matroska
EBML Version                    : 1
EBML Read Version              : 1
Doc Type                        : matroska
Doc Type Version                : 4
Doc Type Read Version          : 2
Timecode Scale                  : 1 ms
Muxing App                      : Lavf60.3.100
Writing App                    : HandBrake 20230319201705-0cbc182b0-master 2023032001
Date/Time Original              : 2023:04:11 22:20:59Z
Duration                        : 0:10:35
Codec ID                        : V_MPEGH/ISO/HEVC
Video Frame Rate                : 60
Image Width                    : 3840
Image Height                    : 2160
Video Codec ID                  : A_AC3
Track Number                    : 3
Track Name                      : Stereo
Track Language                  : und
Track Default                  : No
Audio Codec ID                  : A_MPEG/L3
Track Type                      : Audio
Audio Channels                  : 2
Audio Sample Rate              : 48000
Tag Name                        : DURATION
Tag String                      : 00:10:34.200000000
Image Size                      : 3840x2160
Megapixels                      : 8.3
</pre>
=== RTSP output ===
* [https://forums.developer.nvidia.com/t/jetson-nano-faq/82953 Jetson nano FAQ]. ./test-launch
** [https://forums.developer.nvidia.com/t/about-to-start-a-streaming-server-with-rtsp-and-gstreamer-on-ubuntu-18-04-on-the-jetson-nano/165564/12 About to start a streaming server with RTSP and gstreamer on ubuntu 18.04 on the jetson nano]
** [https://www.simonwenkel.com/notes/software_libraries/gstreamer/gst-rtsp-server-compilation-notes.html gst-rtsp-server Compilation Notes]. 'Undefined reference to gst_rtsp_media_factory_set_enable_rtcp'.
* [https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-streaming.md?utm_source=pocket_saves jetson-utils includes a built-in RTSP server]
* [https://youtu.be/Us20t1gQPOE?si=oNuaIUwxPxYiNdJ5&t=2267 ZoneMinder] allows RTSP stream as a video source.
* HTTP streaming. [https://maker.pro/nvidia-jetson/tutorial/streaming-real-time-video-from-rpi-camera-to-browser-on-jetson-nano-with-flask Using Jetson Nano and a Raspberry Pi Camera for Video Streaming]
== ffmeg ==
[https://developer.nvidia.com/embedded/community/jetson-projects/jetson_ffmpeg FFmpeg] can be used to play 4K video on the Jetson Nano. The Jetson-FFMpeg project allows you to use FFmpeg on the Jetson Nano via the L4T Multimedia API, supporting hardware-accelerated encoding of H.264 and HEVC.
However, it's important to note that the Jetson Nano doesn't need to use GPU for hardware decoding MPEG2, H.264/AVC, HEVC, VP8 and VP9. These formats are decoded by a specific video hardware decoder (NVDEC) that can be accessed by the L4T Multimedia API².
Here is an example command to play a 4K video using FFmpeg on the Jetson Nano:
<pre>
ffplay -vcodec h264_nvmpi -i vid.mp4
ffplay -vcodec hevc_nvmpi -i vid.mp4
</pre>
The `hevc_nvmpi` and `h264_nvmpi` are both hardware-accelerated video encoders provided by NVIDIA, but they are used for different video codecs¹.
* '''h264_nvmpi''': This is the NVIDIA '''hardware-assisted''' H.264 video '''encoder'''. H.264, also known as AVC (Advanced Video Coding), is a standard for video compression that is most commonly used to encode high definition video and distribute digital video content²⁵.
* `hevc_nvmpi`: This encoder is used for the H.265 video codec, also known as HEVC (High Efficiency Video Coding). HEVC is a more recent video compression standard that provides a more efficient compression method than H.264 but with the same level of image quality. It's particularly useful for streaming 4K content over networks like Netflix.
* In terms of quality and performance, '''libx264''' (a '''software-based H.264 encoder''') might deliver better quality than `h264_nvmpi` for the same bitrate, but `h264_nvmpi` is probably faster and uses less power. The same could be true when comparing a software-based HEVC encoder with `hevc_nvmpi`.
[https://github.com/jocover/jetson-ffmpeg#supports-decoding jetson-ffmpeg] from github. It supports decoding of VP9 too.
== Add keyboard shortcut to launch LX terminal ==
[https://superuser.com/a/902584 How To add a shortcut key to the terminal in LXDE?]
Add
<pre>
<!-- Launch LXTerminal with Ctrl+Alt+t-->
    <keybind key="C-A-t">
      <action name="Execute">
        <command>lxterminal</command>
      </action>
    </keybind>
</pre>
to '''~/.config/openbox/lxde-rc.xml'''
== swap ==
* https://github.com/JetsonHacksNano/installSwapfile
* [https://www.jetsonhacks.com/2019/11/28/jetson-nano-even-more-swap/ Jetson Nano – Even More Swap]
== Use as a server ==
[https://maxoffsky.com/code-blog/10-uses-for-nvidia-jetson-nano-developer-kit/ 10 Uses for Nvidia Jetson Nano Developer Kit]
* Web server
* Video Processing and Live Streaming Server
* Artificial Intelligence / Machine Learning Station
* NAS
* Home Media Server (sudo apt-get install kodi)
= Alternative OS =
https://forums.developer.nvidia.com/t/alternative-os/75649
== Armbian ==
https://www.armbian.com/jetson-nano/. PWM causes kernel 6.1\6.2 to panic, so disabled.
== LineageOS ==
<ul>
<li>https://download.lineageos.org/porg
<li>[https://www.getdroidtips.com/download-install-gapps-lineage-os/ Download and Install GApps for Lineage OS]
<li>[https://forums.developer.nvidia.com/t/lineage-android-os-for-the-jetson-nano/193845 Lineage Android OS for the Jetson Nano]
<li>[https://lineageosroms.com/porg_tab/ Nvidia Jetson (Nano / Nano 2GB) [Tablet] (porg_tab)]
* [https://dev.to/asacasa/howto-recovery-mode-for-nvidia-jetson-nano-developer-kit-ceo HowTo: Recovery Mode for NVIDIA Jetson NANO Developer Kit]
* [https://wiki.52pi.com/index.php?title=ZP-0101 FR = factory recovery mode]
<li>Video: [https://youtu.be/6HQmJ_JsTp0?si=uiGRufhl69OIYW8B Lineage OS on the Nvidia Jetson Nano!]
</ul>
== ARES: aurora retro entertainment system ==
<ul>
<li>https://techtoytinker.com/nvidia-jetson-nano. Username/password: aresuser/thera
<li>[https://www.youtube.com/watch?v=V6gR7sO2dFU Nvidia Jetson Nano ARES Stable 1 Release]
</ul>
== Kodi ==
* https://forums.developer.nvidia.com/t/kodi-18-on-nano/125448
* https://elinux.org/Jetson/Kodi_(XBMC) Jetson TK1

Latest revision as of 08:42, 8 March 2024

General information

More

4GB vs 2GB

Comparison between Jetson Nano 2GB and Jetson Nano 4GB

ARMv8, ARMv9

  • https://en.wikipedia.org/wiki/ARM_architecture_family
  • ARMv8 is an ARM instruction set architecture announced in 2011. It brought a large number of fundamental changes to the instruction set, including the introduction of 64-bit operating capabilities. ARMv8 architecture uses two execution states, AArch32 and AArch64. As the names imply, one is for running 32-bit code and one for 64-bit.
  • After ARMv8, which was introduced in 2011, ARM introduced ARMv9 architecture.
  • According to ARM, some of the major new features of the ARMv9-A architecture include Realm Management Extension (RME) and Embedded Trace Extension (ETE) and Trace Buffer Extension (TRBE).
  • Apple M1 chip or M2 chip is based on ARMv8.5-A instruction set architecture.

Images

Vs Raspberry Pi 4

  • The two motherboard are similar:new Raspberry Pi has the same arch and almost the same processor (nvidia one is older). VLC doesn’t work on Nvidia Jetson Nano
  • Raspberry Pi 4 vs NVIDIA Jetson Nano, Which one is better for your project? Note that both can handle H265 (4k 60fps)
  • No, the Raspberry Pi does not support hardware decoding for the VP9 codec. Note that for 4K videos, Raspberry Pi 4B hardware supports only H265 (HEVC) codec. You can use a media player like VLC or Kodi to play a 4K 60fps video file. Make sure the video file is encoded with the H265 codec. This means that while it can technically decode VP9 video, it must do so using software decoding, which is much less efficient and may not be able to handle 4K video at 60fps.
  • Run Your Raspberry Pi at 4K 60Hz. Note that you still won't be able to select 4K resolution for YouTube videos in the Chromium web browser. Nor can you play 4K 60Hz videos in the VLC multimedia player from the desktop. However, you should be able to play compatible 4K 60Hz HEVC videos in the Kodi media player if you have it installed.

Get started

Hello AI World

Ubuntu 20.04

Install Ubuntu 20.04 on Jetson Nano

Post installation

  • Use gparted to increase the partition /dev/mmcblk0 on another computer.
  • sudo apt install openssh-server
  • sudo apt-get install avahi-daemon
  • Switch from GNOME to LXDE & lightdm (cf xfce4). Save 1GB of Memory! Use LXDE on your Jetson.
  • Setup tightvncserver. Seee Remote Desktop. Remember to set up VNC server system at startup. In ".vnc/xstartup", use "startlxde&" instead. For 16:9 ratio, consider 1366×768 or 1280×720.
  • Install jtop to monitor CPU/GPU usage, temperature, et al. jtop is better than tegrastats
    sudo apt install python3-pip
    sudo -H pip3 install -U jetson-stats
    
  • Remove snap
    snap list
    sudo apt remove --purge snapd
    sudo apt-mark hold snapd
    
  • nano ~/.bashrc. Add a line LS_COLORS="di=1;31"
  • Test gst-launch-1.0
    gst-launch-1.0 filesrc location=Big_Buck_Bunny_4K.mp4 !  \
        qtdemux ! queue ! h264parse ! nvv4l2decoder ! \
        nv3dsink window-width=1280 window-height=720
    
  • Install exiftool
    sudo apt install libimage-exiftool-perl
    exiftool Big_Buck_Bunny_4K.mp4
    
  • sudo apt install terminator, neofetch

Fan

sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'

To stop it just change the 255 to zero, or to slow it down put some value in between the two (its and 8 bit number, so any number between 0 and 255 will operate at a different speed).

Camera

  • ls -l /dev/video0
  • CSI Camera Not Detected on Jetson Nano.
    $ # sudo apt-get install v4l-utils
    $ v4l2-ctl --all  # very detailed
    $ v4l2-ctl --list-device
    vi-output, imx219 6-0010 (platform:54080000.vi:0):
    	/dev/video0
    
    NVIDIA Tegra Video Input Device (platform:vi):
    	/dev/media0
    $ v4l2-ctl --list-formats-ext # list video formats
    ioctl: VIDIOC_ENUM_FMT
    	Type: Video Capture
    
    	[0]: 'RG10' (10-bit Bayer RGRG/GBGB)
    		Size: Discrete 3264x2464
    			Interval: Discrete 0.048s (21.000 fps)
    		Size: Discrete 3264x1848
    			Interval: Discrete 0.036s (28.000 fps)
    		Size: Discrete 1920x1080
    			Interval: Discrete 0.033s (30.000 fps)
    		Size: Discrete 1640x1232
    			Interval: Discrete 0.033s (30.000 fps)
    		Size: Discrete 1280x720
    			Interval: Discrete 0.017s (60.000 fps)
  • Turn on/off CSI camera
    # echo 0 > /sys/kernel/debug/camera-video0/streaming
    
  • Getting Your Camera Working on the Nvidia Nano
    $ ls /dev/video0
    $ export DISPLAY=:0   # IF WE USE SSH
    $ gst-launch-1.0 nvarguscamerasrc ! \
     'video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12' ! \
      nvvidconv flip-method=0 ! 'video/x-raw,width=960, height=616' ! \
      nvvidconv ! nvegltransform ! nveglglessink -e
    
    $ gst-launch-1.0 nvarguscamerasrc sensor_id=0 ! \
     'video/x-raw(memory:NVMM),width=3280, height=2464, framerate=21/1, format=NV12' ! \
      nvvidconv flip-method=2 ! 'video/x-raw, width=816, height=616' ! \
      nvvidconv ! nvegltransform ! nveglglessink -e 
    
  • Get Started with Jetson Nano 2GB and CSI Camera
  • Taking Your First Picture with CSI or USB Camera.
    nvgstcapture-1.0 --automate --capture-auto --image-res=4 -S 3
    ls -lt # nvcamtest_XXXX_s00_00000.jpg
    # --capture-auto: Do image/video capture in automation mode for count number of times
    # -A, --automate: Run application in automation mode
    # default resolution is 640 x480; --image-res=2.
    # --image-res=4 gives 1920x1080. --image-res=3 gives 1280x720.
    # -S, --start-time: Start capture after specified time in seconds. Default = 5 sec (use with --automate or -A only)
    # -S 3: automatic after 3 seconds
    # --capture-time: Capture video for specified time in seconds. Default = 10 sec (use with --automate and --capture-auto only)
    $ nvgstcapture-1.0 --help
    ...
    Supported resolutions in case of NvArgusCamera
      (2) : 640x480
      (3) : 1280x720
      (4) : 1920x1080
      (5) : 2104x1560
      (6) : 2592x1944
      (7) : 2616x1472
      (8) : 3840x2160
      (9) : 3896x2192
      (10): 4208x3120
      (11): 5632x3168
      (12): 5632x4224
    
    • You can test if the camera is working by running this pipeline in your terminal: nvgstcapture-1.02. This command will start capture and preview display it on the screen.
    • Press 'j' to capture on image. Press 'q' to quit.
    • Press '1' to start video recording. Press '0' to stop recording.

Tips

Boot from USB

Low memory problem in Jetson nano

GPU benchmark

  • Glmark2. Glmark2 is an OpenGL 2.0 and ES 2.0 benchmark. glmark2 is a cross-platform tool that can be used to test the performance of the GPU on both platforms with and without CUDA cores.
    • sudo apt-get install glmark2
  • LuxMark

System monitor

jtop

jtop: The Ultimate Tool for Monitoring NVIDIA Jetson Devices

sudo pip3 install -U jetson-stats
jtop

Tegrastats Utility

nvidia-smi

NVIDIA CUDA Toolkit

  • Install the NVIDIA CUDA Toolkit if you plan to use software that supports GPU acceleration for media processing tasks. Many video transcoding and processing applications can take advantage of CUDA for hardware acceleration.

jetson_clocks, power mode

  • what does jetson_clocks do? the jetson_clocks script disables the DVFS governor and locks the clocks to their maximums as defined by the active nvpmodel power mode. So if your active nvpmodel mode is 10W, jetson_clocks will lock the clocks to their maximums for 10W mode. And if your active nvpmodel is 5W, jetson_clocks will lock the clocks to their maximums for 5W mode.
  • Jetson Nano – Use More Power! nvpmodel
  • Jetson Nano 2GB Developer Kit User Guide
    • Power Consumption. There are two software-defined power modes for the Jetson module. 10W & 5W.

Hardware acceleration

Youtube streaming

Testing video. Resolution is 480p. CPU usage is 30-50%, GPU is 50%.

Temperature: CPU 46C, GPU 43.5C (no fan). CPU 24C, GPU 22C (fan 255 & loud). CPU 29C, GPU 27C (fan 75, quiet).

By default, there is no sound b/c the output is analog by default. See Jetson nano no sound output. On 2GB, assuming you didn’t choose minimal option for OS installation, go to: Sound & Video> PulseAudio Volume Control> Configuration Tab> Built-in Audio: Profile Digital Stereo (HDMI) Output (Leave this as it is) Change the second profile to “off” (default is on Analog).

GStreamer, gst-launch-1.0

  • Jetson Nano + Raspberry Pi Camera
  • Video Decode Examples Using gst-launch-1.0 & PDF version.
  • To test 4K video playback on the NVIDIA Jetson Nano, you can use the GStreamer multimedia framework.
    sudo add-apt-repository universe
    sudo add-apt-repository multiverse
    sudo apt-get update
    sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa \\
       gstreamer1.0-plugins-base gstreamer1.0-plugins-good \\
       gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \\
       gstreamer1.0-libav
    sudo apt-get install libgstreamer1.0-dev \\
       libgstreamer-plugins-base1.0-dev \\
       libgstreamer-plugins-good1.0-dev \\
       libgstreamer-plugins-bad1.0-dev
    
    gst-launch-1.0 filesrc location=<4k-video-file-path> ! \
       qtdemux ! h264parse ! omxh264dec ! nveglglessink -e
    

    Replace <4k-video-file-path> with the path to your 4K video file. Note that the performance of 4K video playback may depend on other factors such as the bitrate of the video, the overall load on the Jetson Nano, and so on

  • SSH connection. Running gst-launch-1.0 in the background and run jtop to see the resource. See also How do I use the nohup command without getting nohup.out?
    ssh [email protected]
    export DISPLAY=:0
    nohup gst-launch-1.0 filesrc location=lg-uhd-LG-Greece-and-Norway.mp4 ! \
      qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e \
      >/dev/null 2>&1 &
    jtop
    
  • Jetson Nano 2GB development kit 4k video play back question. The following is for H.264 Decode (NVIDIA Accelerated Decode).
    gst-launch-1.0 filesrc location=<filename_h264.mp4> ! \
         qtdemux ! queue ! h264parse ! nvv4l2decoder ! nv3dsink -e
    
    gst-launch-1.0 uridecodebin uri=file:///home/nvidia/a.mp4 ! \
         nvvidconv ! 'video/x-raw(memory:NVMM),width=1920,height=1080' ! \
         nvoverlaysink
    
  • mkv file. Playing videos using gstreamer on Jetson Nano
  • GStreamer on Linux
    gst-launch-1.0 filesrc location=vid.mkv ! \
          matroskademux name=dem dem.video_0 ! \
          h265parse ! nvv4l2decoder ! nvvidconv ! \
          video/x-raw ! subtitleoverlay name=sub dem.subtitle_0 ! \
          queue ! sub. sub. ! xvimagesink
    
  • Is "!" the same as "|" ? Ans: No, the "!" and "|" symbols are not the same in the Linux command line. The "!" symbol in a GStreamer pipeline (like in your `gst-launch-1.0` command) is used to separate and link different elements in the pipeline. The "|" symbol, also known as a pipe, is used in the Linux command line to pass the output of one command as input to another¹. This is a form of redirection that is a fundamental part of Unix-like operating systems.

4k test videos

$ exiftool Big_Buck_Bunny_4K_60fps-x265.mkv
ExifTool Version Number         : 11.88
File Name                       : Big_Buck_Bunny_4K_60fps-x265.mkv
Directory                       : .
File Size                       : 7.1 GB
File Modification Date/Time     : 2023:09:14 02:51:04+02:00
File Access Date/Time           : 2023:09:14 02:55:15+02:00
File Inode Change Date/Time     : 2023:09:14 02:54:49+02:00
File Permissions                : rw-r--r--
File Type                       : MKV
File Type Extension             : mkv
MIME Type                       : video/x-matroska
EBML Version                    : 1
EBML Read Version               : 1
Doc Type                        : matroska
Doc Type Version                : 4
Doc Type Read Version           : 2
Timecode Scale                  : 1 ms
Muxing App                      : Lavf60.3.100
Writing App                     : HandBrake 20230319201705-0cbc182b0-master 2023032001
Date/Time Original              : 2023:04:11 22:20:59Z
Duration                        : 0:10:35
Codec ID                        : V_MPEGH/ISO/HEVC
Video Frame Rate                : 60
Image Width                     : 3840
Image Height                    : 2160
Video Codec ID                  : A_AC3
Track Number                    : 3
Track Name                      : Stereo
Track Language                  : und
Track Default                   : No
Audio Codec ID                  : A_MPEG/L3
Track Type                      : Audio
Audio Channels                  : 2
Audio Sample Rate               : 48000
Tag Name                        : DURATION
Tag String                      : 00:10:34.200000000
Image Size                      : 3840x2160
Megapixels                      : 8.3

RTSP output

ffmeg

FFmpeg can be used to play 4K video on the Jetson Nano. The Jetson-FFMpeg project allows you to use FFmpeg on the Jetson Nano via the L4T Multimedia API, supporting hardware-accelerated encoding of H.264 and HEVC.

However, it's important to note that the Jetson Nano doesn't need to use GPU for hardware decoding MPEG2, H.264/AVC, HEVC, VP8 and VP9. These formats are decoded by a specific video hardware decoder (NVDEC) that can be accessed by the L4T Multimedia API².

Here is an example command to play a 4K video using FFmpeg on the Jetson Nano:

ffplay -vcodec h264_nvmpi -i vid.mp4
ffplay -vcodec hevc_nvmpi -i vid.mp4

The `hevc_nvmpi` and `h264_nvmpi` are both hardware-accelerated video encoders provided by NVIDIA, but they are used for different video codecs¹.

  • h264_nvmpi: This is the NVIDIA hardware-assisted H.264 video encoder. H.264, also known as AVC (Advanced Video Coding), is a standard for video compression that is most commonly used to encode high definition video and distribute digital video content²⁵.
  • `hevc_nvmpi`: This encoder is used for the H.265 video codec, also known as HEVC (High Efficiency Video Coding). HEVC is a more recent video compression standard that provides a more efficient compression method than H.264 but with the same level of image quality. It's particularly useful for streaming 4K content over networks like Netflix.
  • In terms of quality and performance, libx264 (a software-based H.264 encoder) might deliver better quality than `h264_nvmpi` for the same bitrate, but `h264_nvmpi` is probably faster and uses less power. The same could be true when comparing a software-based HEVC encoder with `hevc_nvmpi`.

jetson-ffmpeg from github. It supports decoding of VP9 too.

Add keyboard shortcut to launch LX terminal

How To add a shortcut key to the terminal in LXDE?

Add

<!-- Launch LXTerminal with Ctrl+Alt+t-->
    <keybind key="C-A-t">
      <action name="Execute">
        <command>lxterminal</command>
      </action>
    </keybind>

to ~/.config/openbox/lxde-rc.xml

swap

Use as a server

10 Uses for Nvidia Jetson Nano Developer Kit

  • Web server
  • Video Processing and Live Streaming Server
  • Artificial Intelligence / Machine Learning Station
  • NAS
  • Home Media Server (sudo apt-get install kodi)

Alternative OS

https://forums.developer.nvidia.com/t/alternative-os/75649

Armbian

https://www.armbian.com/jetson-nano/. PWM causes kernel 6.1\6.2 to panic, so disabled.

LineageOS

ARES: aurora retro entertainment system

Kodi