Setting up Orin NX

Reviews and other little ventures that don't quite fit into the other forums
Post Reply
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Setting up Orin NX

Post by Daniel Wee »

To set up NVMe drive:-

1. Install NVMe in the Orin NX. Format it first to be safe.
2. You will need an x86-64 Ubuntu host with a USB C port to transfer the files
3. On the Orin NX, you need to jumper pins 9-10 or turn the REC switch to the ON position
4. On the host, download and install the appropriate SDK Manage debian install package from: https://developer.nvidia.com/sdk-manager
Choose the SDK Manager 2.3.0 Ubuntu .deb version
5. Orin NX will need to be powered up
6. At a later stage, the Orin NX will need to be connected to LAN and it's IP known

In Jetpack 6.2.1
1. 4k mode is not available on HDMI for some reason
2. 40W mode and MAXN Super power mode is also disabled
3. snap has a problem that causes all browsers to fail

With these in mind, we need to fix snap so we can browse first:

Code: Select all

snap download snapd --revision=24724
sudo snap ack snapd_24724.assert
sudo snap install snapd_24724.snap
sudo snap refresh --hold snapd
Browsers - Chromium or Firefox - should work after this.

We will need to set up VNC and we want to do this in headless mode so we will also need to install a dummy driver:
https://developer.nvidia.com/embedded/l ... /vnc-setup
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Setting up Orin NX

Post by Daniel Wee »

Steps:-

1. When installing from SDK Manager - disconnect LAN cable to prevent any downloads first. This includes the option to install Chromium.

2. Immediately after install completes and agreements done, lock kernel files with:-

Code: Select all

sudo apt-mark hold nvidia-l4t-display-kernel nvidia-l4t-kernel nvidia-l4t-kernel-dtbs nvidia-l4t-kernel-headers nvidia-l4t-kernel-oot-headers nvidia-l4t-kernel-oot-modules nvidia-l4t-jetson-io
3. Then handle the browser issue with:-

Code: Select all

snap download snapd --revision=24724
sudo snap ack snapd_24724.assert
sudo snap install snapd_24724.snap
sudo snap refresh --hold snapd
Reboot the system.

4. Deal with the password situation:

Code: Select all

sudo apt install nano
sudo visudo
Add a line after root:

Code: Select all

daniel   ALL=(ALL)  NOPASSWD:ALL
and change the %sudo line to say

Code: Select all

%sudo   ALL=(ALL:ALL) NOPASSWD:ALL
5. Enable VNC by going to Settings->Sharing and enable Remote Login and Remote Desktop.
- in Remote Desktop enable Remote Desktop and Remote Control. Turn on Enable Legacy VNC Protocol.
- Change the password to something more useful
- Install Vino as follows:

Code: Select all

cd /usr/lib/systemd/user/graphical-session.target.wants
sudo ln -s ../vino-server.service ./.
sudo reboot now
VNC should now work.

6. Install sublime text:

Code: Select all

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo tee /etc/apt/keyrings/sublimehq-pub.asc > /dev/null
echo -e 'Types: deb\nURIs: https://download.sublimetext.com/\nSuites: apt/stable/\nSigned-By: /etc/apt/keyrings/sublimehq-pub.asc' | sudo tee /etc/apt/sources.list.d/sublime-text.sources
sudo apt-get update
sudo apt-get install sublime-text
7. Install jtop

Code: Select all

sudo pip3 install -U jetson-stats
sudo systemctl restart jtop
sudo reboot now
Fix jtop for J4012 version:-

Code: Select all

cd ~/Downloads
git clone https://github.com/jetsonhacks/jetson-jtop-patch.git
cd jetson-jtop-patch
chmod +x apply_jtop_fix.sh
./apply_jtop_fix.sh
8. Install opencv with CUDA by downloading install_opencv4.10.0_Jetpack6.1.sh from
https://github.com/AastaNV/JEP/tree/master/script

Code: Select all

wget https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.10.0_Jetpack6.1.sh
Then run.

Code: Select all

bash ./install_opencv4.10.0_Jetpack6.1.sh
This version will have CUDA but requires 'numpy<2' and incompatible with a lot of the other stuff so you may not want to run this. To uninstall:

Code: Select all

cd ./workspace/opencv-4.10.0/release
sudo make uninstall
9. Install rclone for Dropbox transfers:

Code: Select all

sudo apt install rclone
rclone config
Create a new connection with "n" and name it "Dropbox" and select option "9" which should be for dropbox, and then tap through the defaults until it opens a browser to log into Dropbox. After that it should be connected. Copy the files over:-

Code: Select all

mkdir ~/Dropbox
mkdir ~/Dropbox/python
mkdir ~/Dropbox/python/carcounter
rclone cp Dropbox:python/carcounter ~/Dropbox/python/carcounter
If you want to sync changed files from Dropbox to the local directory, use:-

Code: Select all

rclone sync Dropbox:python/carcounter ~/Dropbox/python/carcounter
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Setting up Orin NX

Post by Daniel Wee »

1. Install cusparselt needed for pytorch installation

Code: Select all

