Skip to content

MacOS Build with -DBUILD_CUDA_MODULE=OFF: PyBind attempts to link symbol open3d_core_cuda_device_count #7498

@essandess

Description

@essandess

Checklist

Steps to reproduce the issue

I’ve submitted a MacPorts Portfile for Open3D at macports/macports-ports#32787

When building with -DBUILD_CUDA_MODULE=OFF, PyBind attempts to link symbol open3d_core_cuda_device_count, which of course breaks the build.

A temporary fix is in this patch of cpp/pybind/CMakeLists.txt, which simply deletes the incorrect symbol added to pybind.map:

--- ./cpp/pybind/CMakeLists.txt	2026-05-16 00:05:32
+++ ./cpp/pybind/CMakeLists.txt	2026-05-16 06:29:46
@@ -43,6 +43,15 @@
 open3d_set_global_properties(pybind)
 target_link_libraries(pybind PRIVATE Open3D::Open3D)
 
+# symbol open3d_core_cuda_device_count, function defined to return 0
+# target_link_libraries(pybind PRIVATE "${CMAKE_BINARY_DIR}/cpp/open3d/core/CMakeFiles/core.dir/CUDAUtils.cpp.o")
+if(NOT BUILD_CUDA_MODULE)
+    add_custom_command(
+        TARGET pybind PRE_LINK
+        COMMAND sed -i '' '/open3d_core_cuda_device_count/d' "${CMAKE_CURRENT_BINARY_DIR}/pybind.map"
+        COMMENT "Strip CUDA device symbol from pybind.map"
+    )
+endif()
 
 if (WIN32)
     target_link_options(pybind PUBLIC "/force:multiple")

Error message

Symbol `open3d_core_cuda_device_count` not found

Open3D, Python and System information

- Operating system: macOS 26
- Python version: Python 3.14`
- Open3D version: 0.19.0`
- System architecture: arm64
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): clang

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions