Errors encountered while working on Jetson Nano @24/01/2024

need following command for the installation
sudo apt update sudo apt install xrdp sudo systemctl enable xrdp sudo reboot
can also watch this video:
https://youtu.be/P-EZr0zy53g?si=u7MSje0HzjB-W2-T
sudo apt-get install python3-pip
pip3 install virtualenv
python3 -m virtualenv -p python3 env --system-site-packages
source env/bin/activate
python -c 'import cv2; print(cv2.version)'
Create SwapFile:
sudo fallocate -l 4G /var/swapfile
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
sudo bash -c 'echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab’
Reboot your PC: sudo reboot
After rebooting check swap space by using this command: free -h
Install these Dependencies before installing OpenCV:
sudo sh -c "echo '/usr/local/cuda/lib64' >> /etc/ld.so.conf.d/nvidia-tegra.conf“
sudo ldconfig
sudo apt-get install build-essential cmake git unzip pkg-config
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install libgtk2.0-dev libcanberra-gtk*
sudo apt-get install python3-dev python3-numpy python3-pip
sudo apt-get install libxvidcore-dev libx264-dev libgtk-3-dev
sudo apt-get install libtbb2 libtbb-dev libdc1394-22-dev
sudo apt-get install libv4l-dev v4l-utils
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install libavresample-dev libvorbis-dev libxine2-dev
sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev
sudo apt-get install libopenblas-dev libatlas-base-dev libblas-dev
sudo apt-get install liblapack-dev libeigen3-dev gfortran
sudo apt-get install libhdf5-dev protobuf-compiler
sudo apt-get install libprotobuf-dev libgoogle-glog-dev libgflags-dev
Download OpenCV:
cd ~ wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.1.zip
wget -O opencv_[contrib.zip](<https://www.youtube.com/redirect?event=comments&redir_token=QUFFLUhqbUwyT21QanRCc0NEVmszYTVvWXgzbXhzb3hCQXxBQ3Jtc0tsanpNQ0ViN0Vxd21qak1CeTktRjVVYkVJZXVQY1hQS0xwby1GRlI2VG5HSzhfVDYySFVGbUIybnhLX3NTLU1qeldWVlM2dzBvN05RVGVsSmlhS0NKOTI2RTkyNngwZnhxMFh5VDhWM3I5dk52Q21Wdw&q=http%3A%2F%2Fcontrib.zip%2F&stzid=UgzHycXony_VUGL5Alx4AaABAg>) [<https://github.com/opencv/opencv_contrib/archive/4.5.1.zip>](<https://www.youtube.com/redirect?event=comments&redir_token=QUFFLUhqa3UyMmMzX2FBdHp2LTlvT0hCanpKdU1KSGdld3xBQ3Jtc0ttWVdJWkVLLUdCV2dGUDZ3V1dzaXNfRGIyNGc3TDJiWllKWE1oc0hxcHJib0N1dzJ2QjNPX0t3YkNzV3NMcU5FZjRqTUxvLUc0c3JfcGlRZFVwMEFwM2dBRE9VUVFsdmhWWTlBMlowMDhtV3Yza0lLVQ&q=https%3A%2F%2Fgithub.com%2Fopencv%2Fopencv_contrib%2Farchive%2F4.5.1.zip&stzid=UgzHycXony_VUGL5Alx4AaABAg>)
unzip opencv.zip
unzip opencv_contrib.zip
Now rename the directories. Type each command below, one after the other.
mv opencv-4.5.1 opencv mv opencv_contrib-4.5.1 opencv_contrib rm opencv.zip
rm opencv_contrib.zip
Lets build OpenCV now:
cd ~/opencv mkdir build cd build
copy and paste this entire block of commands below into your terminal.
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 -D WITH_OPENCL=OFF -D WITH_CUDA=ON -D CUDA_ARCH_BIN=5.3 -D CUDA_ARCH_PTX="" -D WITH_CUDNN=ON -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D OPENCV_DNN_CUDA=ON -D ENABLE_NEON=ON -D WITH_QT=OFF -D WITH_OPENMP=ON -D WITH_OPENGL=ON -D BUILD_TIFF=ON -D WITH_FFMPEG=ON -D WITH_GSTREAMER=ON -D WITH_TBB=ON -D BUILD_TBB=ON -D BUILD_TESTS=OFF -D WITH_EIGEN=ON -D WITH_V4L=ON -D WITH_LIBV4L=ON -D OPENCV_ENABLE_NONFREE=ON -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=OFF -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_opencv_python3=TRUE -D OPENCV_GENERATE_PKGCONFIG=ON -D BUILD_EXAMPLES=OFF ..
Build OpenCV. This command below will take a long time (around 2 hours), make -j4 # (make then space single dash and then j4)
Finish the install:
cd ~ sudo rm -r /usr/include/opencv4/opencv2 cd ~/opencv/build sudo make install sudo ldconfig make clean sudo apt-get update
Verify OpenCV Installation
#open python3 shell
python3 import cv2 cv2.*version*
Install jtop, a system monitoring software for Jetson Nano.
cd ~ sudo -H pip3 install -U jetson-stats sudo reboot jtop
Test Your Camera on Jetson Nano: Turn on your Jetson Nano. Open a new terminal window, and type:
ls /dev/video0
#csi camera
ls /dev/video* # show you a list of cameras
Take a Photo:
nvgstcapture-1.0 --orientation=2 # for testing CSI camera
nvgstcapture-1.0 --camsrc=0 --cap-dev-node=1
Installing PyTorch on Jetson Nano @25/01/2024
Installing YOLO V8 on Jetson Nano @25/01/2024
pip install ultralytics
1. Flash Jetson Device
Ensure that your Jetson is flashed with Jetpack 4.5, 4.6, or 5.1. You can check you existing with this repository from Jetson Hacks
git clone <https://github.com/jetsonhacks/jetsonUtilities.git>
cd jetsonUtilities
python jetsonInfo.py
2. Run Docker Container
Next, run the Roboflow Inference Server using the accompanying Docker container:
sudo docker run --privileged --net=host --runtime=nvidia \\
--mount source=roboflow,target=/tmp/cache -e NUM_WORKERS=1 \\
roboflow/roboflow-inference-server-jetson-4.6.0:latest
Note: The docker image you need depends on what Jetpack version you are using.
3. Use the Server
You can now use the server to run inference on any of your models. The following command shows the syntax for making a request to the inference API via curl:
base64 -i YOUR_IMAGE.jpg | curl -d @- "<http://localhost:9001/ctpl_grape_detection/1?api_key=4dMfOwWUyLj6kIqiKs44>"
When you send a request for the first time, your model will compile on your Jetson device for 5-10 minutes.