IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.64k stars 4.83k forks source link

RealSense D435 drivers for SEEED Studio NVIDIA Jetson ORIN NX 16G -- ModuleNotFoundError: No module named 'pyrealsense2' #13286

Closed monajalal closed 3 months ago

monajalal commented 3 months ago

I have an Intel RealSense D435 camera and want to connect it to SEEED Studio NVIDIA Jetson ORIN NX 16G which we recently bought and flashed it with JetPack 6.0.0 https://wiki.seeedstudio.com/reComputer_J4012_Flash_Jetpack/

I want to be able to connect the camera to the board and get a real-time feed of the RGB image. I cannot find the drivers or an instruction manual stating the steps.

Looking at the following list of camera partner, Intel is not one. So I am curious how people get it working with NVIDIA Jetson boards?

https://developer.nvidia.com/embedded/jetson-partner-supported-cameras?

I do see the FRAMOS D435e camera which is quite similar to Intel RealSense D435 camera however even for that one neither JetPack 6.0.0 nor Jetson ORIN NX 16G is supported.

Please suggest how we could proceed with our goal?

Screenshot from 2024-08-23 11-48-28

MartyG-RealSense commented 3 months ago

Hi @monajalal Official support for JetPack 6.0 was added in the latest 'interim beta' librealsense SDK version 2.56.1.

https://github.com/IntelRealSense/librealsense/wiki/Release-Notes#release-2561-beta

As this is an interim release, the only way to install 2.56.1 at present is to compile it from source code as there are no packages yet.

I would recommend compiling the SDK from source code using the libuvc backend build script, as described in the Jetson source code installation instructions at the link below.

https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md#building-from-source-using-rsusb-backend

monajalal commented 3 months ago

@MartyG-RealSense

am I doing this wrong?

mona@mona:~/librealsense$ git checkout remotes/origin/r/256
HEAD is now at a5c986e04 bump to v2.56.1
mona@mona:~/librealsense$ git branch
* (HEAD detached at origin/r/256)
  master
mona@mona:~/librealsense$ git pull
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>
monajalal commented 3 months ago

@MartyG-RealSense I didn't build from source but at least realsense-viewer worked

I followed here

https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md#building-from-source-using-rsusb-backend

The list of commands I tried

   73  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
   74  sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u
   75  sudo apt-get install librealsense2-utils
   76  sudo apt-get install librealsense2-dev

mona@mona:~/librealsense$ realsense-viewer
 23/08 15:32:04,783 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video0 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video0
 23/08 15:32:04,948 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video1 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video1
 23/08 15:32:04,949 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video2 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video2
 23/08 15:32:04,951 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video3 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video3
 23/08 15:32:04,951 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video4 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video4
 23/08 15:32:04,952 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video5 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video5
 23/08 15:32:05,450 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video0 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video0
 23/08 15:32:05,451 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video1 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video1
 23/08 15:32:05,452 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video2 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video2
 23/08 15:32:05,453 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video3 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video3
 23/08 15:32:05,455 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video4 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video4
 23/08 15:32:05,456 INFO [281473593493568] (backend-v4l2.cpp:753) Enumerating UVC video5 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video5
 23/08 15:32:05,466 INFO [281473593493568] (context.cpp:116) ... /sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video0
 23/08 15:32:05,466 INFO [281473593493568] (context.cpp:128) Found 1 RealSense devices (0xff requested & 0xff from device-mask in settings)

Screenshot from 2024-08-23 15-32-44 Screenshot from 2024-08-23 15-32-34

I now move to trying my Python script and let you know if I face any issue.

monajalal commented 3 months ago

Unfortunately I couldn't get it to work from source

mona@mona:~/librealsense$ ./scripts/libuvc_installation.sh 

