HKUST-Aerial-Robotics / VINS-Fusion

An optimization-based multi-sensor state estimator
GNU General Public License v3.0
3.32k stars 1.36k forks source link

OutOfMemoryError on Jetson Orin Nano #220

Open Diva-Mio opened 9 months ago

Diva-Mio commented 9 months ago

When I ran use sample command:

    roslaunch vins vins_rviz.launch
    rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml 
    rosbag play MH_01_easy.bag

I got the following error message:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.4) /home/ubuntu/build_opencv/opencv/modules/core/src/alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 369394115439360 bytes in function 'OutOfMemoryError'
Aborted (core dumped)

How can I to solve this problem? My Environment :

  1. Hardware:Jetson Orin Nano 8GB develop kit
  2. OS:Jetpack5.1.1
  3. installed opencv library:libopencv-viz4.2, python3-opencv/focal,now 4.2.0+dfsg-5 arm64
patrickpoirier51 commented 9 months ago

I confirm the same error on a Jetson Xavier NX nvidia-jetpack Version: 5.0.2-b231 ROS Noetic

The error message: OpenCV(4.5.4) /home/ubuntu/build_opencv/opencv/modules/core/src/alloc.cpp:73: is referencing an inexsistant path on the Jetson , I suspect it is a reference to cv-bridge within ROS

I tried different version of OpenCV and built the https://github.com/ros-perception/vision_opencv/tree/noetic vision_opencv with no succes

patrickpoirier51 commented 8 months ago

Just a quick update, Removing refs to JETPACK in sources made it installing standard Opencv 4.2

/etc/apt/sources.list.d/nvidia-l4t-apt-source.list
commented (#) these lines deb https://repo.download.nvidia.com/jetson/common r35.4 main deb https://repo.download.nvidia.com/jetson/t194 r35.4 main

sudo apt update sudo apt install libopencv-dev All 4 .2 libs installed clean

VINS-Fusions build and works @ 15 FPS

otis-XJY commented 7 months ago

I have the same problem in NX. Does it worked out?

patrickpoirier51 commented 7 months ago

I have the same problem in NX. Does it worked out?

Yes

otis-XJY commented 7 months ago

Thank you for your reply. But I'm a little confused

Just a quick update, Removing refs to JETPACK in sources made it installing standard Opencv 4.2

/etc/apt/sources.list.d/nvidia-l4t-apt-source.list commented (#) these lines deb https://repo.download.nvidia.com/jetson/common r35.4 main deb https://repo.download.nvidia.com/jetson/t194 r35.4 main

sudo apt update sudo apt install libopencv-dev All 4 .2 libs installed clean

VINS-Fusions build and works @ 15 FPS

Thank you for your reply. Please forgive my broken English. I'm a little confused about your Opencv version. The error in NX is about opencv4.5.4. But you removed opencv 4.2 and resolve the problem. And how did you remove opencv4.2? just "commented (#) these lines" as you said? Or you did like this sudo apt-get purge libopencv* sudo apt autoremove sudo apt-get update

Diva-Mio commented 7 months ago

https://forums.developer.nvidia.com/t/compiling-opencv-on-jetpack-5/219668

This is a solve about clean opencv4.5.4 and 4.2. I run this .sh after install ROS. It can work for me. BTW it has a few problem between build opencv4.6.0, So you need to search the solution about it.

patrickpoirier51 commented 7 months ago

Yes, you need to purge package. Your apt sequence is good

If you check before purge, with apt list --installed, you will see a mix of 4.2 and 4.5 ; that is the root cause of the problem

After applying the update without JetPack, you can check if all installed packages are 4,2

otis-XJY commented 6 months ago

https://forums.developer.nvidia.com/t/compiling-opencv-on-jetpack-5/219668

This is a solve about clean opencv4.5.4 and 4.2. I run this .sh after install ROS. It can work for me. BTW it has a few problem between build opencv4.6.0, So you need to search the solution about it.

thank you for your advice. but I have installed the opencv4.5.3 with cuda. If I run this .sh, it will remove all the opencv package,right?

Diva-Mio commented 6 months ago

Yes, if you don't want to install opencv 4.6.0 you can modify that file. And install opencv4.5.3 after clean.

otis-XJY commented 6 months ago

Yes, if you don't want to install opencv 4.6.0 you can modify that file. And install opencv4.5.3 after clean.

OK,I see. But I have other project need opencv, so it's a little risky to remove all opencv. I have tried to remove so .so by find /usr/lib/aarch64-linux-gnu -type f -name "*4.5.4*" -exec rm {} \;(my jetpack opencv is 4.5.4) it seem work for me

anandvgeorge commented 3 months ago

I have faced similar issue recently on Jetson Orin. For me the issue was resolved after I built cv_bridge and dependent ROS packages from source, with the same OpenCV version used for compiling VINS-Fusion.