The configs are still experimental and not yet final, this is a bunch of random commands that are scattered around in header2's.
We are using the NVidia Jetson Xavier NX Developer Kit for computing.
We can create an SD card image and just reuse that (basically a clone of the entire system)
Resources:
- NVidia official documentation
- NVIDIA Jetson Xavier NX flashing tutorial
- Medium article: The Newbie Guide to Setting Up a Jetson Nano on JP4.4 Part 1: Running Jupyter Lab Headless Using SSH
You must flash it using the SDK manager Jetpack 4.4.1 (for compatibility with the camera).
Here are some official instructions.
-
Download and install Nvidia SDK Manager: https://developer.nvidia.com/nvidia-sdk-manager
-
After installing SDK open SDK Manager from Search
-
Login as a developer.
-
On
Target Hardware
, select the device you want to flash. -
Now change the jetpack version from
Target Operating System
to 4.4.1 -
Press continue.
-
On
step 03
, select Manual Setup. Outside in real world, connect Jetson with SDKs PC using USB cable, and power on the Jetson. Just follow the instruction too.Put jetson in Force Recovery Mode. For carrier board revision A02, these are pins 3 and 4 of J40, which is located near the camera header.
-
After clicking flash, the Jetson begin to initiated OS installation,
-
Put username and password in SDK's PC.
-
In
step 04
just click Finish.
#nodejs
wget https://nodejs.org/dist/v12.21.0/node-v12.21.0-linux-arm64.tar.xz tar
tar -xJf node-v12.21.0-linux-arm64.tar.xz
cd ./node-v12.21.0-linux-arm64 && sudo cp -R * /usr/local/
node -v
npm -v
sudo apt install -y libffi-dev libssl1.0-dev
#sudo apt install -y nodejs npm
sudo -H pip3 install jupyter jupyterlab
sudo jupyter labextension install @jupyter-widgets/jupyterlab-manager
### jupyter remote access:
# on the workstation:sudo -H pip3 install jupyter jupyterlabsudo -H pip3 install jupyter jupyterlab
yes|jupyter notebook --generate-config
yes|jupyter lab --generate-config
echo 'c.NotebookApp.ip = "localhost"
c.ServerApp.allow_remote_access = True' | tee -a ~/.jupyter/jupyter_notebook_config.py ~/.jupyter/jupyter_lab_config.py
# (optional)
jupyter notebook password; jupyter lab password
Be very careful and only install what is needed, be especially careful with OpenCV
, tensorflow
, numpy
, scipy
versions.
To choose TensorFlow version, see compatibility matrix.
# the general stuff
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3 python3-pip
sudo -H pip3 install -U pip testresources setuptools==49.6.0
# working: numpy==1.19.4 scipy==1.5.4
sudo apt install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
sudo -H pip3 install -U numpy==1.19.4 future==0.18.2 mock==3.0.5 h5py==2.10.0 gast==0.2.2 keras_preprocessing==1.1.2 keras_applications==1.0.8 futures protobuf pybind11 scipy==1.4.1
JP_VERSION=44
# check this page for compatibility matrix:
# https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform-release-notes/tf-jetson-rel.html
sudo -H pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v44 tensorflow==2.3.1+nv20.12
sudo apt install -y libcanberra-gtk-module libcanberra-gtk3-module
sudo apt install -y nano qemu-user-static v4l-utils
sudo add-apt-repository universe
sudo add-apt-repository multiverse
sudo apt update
sudo apt install -y 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 install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
gst-inspect-1.0 --version
sudo -H pip3 install -U jetson-stats
sudo nvpmodel -m 2 # setting to 15 watt mode
sudo jetson_clocks # disable throttling
using ssh port forwarding
echo "[daemon]
AutomaticLoginEnable=true
AutomaticLogin=$USER" | sudo tee -a /etc/gdm3/custom.conf/etc/gdm3/custom.conf/etc/gdm3/custom.conf
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
Download the .pem file and the corresponding tunneling file and put them in the home directory (user home, meaning /hom/$USER
and you should see them when you type ls
from home)
Place tunneling.sh in the home directory (~
).
sudo apt install -y autossh
chmod 400 nommas_tunneling.pem
#NOTE: PEM_FILE and AWS_PUBLIC_IP must be changed based on the server
mkdir ~/log
echo "
export PEM_FILE=~/nommas_tunneling.pem
export AWS_PUBLIC_IP=ec2-xxx-xxx-xxx-xxx.xxx.compute.amazonaws.com
cd ~ && sh ~/tunneling.sh >> ~/log/tunneling.sh.log 2>&1 &
(jupyter lab list|grep :8888) || cd ~ && jupyter lab --no-browser --port 8888 >> ~/log/jupyterlab.log 2>&1 &
source /etc/profile &
gsettings set org.gnome.nautilus.preferences executable-text-activation 'launch' & # allow user to execute by double-clicking
export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1
" >> ~/.profile
echo "
sudo nvpmodel -m 2 & # setting to 15 watt mode
sudo jetson_clocks & # disable throttling
" | sudo tee -a /etc/profile
echo '
#!/usr/bin/bash
source ~/.profile &
xdg-open "http://localhost:8888/notebooks/defect_detection/deployment.ipynb" &
' > ~/Desktop/nommas_inspector
sudo chmod +x ~/Desktop/nommas_inspector.sh
put both files in the user's home directory (/home/$USER
)
We are using the e-CAM217_CUMI0234_MOD - Full HD Color Global Shutter Camera Module (1280 x 720)120fps UYVY
For documentation, see the website, the docs in the release packages, and also the emails attached camera_vendor_installation_email.md
# gstreamer command to view what camera sees
/usr/local/ecam_tk1/bin/ecam_tk1_guvcview --device=/dev/video0
To use in python, use the following:
# this works nicely, but to reach high FPS, you must use threaded queues like imutils.video.FileVideoStream
# ~32fps
# autobrightness ON
spec = 'v4l2src device=/dev/video0 ! video/x-raw, format=(string)UYVY, width=(int)1280, height=(int)720, framerate=120/1! nvvidconv ! video/x-raw(memory:NVMM), format=(string)BGRx ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'
# autobrightness OFF (, --aeantibanding=2)
spec = 'v4l2src device=/dev/video0 ! video/x-raw, --aeantibanding=2, format=(string)UYVY, width=(int)1280, height=(int)720, framerate=120/1! nvvidconv ! video/x-raw(memory:NVMM), format=(string)BGRx ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'
cam = cv2.VideoCapture(spec, cv2.CAP_GSTREAMER)
Communicating using USB cable
Try accessing the Jetson's USB IP which should be fixed (different boards have different USB IP addresses)
sudo ssh 192.168.55.1 -l JETSONUSERNAMEHERE
Another way is using minicom
, sudo apt install minicom
, to connect it using the USB on Linux, use:
sudo minicom -D /dev/ttyACM0 -8 -b 115200
(replace /dev/sdX
with proper device, use sudo fdisk -l
to check)
## with compression (takes less space)
# write image from SD card to file
sudo dd if=/dev/sdX conv=sync,noerror bs=64K | gzip -c > ~/backup_image.img.gz
# restore image from file to SD card
sudo gunzip -c ~/backup_image.img.gz | dd of=/dev/sdX bs=64K
## without compression:
# write image from SD card to file
sudo dd bs=32M if=/dev/sdX of="jetson_backup_$(date).img" status=progress
# write image from file to SD card
sudo dd bs=32M if=<jetson_backup>.img of=/dev/sdX status=progress
NOTE: this method should be revised as there are security issues mentioned in this thread. Also possibly we should be using flash.sh
as mentioned here.
# adding swap space
gbswp=20
sudo fallocate -l ${gbswp}G /mnt/${gbswp}GB.swap
sudo chmod 600 /mnt/${gbswp}GB.swap
sudo mkswap /mnt/${gbswp}GB.swap
echo "/mnt/${gbswp}GB.swap swap swap defaults 0 0" | sudo tee -a /etc/fstab
sudo swapon /mnt/${gbswp}GB.swap
## set swapiness
#sudo sh -c 'echo 1 > /proc/sys/vm/swappiness'
- add a
Resources
section - add section on remote access
- add jetson flash instructions
- add opencv threaded camera fetching