+ cd ./librealsense-master
+ echo Install udev-rules
Install udev-rules
+ sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
+ sudo cp config/99-realsense-d4xx-mipi-dfu.rules /etc/udev/rules.d/
+ sudo udevadm control --reload-rules
+ sudo udevadm trigger
+ mkdir build
+ cd build
+ cmake ../ -DFORCE_LIBUVC=true -DBUILD_WITH_CUDA=true -DCMAKE_BUILD_TYPE=release
-- The CXX compiler identification is GNU 9.5.0
-- The C compiler identification is GNU 9.5.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking internet connection...
-- Internet connection identified
CMake Deprecation Warning at CMakeLists.txt:16 (MESSAGE):
  FORCE_LIBUVC, FORCE_WINUSB_UVC and ANDROID_USB_HOST_UVC are deprecated, use
  FORCE_RSUSB_BACKEND instead

-- Info: REALSENSE_VERSION_STRING=2.55.1
-- Setting Unix configurations
-- Info: Building with CUDA requires CMake v3.8+
-- The CUDA compiler identification is unknown
CMake Error at CMake/cuda_config.cmake:3 (enable_language):
  No CMAKE_CUDA_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full
  path to the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  CMake/global_config.cmake:63 (include)
  CMakeLists.txt:46 (global_set_flags)

-- Configuring incomplete, errors occurred!
See also "/home/mona/librealsense_build/librealsense-master/build/CMakeFiles/CMakeOutput.log".
See also "/home/mona/librealsense_build/librealsense-master/build/CMakeFiles/CMakeError.log".

I also changed the last line to

cmake ../ -DFORCE_LIBUVC=true -DBUILD_WITH_CUDA=true -DCMAKE_BUILD_TYPE=release

to include the -DBUILD_WITH_CUDA=true flag for cmake.

Could you please help me with this inquiry?

Checking whether the CUDA compiler is NVIDIA using "" did not match "nvcc: NVIDIA \(R\) Cuda compiler driver":
Checking whether the CUDA compiler is Clang using "" did not match "(clang version)":
Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: CMAKE_CUDA_COMPILER-NOTFOUND
Build flags:
Id flags:  -v

The output was:
No such file or directory

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: CMAKE_CUDA_COMPILER-NOTFOUND
Build flags:
Id flags:  -v

The output was:
No such file or directory

I know I have CUDA since I have run deep learning applications inference using TensorRT about 2 months ago on this Jetson.

CMakeOutput.log

I have attached for you the output log.

It seems it is also not pointing to the correct version despite using git checkout. Could you please help me with that too?

mona@mona:~/librealsense$ git branch -a
* (HEAD detached at origin/r/256)
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/R/2542
  remotes/origin/R/5e/ww07
  remotes/origin/development
  remotes/origin/feature/aus
  remotes/origin/gh-pages
  remotes/origin/jupyter
  remotes/origin/master
  remotes/origin/r/255
  remotes/origin/r/256
  remotes/origin/r/5e/ww12
  remotes/origin/r/5e/ww13
  remotes/origin/r/5e/ww20
  remotes/origin/r/5e/ww23
  remotes/origin/r/5e/ww28
mona@mona:~/librealsense$ nvidia-smi 
Fri Aug 23 16:01:33 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 540.3.0                Driver Version: N/A          CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  Orin (nvgpu)                  N/A  | N/A              N/A |                  N/A |
| N/A   N/A  N/A               N/A /  N/A | Not Supported        |     N/A          N/A |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+
mona@mona:~/librealsense$ uname -a
Linux mona 5.15.136-tegra #1 SMP PREEMPT Wed Jul 3 22:31:57 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
mona@mona:~/librealsense$ lsb_release -a
LSB Version:    core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:    22.04
Codename:   jammy
monajalal commented 3 months ago

so I did remove the cuda flag, and checkout this commit number, and build was successful

