Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

issue in building open3d in jetson orin

Open Nimaro76 opened this issue 1 year ago • 9 comments

Checklist

Steps to reproduce the issue

I first cloned Open3D by: git clone https://github.com/isl-org/Open3D.git cd Open3D Then, I build Open3D (on Ubuntu 22.04, with CUDA 12.2) with: mkdir build cd build cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_CUDA_MODULE=ON make -j$(nproc)

Error message

home/safebot/Open3D/cpp/open3d/core/nns/kernel/L2Select.cuh(57): error #20054-D: dynamic initialization is not supported for a function-scope static __shared__ variable within a __device__/__global__ function
                Pair<T, int> blockMin[kRowsPerBlock * (kBlockSize / kWarpSize)];
                             ^
          detected during:
            instantiation of "void open3d::core::nns::l2SelectMin1<T,TIndex,kRowsPerBlock,kBlockSize>(T *, T *, T *, TIndex *, int, int) [with T=float, TIndex=int32_t, kRowsPerBlock=8, kBlockSize=256]" at line 223
            instantiation of "void open3d::core::nns::runL2SelectMin<T,TIndex>(cudaStream_t, open3d::core::Tensor &, open3d::core::Tensor &, open3d::core::Tensor &, open3d::core::Tensor &, int, int, int) [with T=float, TIndex=int32_t]" at line 191 of /home/safebot/Open3D/cpp/open3d/core/nns/KnnSearchOps.cu
            instantiation of "void open3d::core::nns::KnnSearchCUDAOptimized<T,TIndex,OUTPUT_ALLOCATOR>(const open3d::core::Tensor &, const open3d::core::Tensor &, int, OUTPUT_ALLOCATOR &, open3d::core::Tensor &) [with T=float, TIndex=int32_t, OUTPUT_ALLOCATOR=open3d::core::nns::NeighborSearchAllocator<float, int32_t>]" at line 260 of /home/safebot/Open3D/cpp/open3d/core/nns/KnnSearchOps.cu
            instantiation of "void open3d::core::nns::KnnSearchCUDA<T,TIndex>(const open3d::core::Tensor &, const open3d::core::Tensor &, const open3d::core::Tensor &, const open3d::core::Tensor &, int, open3d::core::Tensor &, open3d::core::Tensor &, open3d::core::Tensor &) [with T=float, TIndex=int32_t]" at line 318 of /home/safebot/Open3D/cpp/open3d/core/nns/KnnSearchOps.cu

Remark: The warnings can be suppressed with "-diag-suppress <warning-number>"

