librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Pyrealsense2 : Can't able to build from source

Open Muthukumar4796 opened this issue 1 year ago • 7 comments

| Camera Model | D455 | | Operating System & Version | Ubuntu 22.04 | | Language | python |

I'm trying to install Pyrealsense 2 by building it from source. However, during the build process, it keeps showing an error.

I have attached the error for your reference.build_error.txt

Muthukumar4796 avatar Feb 08 '24 06:02 Muthukumar4796

Hi @Muthukumar4796 Are you able to compile the librealsense SDK successfully without the pyrealsense2 wrapper? If so then you could afterwards install the wrapper separately from packages instead of source code with the command pip install pyrealsense2

At the time of writing this, the pip install method of installing the wrapper supports Python 3.7 to 3.11 on computers / computing devices with x86 / x64 architecture (such as laptop and desktop PCs) and Python 3.7 to 3,9 on Arm architectured devices (such as Nvidia Jetson and Raspberry Pi).

MartyG-RealSense avatar Feb 08 '24 12:02 MartyG-RealSense

My main goal is to fully build the pyrealsense2 library from source with CUDA on my Ubuntu 22.04 PC, and ensure that it only uses the GPU and not the CPU. If you have any ideas on how to accomplish this, please provide step-by-step instructions.

Muthukumar4796 avatar Feb 08 '24 12:02 Muthukumar4796

CUDA support in the librealsense SDK requires an Nvidia GPU and is enabled by including the flag -DBUILD_WITH_CUDA in the CMake build instruction. It is usually only used with the Nvidia GPU on Nvidia Jetson computing boards though and the few attempts made in the past to use it on an Nvidia equipped PC have not worked..

The only operations that librealsense's CUDA support accelerates are YUY to RGB color conversion, depth-color alignment and point clouds. So if you are not using point clouds or alignment in your project then CUDA will not reduce CPU utilization.

MartyG-RealSense avatar Feb 08 '24 13:02 MartyG-RealSense

I have a laptop with a built-in Nvidia-1650 graphics card that supports CUDA version 12.2. It runs Ubuntu 22.04. However, you mentioned that Nvidia-equipped PCs not work for building pyrealsense2. Therefore, I am unable to build pyrealsense2 for my PC. Could you suggest an alternative method for me to do this?

Muthukumar4796 avatar Feb 08 '24 14:02 Muthukumar4796

PCs with an Nvidia GPU have difficulty enabling librealsense's CUDA support but CUDA is not required for pyrealsense2 and you can build the wrapper on PC without enabling librealsense's CUDA support.

MartyG-RealSense avatar Feb 08 '24 14:02 MartyG-RealSense

Yes but it consumes CPU, and I have another process that requires CPU power.Thats why I tried to build with GPU.

Muthukumar4796 avatar Feb 08 '24 17:02 Muthukumar4796

The librealsense SDK has an alternative to CUDA for offloading work onto the GPU called GLSL processing blocks, and it is 'vendor neutral' meaning that it can work with any GPU brand and not just Nvidia. However, it is meant for use with C++ and so may not be helpful to you if your project requires Python. Please see https://github.com/IntelRealSense/librealsense/pull/3654 for further details about GLSL.

There are not other options than CUDA and GLSL for offloading RealSense processing to the GPU, unfortunately.

MartyG-RealSense avatar Feb 09 '24 09:02 MartyG-RealSense