2020년 7월 22일 수요일

Jetson Xavier NX - JetPack 4.4(production release) headless setup

First, download SD card image for Xavier NX from https://developer.nvidia.com/embedded/jetpack .
As of July 2020, the latest version is JetPack 4.4. JetPack upgrades to the new version frequently, so always check the latest version on the homepage. Then, use the Etcher tool to create an SD card image. Since this process has a lot of help materials, the explanation is omitted. Etcher supports zip compressed files, so you don't have to decompress it on purpose.

Tips:Xavier NX can be installed with an additional SSD. If you plan to use an SSD together, it is recommended to prepare an SD card with a capacity of 128 GB or more. If you are not using an SSD, you can use an SD card with 32 or 64GB capacity. The reason is that if you use SSD together, you can use a large amount of storage space, so you can install multiple platforms at once. Therefore, it is recommended not to change the SD card with OS as often as possible in order to use the installed system for a long time.
How to use the SD card without replacing it will be explained again later.

Headless Setup

Now insert the SD card into Xavier NX. And before connecting the power, connect the USB cable as shown in the picture. Connect the other end of the USB cable to your PC.
Then connect the Xavier NX's 19V power supply. When Xavier NX boots, the device connected to COM3 is shown in the device manager of the PC as shown in the following figure. The COM port number will change depending on your PC.




You can now connect serially using putty. Connect using the COM port number checked in the PC device manager. System Configurationon putty screen as follows. Now follow the instructions on the screen to set up.
I have explained in a previous blog how to do a headless setup on the Jetson Nano. For more information, please refer to this blog.




Serial connection using putty can be used at any time. Therefore, when a monitor, keyboard, etc. are not ready, serial connection using a USB cable is a useful connection method. Once connected, it provides the same console environment as using ssh.

Boot from SSD

Xavier NX can be only booted using eMMC or SD card. There are articles introducing the SSD booting on the Xavier NX and then booting the SSD using a service script that changes the rootfs.
The typical article is https://www.jetsonhacks.com/2020/05/29/jetson-xavier-nx-run-from-ssd/ introduced by JetsonHacks. However, even in this case, the boot does not start from the SSD. After booting the kernel using the SD card, the rootfs are changed to SSD. Therefore, SD card must be used together. It is not a complete SSD boot.

JetsonHacks' Youtube video explains how to use SSDs with Xavier NX



Personally, I think it's a good idea to wait for NVidia to provide SSD bootable firmware. If they don't offer this, I can't help it.

How to set up an SSD

SD cards are not only less stable and less faster than SSDs, but also have less capacity, so let's find a way to properly utilize SSDs.

I plan to use Xavier NX primarily for edge AI computing. And the programming language will mainly use Python. Probably many people are similar to me.

Since the Jetson Nano can only use SD cards, I have created several SD card images and then installed and used the packages needed for a specific purpose on the SD card. For example, the A SD card is used for PyTorch and the B SD card is used for Tensorflow. However, if you want the SSD to take advantage of the large storage capacity, you may prefer to use the Python virtual environment rather than this method.
After creating a Python virtual environment on an SSD, install most of the necessary Python packages in the virtual environment to utilize the SSD efficiently.

1. Power off the Xavier NX and install NVME SSD at the bottom of Xavier NX M.2 slot.


<image from jetsonhacks>


2.Power on the system and format the SSD drive. In my case there's already 3 partitions. I'll delete all existing partitions.

root@XavierNX:~# mkfs.ext4 /dev/nvme0n1
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 31258710 4k blocks and 7815168 inodes
Filesystem UUID: c1726e94-12c1-43bf-bcee-9811970202b8
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done


3. Create a mount point for the drive

So far I've been working mostly in the /usr/local/src directory.
However, in Xavier NX, I plan to mainly work in /home/spypiggy. spypiggy is my username in Xavier NX. I will mount /home/spypiggy directory to ssd and use it. So in the future, most of the work on Xavier NX will be done in /home/spypiggy.


#First, copy the existing files on the /home/spypiggy to /dev/nvme0n1
mount /dev/nvme0n1 /mnt
rsync -avhr /home/spypiggy/.* /mnt
rsync -avhr /home/spypiggy/* /mnt
umount /mnt

#Now mount /dev/nvme0n1 to /home/spypiggy/
mount /dev/nvme0n1 /home/spypiggy/
vim /etc/fstab 
/dev/nvme0n1 /home/spypiggy ext4 defaults 0 1
reboot

#reboot and check the /home/spypiggy directory
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p1  116G   13G   98G  12% /
none            3.5G     0  3.5G   0% /dev
tmpfs           3.8G  4.0K  3.8G   1% /dev/shm
tmpfs           3.8G   20M  3.8G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/nvme0n1    117G   61M  111G   1% /home/spypiggy
tmpfs           778M  8.0K  778M   1% /run/user/120
tmpfs           778M     0  778M   0% /run/user/0

After rebooting, you can see that the /home/spypiggy directory is mounted on /dev/nvme0n1.

Power mode

After installing JetPack 4.4, install htop.
And if you check the system with htop command, it is as follows.



There are only two CPU Cores visible. Xavier NX clearly states that it has 6 cores...
This table shows the power mode that the Xavier NX supports. Mode ID value is from 0 to 4. Mode IDs 3 and 4 operate in a low power mode of 10W. Mode ID 2 is the most powerful with 15W of power and six cores.



The same console command as this is nvpmodel. You can check the current power model using the nvpmodel command.

spypiggy@XavierNX:~$ sudo nvpmodel -q
NV Fan Mode:quiet
NV Power Mode: MODE_10W_2CORE
3

You can see that it is currently mode3. As you can see from the above table, you can change to mode 3 to get the most out of 6 cores.

spypiggy@XavierNX:~$ sudo nvpmodel -m 2
NVPM WARN: patching tpc_pg_mask: (0x1:0x4)
NVPM WARN: patched tpc_pg_mask: 0x4
spypiggy@XavierNX:~$ sudo nvpmodel -q
NV Fan Mode:quiet
NV Power Mode: MODE_15W_6CORE
2

Now run htop and you should see 6 cores.
If you normally use 2 cores and up to 10W of power in Mode ID 3, which is the default mode, and you need to perform machine learning, etc., you can change the mode to 2 for maximum performance.
For reference, since the GPU is used regardless of the Mode ID, the machine learning execution performance, which is highly dependent on the GPU usage, does not depend heavily on the Mode ID.

Wrapping up

So far, we have seen how to install JetPack in Headless mode on Jetson Xavier NX and how to use SSD. Next time, I will look at using the Python virtual environment to utilize SSD effectively.





댓글 없음:

댓글 쓰기