1 error detected in the compilation of "/home/safebot/Open3D/cpp/open3d/core/nns/KnnSearchOps.cu".
make[2]: *** [cpp/open3d/core/CMakeFiles/core.dir/build.make:1294: cpp/open3d/core/CMakeFiles/core.dir/nns/KnnSearchOps.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2060: cpp/open3d/core/CMakeFiles/core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Open3D, Python and System information

- Operating system: Ubuntu 22.04 
- Python version: `3.10.12`
- Open3D version: output from python: `0.18`
- System architecture:   jetson 
- Is this a remote workstation?: no
- How did you install Open3D?: build from source

Additional information

I tried to insdtall open3d from source with build cuda module . I appreciate your help in this regard

Nimaro76 avatar Jul 22 '24 22:07 Nimaro76

I'm having the same issue. There seems to be a compatibility issue with CUDA on ubuntu 22.04. the Build containers also only run on Ubuntu 18 and 20 on x86 systems

edrethardo avatar Dec 18 '24 07:12 edrethardo

I've Fixed the issue works on l4t-pytorch:r36.4.0 with CUDA 12.6 pull the latest version from main 8e43455

apply this patch

diff --git a/cpp/open3d/core/nns/kernel/L2Select.cuh b/cpp/open3d/core/nns/kernel/L2Select.cuh
index 61c37bd0b..e669727a9 100644
--- a/cpp/open3d/core/nns/kernel/L2Select.cuh
+++ b/cpp/open3d/core/nns/kernel/L2Select.cuh
@@ -52,10 +52,10 @@ __global__ void l2SelectMin1(T* productDistances,
                              TIndex* outIndices,
                              int num_points,
                              int dim) {
-    // Each block handles kRowsPerBlock rows of the distances (results)
-    Pair<T, int> threadMin[kRowsPerBlock];
-    __shared__ Pair<T, int> blockMin[kRowsPerBlock * (kBlockSize / kWarpSize)];
+    extern __shared__ char shared_memory[];
+    Pair<T, int>* blockMin = reinterpret_cast<Pair<T, int>*>(shared_memory);
 
+    Pair<T, int> threadMin[kRowsPerBlock];
     T distance[kRowsPerBlock];
 
 #pragma unroll
@@ -64,23 +64,14 @@ __global__ void l2SelectMin1(T* productDistances,
         threadMin[i].v = -1;
     }
 
-    // blockIdx.x: which chunk of rows we are responsible for updating
     int rowStart = blockIdx.x * kRowsPerBlock;
-
-    // FIXME: if we have exact multiples, don't need this
-    bool endRow = (blockIdx.x == gridDim.x - 1);
-
-    if (endRow) {
-        if (num_points % kRowsPerBlock == 0) {
-            endRow = false;
-        }
-    }
+    bool endRow = (blockIdx.x == gridDim.x - 1) && (num_points % kRowsPerBlock != 0);
 
     if (endRow) {
         for (int row = rowStart; row < num_points; ++row) {
             for (int col = threadIdx.x; col < dim; col += blockDim.x) {
                 distance[0] = centroidDistances[col] +
-                              productDistances[row + dim + col];
+                              productDistances[row * dim + col];
 
                 if (distance[0] < threadMin[0].k) {
                     threadMin[0].k = distance[0];
@@ -88,17 +79,14 @@ __global__ void l2SelectMin1(T* productDistances,
                 }
             }
 
-            // Reduce within the block
-            threadMin[0] = blockReduceAll<Pair<T, int>, Min<Pair<T, int>>,
-                                          false, false>(
-                    threadMin[0], Min<Pair<T, int>>(), blockMin);
+            threadMin[0] = blockReduceAll<Pair<T, int>, Min<Pair<T, int>>, false, false>(
+    threadMin[0], Min<Pair<T, int>>(), blockMin);
 
             if (threadIdx.x == 0) {
-                outDistances[row + 0] = threadMin[0].k;
-                outIndices[row + 0] = threadMin[0].v;
+                outDistances[row] = threadMin[0].k;
+                outIndices[row] = threadMin[0].v;
             }
 
-            // so we can use the shared memory again
             __syncthreads();
 
             threadMin[0].k = Limits<T>::getMax();
@@ -110,12 +98,7 @@ __global__ void l2SelectMin1(T* productDistances,
 
 #pragma unroll
             for (int row = 0; row < kRowsPerBlock; ++row) {
-                distance[row] = productDistances[(rowStart + row) * dim + col];
-            }
-
-#pragma unroll
-            for (int row = 0; row < kRowsPerBlock; ++row) {
-                distance[row] = distance[row] + centroidDistance;
+                distance[row] = productDistances[(rowStart + row) * dim + col] + centroidDistance;
             }
 
 #pragma unroll
@@ -127,15 +110,14 @@ __global__ void l2SelectMin1(T* productDistances,
             }
         }
 
-        // Reduce within the block
-        blockReduceAll<kRowsPerBlock, Pair<T, int>, Min<Pair<T, int>>, false,
-                       false>(threadMin, Min<Pair<T, int>>(), blockMin);
+        blockReduceAll<kRowsPerBlock, Pair<T, int>, Min<Pair<T, int>>, false, false>(
+    threadMin, Min<Pair<T, int>>(), blockMin);
 
         if (threadIdx.x == 0) {
 #pragma unroll
             for (int row = 0; row < kRowsPerBlock; ++row) {
-                outDistances[rowStart + row + 0] = threadMin[row].k;
-                outIndices[rowStart + row + 0] = threadMin[row].v;
+                outDistances[rowStart + row] = threadMin[row].k;
+                outIndices[rowStart + row] = threadMin[row].v;
             }
         }
     }

build with

cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DTHRUST_INCLUDE_DIR=/usr/local/cuda/include \
-DTHRUST_VERSION=2.0.5 \
-DBUILD_CUDA_MODULE=ON \
-DBUILD_GUI=OFF \
-DUSE_OPENMP=ON \
-DBUILD_TENSORFLOW_OPS=OFF \
-DBUILD_PYTORCH_OPS=OFF \
-DBUILD_UNIT_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=~/open3d_install \
-DPYTHON_EXECUTABLE=$(which python) \
-DBUILD_PYTHON_MODULE=ON \
-DBUILD_LIBREALSENSE=OFF \
-DUSE_SYSTEM_LIBREALSENSE=OFF \
-DGLIBCXX_USE_CXX11_ABI=ON \
-DCMAKE_CUDA_ARCHITECTURES=87 \
..

edrethardo avatar Dec 18 '24 12:12 edrethardo

Thank you @edrethardo a million times over!! This was the final step in a multi-day effort for me. Following your instructions, I applied the same patch -- I put it on a fork for other's convenience. Also like you, I am setting this up on a new Jetson Orin Nano and am using l4t-pytorch:r36.4.0 as a base image.

My use case required a few changes. First, I am using an Intel RealSense depth camera, so I enabled -DBUILD_LIBREALSENSE=ON. The other major difference in my installation was utilizing pre-built dependencies to avoid lengthy builds where all dependencies were built from source. However, this didn't work for all the dependencies. Specifically, I ran into issues with the following:

  • png: Open3D couldn't find the header file for unzip.h (see related #4883)
  • glfw: Encountered issues related to GLFW_PLATFORM
  • curl: Encountered errors related to OpenSSL

I resolved all of these issues by just building these dependencies from source. Lastly, there were a few flags you specified that I don't think are in the CMakeLists.txt

  • DTHRUST_INCLUDE_DIR and DTHRUST_VERSION: ChatGPT hallucinated these when I was debugging too :)
  • DUSE_OPENMP should be DWITH_OPENMP; it also is enabled by default

Here are the relevant parts of my Dockerfile:

FROM dustynv/l4t-pytorch:r36.4.0

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York
ENV SUDO=command

# Install packages
RUN apt-get update && apt-get install -y \
    # Required by pyrealsense2
    libusb-1.0-0-dev \
    # Required to build Open3D from source
    # https://github.com/isl-org/Open3D/blob/main/util/install_deps_ubuntu.sh
    git xorg-dev libxcb-shm0 libglu1-mesa-dev python3-dev libc++-dev libc++abi-dev \
    libsdl2-dev libxi-dev libtbb-dev libosmesa6-dev libudev-dev autoconf libtool ccache \
    # Open3D 3rd party dependencies
    # These are installed here to avoid needing to build them from source
    libeigen3-dev libglew-dev libtbb-dev libfmt-dev libjsoncpp-dev libjpeg-dev \
    liblzf-dev libassimp-dev libblas-dev libqhull-dev libzmq3-dev  libvtk9-dev \
    && rm -rf /var/lib/apt/lists/*

# =============================================================================

# Install Open3D from source for CUDA support

# Download
# Due to a CUDA Ubuntu 22.04 compatibility issue, we need to apply the patch
# described in https://github.com/isl-org/Open3D/issues/6885
RUN git clone --branch jetson-orin-nano --single-branch https://github.com/henryrobbins/Open3D.git

# Build
RUN cd Open3D \
    && mkdir build \
    && cd build \
    && cmake ../ \
        -DBUILD_CUDA_MODULE=ON \
        -DCMAKE_CUDA_ARCHITECTURES=87 \
        -DBUILD_GUI=OFF \
        -DBUILD_LIBREALSENSE=ON \
        -DUSE_SYSTEM_EIGEN3=ON \
        -DUSE_SYSTEM_GLEW=ON \
        -DUSE_SYSTEM_TBB=ON \
        -DUSE_SYSTEM_FMT=ON \
        -DUSE_SYSTEM_JSONCPP=ON \
        -DUSE_SYSTEM_JPEG=ON \
        -DUSE_SYSTEM_LIBLZF=ON \
        -DUSE_SYSTEM_ASSIMP=ON \
        -DUSE_SYSTEM_BLAS=ON \
        -DUSE_SYSTEM_QHULLCPP=ON \
        -DUSE_SYSTEM_ZEROMQ=ON \
        -DUSE_SYSTEM_VTK=ON \
    && make -j$(nproc) \
    && make install \
    && make python-package

# Install
RUN pip install --ignore-installed /Open3D/build/lib/python_package

I needed to include --ignore-installed due to the following issue, though I think that there are other workarounds.

Installing collected packages: plotly, jupyter-core, blinker, attrs, referencing, flask, jsonschema-specifications, dash, jsonschema, nbformat, open3d
  Attempting uninstall: blinker
    Found existing installation: blinker 1.4
error: uninstall-distutils-installed-package

× Cannot uninstall blinker 1.4
╰─> It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

With this setup, I was able to successfully run o3d.core.cuda.is_available()!

henryrobbins avatar Feb 10 '25 22:02 henryrobbins

Awesome, I‘m glad to hear that the Patch helped someone else.

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: Henry Robbins @.> Sent: Monday, February 10, 2025 11:46:03 PM To: isl-org/Open3D @.> Cc: edrethardo @.>; Mention @.> Subject: Re: [isl-org/Open3D] issue in building open3d in jetson orin (Issue #6885)

Thank you @edrethardohttps://github.com/edrethardo a million times over!! This was the final step in a multi-day effort for me. Following your instructions, I applied the same patch -- I put it on a forkhttps://github.com/henryrobbins/Open3D/tree/jetson-orin-nano for other's convenience. Also like you, I am setting this up on a new Jetson Orin Nano and am using l4t-pytorch:r36.4.0 as a base image.

My use case required a few changes. First, I am using an Intel RealSense depth camera, so I enabled -DBUILD_LIBREALSENSE=ON. The other major difference in my installation was utilizing pre-built dependencies to avoid lengthy builds where all dependencies were built from source. However, this didn't work for all the dependencies. Specifically, I ran into issues with the following:

I resolved all of these issues by just building these dependencies from source. Lastly, there were a few flags you specified that I don't think are in the CMakeLists.txthttps://github.com/henryrobbins/Open3D/blob/jetson-orin-nano/CMakeLists.txt

  • DTHRUST_INCLUDE_DIR and DTHRUST_VERSION: ChatGPT hallucinated these when I was debugging too :)
  • DUSE_OPENMP should be DWITH_OPENMP; it also is enabled by default

Here are the relevant parts of my Dockerfile:

FROM dustynv/l4t-pytorch:r36.4.0

ENV DEBIAN_FRONTEND=noninteractive ENV TZ=America/New_York ENV SUDO=command

Install packages

RUN apt-get update && apt-get install -y
# Required by pyrealsense2 libusb-1.0-0-dev
# Required to build Open3D from source # https://github.com/isl-org/Open3D/blob/main/util/install_deps_ubuntu.sh git xorg-dev libxcb-shm0 libglu1-mesa-dev python3-dev libc++-dev libc++abi-dev
libsdl2-dev libxi-dev libtbb-dev libosmesa6-dev libudev-dev autoconf libtool ccache
# Open3D 3rd party dependencies # These are installed here to avoid needing to build them from source libeigen3-dev libglew-dev libtbb-dev libfmt-dev libjsoncpp-dev libjpeg-dev
liblzf-dev libassimp-dev libblas-dev libqhull-dev libzmq3-dev libvtk9-dev
&& rm -rf /var/lib/apt/lists/*

=============================================================================

Install Open3D from source for CUDA support

Download

Due to a CUDA Ubuntu 22.04 compatibility issue, we need to apply the patch

described in https://github.com/isl-org/Open3D/issues/6885

RUN git clone --branch jetson-orin-nano --single-branch https://github.com/henryrobbins/Open3D.git

Build

RUN cd Open3D
&& mkdir build
&& cd build
&& cmake ../
-DBUILD_CUDA_MODULE=ON
-DCMAKE_CUDA_ARCHITECTURES=87
-DBUILD_GUI=OFF
-DBUILD_LIBREALSENSE=ON
-DUSE_SYSTEM_EIGEN3=ON
-DUSE_SYSTEM_GLEW=ON
-DUSE_SYSTEM_TBB=ON
-DUSE_SYSTEM_FMT=ON
-DUSE_SYSTEM_JSONCPP=ON
-DUSE_SYSTEM_JPEG=ON
-DUSE_SYSTEM_LIBLZF=ON
-DUSE_SYSTEM_ASSIMP=ON
-DUSE_SYSTEM_BLAS=ON
-DUSE_SYSTEM_QHULLCPP=ON
-DUSE_SYSTEM_ZEROMQ=ON
-DUSE_SYSTEM_VTK=ON
&& make -j$(nproc)
&& make install
&& make python-package

Install

RUN pip install --ignore-installed /Open3D/build/lib/python_package

I needed to include --ignore-installed due to the following issue, though I think that there are other workarounds.

Installing collected packages: plotly, jupyter-core, blinker, attrs, referencing, flask, jsonschema-specifications, dash, jsonschema, nbformat, open3d Attempting uninstall: blinker Found existing installation: blinker 1.4 error: uninstall-distutils-installed-package

× Cannot uninstall blinker 1.4 ╰─> It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

With this setup, I was able to successfully run o3d.core.cuda.is_available()!

— Reply to this email directly, view it on GitHubhttps://github.com/isl-org/Open3D/issues/6885#issuecomment-2649426874, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALHDE6CLKXJV6E3YBXSDFCL2PET2XAVCNFSM6AAAAABLJEZ46CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBZGQZDMOBXGQ. You are receiving this because you were mentioned.Message ID: @.***>

edrethardo avatar Feb 11 '25 09:02 edrethardo

ModuleNotFoundError: No module named 'open3d.cpu' after Building Open3D on aarch64

Description

After building Open3D on my ARM64 (aarch64) Ubuntu system on a Jetson Orin with Python 3.10, I encounter an error when attempting to import the Open3D module. The build process completes without any fatal errors, but the module open3d.cpu cannot be found at runtime. I used the fork by @henryrobbins and there seems to be no compilation errors at least on the CPP side.

Steps to Reproduce

  1. Build Open3D:

    # In the Open3D build directory
    removing build/bdist.linux-aarch64/wheel
    pip wheel created at /home/motion/Open3D/build/lib/python_package/pip_package
    [100%] Built target pip-package
    WARNING: Skipping open3d as it is not installed.
    WARNING: Skipping open3d-cpu as it is not installed.
    Defaulting to user installation because normal site-packages is not writeable
    Processing /home/motion/Open3D/build/lib/python_package/pip_package/open3d-0.19.0+c6d474b3-cp310-cp310-manylinux_2_35_aarch64.whl
    
  2. Import Open3D: Run the following command:

    python -c "import open3d; print(open3d.__version__)"
    
  3. Error Output: The command produces the following traceback:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/motion/.local/lib/python3.10/site-packages/open3d/__init__.py", line 101, in <module>
        from open3d.cpu.pybind import (
    ModuleNotFoundError: No module named 'open3d.cpu'
    

Expected Behavior

I expect the command to successfully import Open3D and print its version number.

Actual Behavior

The import fails with a ModuleNotFoundError for open3d.cpu.

Environment

  • OS: Ubuntu (aarch64)
  • Python Version: 3.10
  • Open3D Version: 0.19.0+c6d474b3 (built from source)
  • Installation Path: /home/motion/.local/lib/python3.10/site-packages/open3d/
  • CUDA version: 12.6

Aadityavoru avatar Feb 24 '25 21:02 Aadityavoru

@Aadityavoru Are you installing in conda environment?

mjunsen123 avatar Mar 13 '25 09:03 mjunsen123

@Aadityavoru I am having the same issues as you. Have you found any solutions?

Ishansehgal avatar Mar 14 '25 10:03 Ishansehgal

@mjunsen123 no I am not

Aadityavoru avatar Mar 27 '25 18:03 Aadityavoru

it builds including ubuntu 24.04 jp7: https://github.com/isl-org/Open3D/pull/7240

johnnynunez avatar May 08 '25 15:05 johnnynunez

Error message

home/safebot/Open3D/cpp/open3d/core/nns/kernel/L2Select.cuh(57): error #20054-D: dynamic initialization is not supported for a function-scope static shared variable within a device/global function Pair<T, int> blockMin[kRowsPerBlock * (kBlockSize / kWarpSize)];

There is also a workaround to silence this warning (initially it's a warning which becomes an error due additional flags passed to the compiler):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 354125dc0..bb6a752dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -399,6 +399,7 @@ if(BUILD_CUDA_MODULE)
         message(WARNING "Using --allow-unsupported-compiler flag for nvcc with MSVC 2022. "
         "Set $Env:NVCC_PREPEND_FLAGS='--allow-unsupported-compiler' if nvcc still fails.")
     endif()
+    set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe --diag_suppress=20054")
     if (CMAKE_CUDA_ARCHITECTURES)
         message(STATUS "Building with user-provided CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
     else()

ModuleNotFoundError: No module named 'open3d.cpu' after Building Open3D on aarch64

Description

After building Open3D on my ARM64 (aarch64) Ubuntu system on a Jetson Orin with Python 3.10, I encounter an error when attempting to import the Open3D module. The build process completes without any fatal errors, but the module open3d.cpu cannot be found at runtime. I used the fork by @henryrobbins and there seems to be no compilation errors at least on the CPP side.

Digging into __init__.py shows that it's due to python's inability to load the compiled library. The actual reason resembles this issue. Indeed compiling with BUILD_SHARED_LIBS=ON and then `export LD_PRELOAD="/path/to/libOpen3D.so.." before running python fixes the problem

DmitryYurov avatar Jun 17 '25 14:06 DmitryYurov

https://pypi.jetson-ai-lab.dev/jp6/cu126/open3d/0.19.0

johnnynunez avatar Jun 17 '25 14:06 johnnynunez

@johnnynunez It seems you forgot to upload the whl in that website. Can you upload it as soon as possible?

Brianwind avatar Nov 09 '25 07:11 Brianwind