-- Set runtime path of "/usr/local/bin/rs-fw-update" to ""
-- Installing: /usr/local/bin/rs-embed
-- Installing: /usr/local/bin/rs-data-collect
-- Set runtime path of "/usr/local/bin/rs-data-collect" to ""
-- Installing: /usr/local/bin/realsense-viewer
-- Set runtime path of "/usr/local/bin/realsense-viewer" to ""
-- Up-to-date: /home/mona/Documents/librealsense2/presets
-- Installing: /home/mona/Documents/librealsense2/presets/sample.preset
-- Installing: /usr/local/bin/rs-depth-quality
-- Set runtime path of "/usr/local/bin/rs-depth-quality" to ""
-- Installing: /usr/local/bin/rs-rosbag-inspector
-- Set runtime path of "/usr/local/bin/rs-rosbag-inspector" to ""
-- Installing: /usr/local/bin/rs-benchmark
-- Set runtime path of "/usr/local/bin/rs-benchmark" to ""
-- Installing: /usr/local/lib/libfw.a
+ echo -e '\e[92m\n\e[1mLibrealsense script completed.\n\e[0m'

Librealsense script completed.

mona@mona:~/librealsense$ ./scripts/libuvc_installation.sh 

mona@mona:~/librealsense$ git checkout a5c986e

However, when I run it, I get this error:

mona@mona:~/librealsense/wrappers/python/examples$ python opencv_viewer_example.py 
Traceback (most recent call last):
  File "/home/mona/librealsense/wrappers/python/examples/opencv_viewer_example.py", line 8, in <module>
    import pyrealsense2 as rs
ModuleNotFoundError: No module named 'pyrealsense2'
mona@mona:~/librealsense/wrappers/python/examples$ git branch
* (HEAD detached at origin/r/256)
  master

Please let me know what you suggest @MartyG-RealSense

Screenshot from 2024-08-23 16-46-59

monajalal commented 3 months ago

I did

  105  sudo apt-get remove  librealsense2-utils
  106  sudo apt-get remove librealsense2-dev

image

But I still see the message regarding multiple versions of rs when I open the $ realsense-viewer. How should that be fixed?

It could be I did cmake twice?

mona@mona:~/librealsense/wrappers/python/examples$ realsense-viewer
 23/08 16:50:32,329 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video0 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video0
 23/08 16:50:32,508 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video1 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video1
 23/08 16:50:32,509 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video2 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video2
 23/08 16:50:32,511 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video3 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video3
 23/08 16:50:32,512 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video4 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video4
 23/08 16:50:32,513 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video5 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video5
 23/08 16:50:33,187 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video0 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video0
 23/08 16:50:33,191 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video1 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video1
 23/08 16:50:33,193 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video2 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video2
 23/08 16:50:33,195 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video3 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video3
 23/08 16:50:33,196 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video4 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video4
 23/08 16:50:33,197 INFO [281473457256512] (backend-v4l2.cpp:753) Enumerating UVC video5 realpath=/sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.3/video4linux/video5
 23/08 16:50:33,236 INFO [281473457256512] (context.cpp:116) ... /sys/devices/platform/bus@0/3610000.usb/usb1/1-2/1-2.1/1-2.1.4/1-2.1.4:1.0/video4linux/video0
 23/08 16:50:33,236 INFO [281473457256512] (context.cpp:128) Found 1 RealSense devices (0xff requested & 0xff from device-mask in settings)

Screenshot from 2024-08-23 16-50-48

MartyG-RealSense commented 3 months ago

The message Multiple realsense udev-rules were found typically occurs when librealsense has been installed from both packages and source code on the same computer, like you did.

This problem can be fixed easily by deleting the rule in the /etc folder from your computer.

/etc/udev/rules.d/99-realsense-libusb.rules

Regarding the pyrealsense2 problem, if you built librealsense from source with libuvc_installation.sh then the pyrealsense2 wrapper will not have been included in the build unless you add the flag -DBUILD_PYTHON_BINDINGS:bool=true to line 46 of the script.

monajalal commented 3 months ago

I have Python 3.10 on Jetson, but I get this cmake error

mona@mona:~$ python
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
mona@mona:~$ which -a python
/usr/bin/python
/bin/python

cmake_python_error

Have you faced this issue?

monajalal commented 3 months ago

I changed line 46 to this still get error

