Jetson

From 太極
Revision as of 20:06, 28 September 2023 by Brb (talk | contribs) (→‎RTSP output)
Jump to navigation Jump to search

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

  • 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.
    • 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