diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index f274657b909..af70629366e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -59,7 +59,11 @@ jobs: - name: Install dependencies run: | brew install ccache pkg-config - brew link --force libomp # needed for cmake to find OpenMP + # Install libomp 11.1.0 + # https://github.com/microsoft/LightGBM/issues/4229 + brew unlink libomp + wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb + brew install--formula libomp.rb ccache -M 2G # See .github/workflows/readme.md for ccache strategy. - name: Config and build run: | @@ -118,15 +122,15 @@ jobs: # https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6 matrix: python_version: ['3.7', '3.8', '3.9', '3.10'] - # is_master: - # - ${{ github.ref == 'refs/heads/master' }} - # exclude: - # - is_master: false - # python_version: '3.7' - # - is_master: false - # python_version: '3.8' - # - is_master: false - # python_version: '3.9' + is_master: + - ${{ github.ref == 'refs/heads/master' }} + exclude: + - is_master: false + python_version: '3.7' + - is_master: false + python_version: '3.8' + - is_master: false + python_version: '3.9' env: BUILD_CUDA_MODULE: OFF @@ -170,8 +174,12 @@ jobs: cmake --version source util/ci_utils.sh install_python_dependencies + # Install libomp 11.1.0 + # https://github.com/microsoft/LightGBM/issues/4229 brew install ccache - brew link --force libomp # needed for cmake to find OpenMP + brew unlink libomp + wget https://raw.githubusercontent.com/Homebrew/homebrew-core/fb8323f2b170bd4ae97e1bac9bf3e2983af3fdb0/Formula/libomp.rb + brew install --formula libomp.rb ccache -M 2G # See .github/workflows/readme.md for ccache strategy. - name: Config and build wheel diff --git a/cpp/pybind/CMakeLists.txt b/cpp/pybind/CMakeLists.txt index d4cd6e6cab2..454fe3f3216 100644 --- a/cpp/pybind/CMakeLists.txt +++ b/cpp/pybind/CMakeLists.txt @@ -65,9 +65,23 @@ if (BUILD_GUI AND CMAKE_SYSTEM_NAME STREQUAL "Linux") list(APPEND PYTHON_EXTRA_LIBRARIES ${CPP_LIBRARY}.1 ${CPPABI_LIBRARY} ${MESA_CPU_GL_LIBRARY}) endif() +if (WITH_OPENMP AND APPLE) +# Package libomp v11.1.0, if it is not installed. Later version cause crash on +# x86_64 if PyTorch is already imported. +# https://github.com/microsoft/LightGBM/issues/4229 + list(APPEND PYTHON_EXTRA_LIBRARIES ${OpenMP_libomp_LIBRARY}) + file(GENERATE OUTPUT update_pybind_libomp.sh + CONTENT [=[libomp_library=$(dyld_info -dependents "$" | +grep libomp | tr -d '[:space:]') +install_name_tool -change $libomp_library @loader_path/../libomp.dylib \ +"$"]=]) + add_custom_command(TARGET pybind POST_BUILD + COMMAND bash update_pybind_libomp.sh + COMMENT "Updating pybind to use packaged libomp") +endif() # Use `make python-package` to create the python package in the build directory -# The python package will be created at PYTHON_PACKAGE_DIR. It contains: +# The python package will be created at PYTHON_PACKAGE_DST_DIR. It contains: # 1) Pure-python code and misc files, copied from python/package # 2) The compiled python-C++ module, i.e. open3d.so (or the equivalents) # 3) Configured files and supporting files @@ -84,8 +98,8 @@ set(GENERATED_OUTPUTS "") # add additional optional compiled modules if (BUILD_TENSORFLOW_OPS) - list( APPEND COMPILED_MODULE_PATH_LIST $ ) - add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/lib/ml/tf/python/ops/ops.py" + list(APPEND COMPILED_MODULE_PATH_LIST $ ) + add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/lib/ml/tf/python/ops/ops.py" COMMAND ${Python3_EXECUTABLE} generate_tf_ops_wrapper.py --input "${PYTHON_PACKAGE_SRC_DIR}/open3d/ml/tf/python/ops/ops.py.in" --output "${CMAKE_BINARY_DIR}/lib/ml/tf/python/ops/ops.py" --lib $ DEPENDS open3d_tf_ops WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}