cmake ../ -DFORCE_LIBUVC=true -DCMAKE_BUILD_TYPE=release -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_INCLUDE_DIR=/usr/include/python3.10 -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu

Screenshot from 2024-08-26 18-09-41

mona@mona:~$ which -a python
/usr/bin/python
/bin/python
mona@mona:~$ 
mona@mona:~$ python3.10 -c "import sysconfig; print(sysconfig.get_path('include'))"
/usr/include/python3.10
mona@mona:~$ python3.10 -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"
/usr/lib/aarch64-linux-gnu
monajalal commented 3 months ago

ok, changing that line to the following worked

cmake ../ -DFORCE_LIBUVC=true -DCMAKE_BUILD_TYPE=release -DBUILD_PYTHON_BINDINGS=ON -DPYTHON_INCLUDE_DIR=/usr/include/python3.10 -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu -DPYTHON_EXECUTABLE=/usr/bin/python3.10

monajalal commented 3 months ago

@MartyG-RealSense While the cmake was done successfully with no error, I get an error that there is no pipeline module. Could you please guide me on this?

mona@mona:~/librealsense/wrappers/python/examples$ python opencv_viewer_example.py 
Traceback (most recent call last):
  File "/home/mona/librealsense/wrappers/python/examples/opencv_viewer_example.py", line 13, in <module>
    pipeline = rs.pipeline()
AttributeError: module 'pyrealsense2' has no attribute 'pipeline'
MartyG-RealSense commented 3 months ago

I'm pleased to hear that building the pyrealsense2 wrapper with CMake succeeded for you.

In regard to module 'pyrealsense2' has no attribute 'pipeline', does it work if you change your pyrealsense import line from:

import pyrealsense2 as rs

to:

import pyrealsense2.pyrealsense2 as rs

monajalal commented 3 months ago

@MartyG-RealSense no that doesn't work

mona@mona:~/librealsense/wrappers/python/examples$ python
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrealsense2 as rs
>>> rs.pipeline()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pyrealsense2' has no attribute 'pipeline'
>>> import pyrealsense2.pyrealsense2 as rs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyrealsense2.pyrealsense2'

Also, I cannot find pyrealsense2.so but looks like librealsense2.so is located here

/home/mona/librealsense_build/librealsense-master/build/release/librealsense2.so

I also see these

mona@mona:~/librealsense_build/librealsense-master$ find . -name "*.so"
./build/release/pyrealsense2.cpython-310-aarch64-linux-gnu.so
./build/release/librealsense2-gl.so
./build/release/pyrsutils.cpython-310-aarch64-linux-gnu.so
./build/release/librealsense2.so
mona@mona:~/librealsense_build/librealsense-master/build/release$ ls *.so
lrwxrwxrwx 1 mona mona 47 Aug 26 18:19 pyrsutils.cpython-310-aarch64-linux-gnu.so -> pyrsutils.cpython-310-aarch64-linux-gnu.so.2.55
lrwxrwxrwx 1 mona mona 21 Aug 26 18:30 librealsense2.so -> librealsense2.so.2.55
lrwxrwxrwx 1 mona mona 24 Aug 26 18:32 librealsense2-gl.so -> librealsense2-gl.so.2.55
lrwxrwxrwx 1 mona mona 50 Aug 26 18:36 pyrealsense2.cpython-310-aarch64-linux-gnu.so -> pyrealsense2.cpython-310-aarch64-linux-gnu.so.2.55

It doesn't show 2.56?!

Also, looks related to this issue.

https://github.com/IntelRealSense/librealsense/pull/13079

Please also check my full comment here https://github.com/IntelRealSense/librealsense/pull/13079#issuecomment-2312723332

MartyG-RealSense commented 3 months ago

After your successful method at https://github.com/IntelRealSense/librealsense/pull/13079#issuecomment-2312895097 do you still require assistance with the pipeline attribute problem, please?

monajalal commented 3 months ago

I think the script needs to be fixed so I don't have to do what I have done in that other comment manually but yeah I am all set. Thank you.