curl -OLs https://developer.download.nvidia.com/compute/cusparselt/redist/libcusparse_lt/linux-aarch64/libcusparse_lt-linux-aarch64-0.8.1.1_cuda12-archive.tar.xz
tar xf libcusparse_lt-linux-aarch64-0.8.1.1_cuda12-archive.tar.xz
sudo cp -a libcusparse_lt-linux-aarch64-0.8.1.1_cuda12-archive/include/* /usr/local/cuda/include'
sudo cp -a libcusparse_lt-linux-aarch64-0.8.1.1_cuda12-archive/lib/* /usr/local/cuda/lib64/
rm -rf libcusparse_lt-linux-aarch64-0.8.1.1_cuda12-archive
For more up to date libraries and for other CUDA versions, select the application download from:
https://developer.download.nvidia.com/c ... x-aarch64/

2. Add cuda directory to PATH. Edit ~/.profile and add /usr/local/cuda-12.6/bin to the front of PATH.

Code: Select all

PATH="/usr/local/cuda-12.6/bin:$PATH"
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Setting up Orin NX

Post by Daniel Wee »

Installing PyTorch from the official site - you get CUDA but no easyocr compatility.

Code: Select all

pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126
This works great on Windows 11 but is not compatible with Jetpack 6.2.1 even without easyocr running. It will start and report CUDA available but will crash after a while.

Alternatively, we can try the pre-compiled torch version from:
https://developer.download.nvidia.com/c ... redist/jp/

Code: Select all

wget https://developer.download.nvidia.com/compute/redist/jp/v61/pytorch/torch-2.5.0a0+872d972e41.nv24.08.17622132-cp310-cp310-linux_aarch64.whl
pip3 install torch-2.5.0a0+872d972e41.nv24.08.17622132-cp310-cp310-linux_aarch64.whl
This doesn't seem compatible as importing torch in python leads to an error.

torchvision will also need to be installed but this can only be done from source. Follow the instructions here:-
https://ninjalabo.ai/blogs/jetson_pytorch.html

Code: Select all

sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libopenblas-dev libavcodec-dev libavformat-dev libswscale-dev
git clone --branch release/0.20 https://github.com/pytorch/vision torchvision
cd torchvision
export BUILD_VERSION=0.20.0
pip3 install 'numpy<2'
python3 setup.py install --user # remove --user if installing in virtualenv
For compatibility, a few other libraries will also need to be downgraded to match this version of torch:

Code: Select all

pip3 install opencv-python==4.11.0.86 --force
pip3 install opencv-contrib-python==4.11.0.86 --force
pip3 install 'numpy<2'
At this point, the carcounter.py should mostly be working.
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Setting up Orin NX

Post by Daniel Wee »

easyocr minimally needs to be at 1.6.0 to be compatible with torchvision 0.20.0 which we are using. However, this version also seems to require open-python-headless 4.5.4.60 which is not compatible with opencv-python 4.11.0.86.

The way to get around this problem then is to downgrade opencv-python further to 4.5.4.60 hence:-

Code: Select all

pip3 install opencv-python==4.5.4.60
pip3 install opencv-contrib-python==4.5.4.60
pip3 install easyocr
The latest version of easyocr appears to be 1.7.2 which requires torchvision>=0.5 which should work with torchvision 0.20.0 which we currently use with Jetpack 6.2.1+b38. This should technically work and might be worth exploring.
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Setting up Orin NX

Post by Daniel Wee »

More jtop fixes

If running jtop produces the error:
[WARN] jetson-stats not supported for [L4T 36.4.7]
Please, try: sudo pip3 install -U jetson-stats or
open a Github issue (press CTRL + Click)
Note the L4T version number. Next get the jetpack number:-

Code: Select all

sudo apt-cache show nvidia-jetpack
This may yield several packages. I took the latest which was 6.2.1+b38 which should also be confirmed with:-

Code: Select all

dpkg -l | grep nvidia-jetpack

Code: Select all

cd /usr/local/lib/python3.10/dist-packages/jtop/core
sudo nano jetson_variables.py
Page down to the NVIDIA_JETPACK section and add a line at the top of the section:

Code: Select all

    "36.4.7": "6.2.1+b38",
This should be followed with a restart of the service:

Code: Select all

sudo systemctl daemon-reload
sudo systemctl restart jtop.service
Daniel Wee
Site Admin
Posts: 2456
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Setting up Orin NX

Post by Daniel Wee »

Installing OpenCV with CUDA support

Use the script from:
https://github.com/make2explore/Tutoria ... -Latest.sh

Code: Select all

chmod +x OpenCV-Latest.sh
./OpenCV-Latest.sh
This currently works to install OpenCV 4.13-dev but does not include opencv-python-headless which easyocr requires. If you manually install opencv-python-headless it will install a newer version of numpy which will require downgrading to 'numpy<2'. Otherwise this will break other parts. The problem is that the new OpenCV requires a newer version of numpy.

The idea of compiling OpenCV 4.5.4.60 with CUDA does not work because this version requires CUDA 11 whereas we are running CUDA 12.6 on the Jetpack 6.2.1
Post Reply