Skip to content

Commit

Permalink
Add support for python3.11 (#6288)
Browse files Browse the repository at this point in the history
- Add support for python3.11
- Update the linux/mac/windows CI to handle python 3.11
-️ Upgrade pytorch to 2.0.1 with cuda 11.7
- Upgrade tensorflow / tensorboard to 2.13. This needs C++17 (not supported by MSVC 19.29). 
- scipy 1.11.2
- Disable building tensorflow ops on Linux. Keep old cxx11_abi.
- In Open3D-ML companion PR, add instructions to build with new cxx11_abi with tensorflow ops support.
- Set cxx11_abi based on tf / torch ops in ci_utls.sh
- Add env var to control building tf ops and pytorch ops in docker.
---------
Co-authored-by: Sameer Sheorey <[email protected]>
  • Loading branch information
OlivierLDff authored Oct 23, 2023
1 parent 3ddc69b commit a2401d0
Show file tree
Hide file tree
Showing 39 changed files with 264 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'

- name: Install dependencies
env:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Install dependencies
run: |
brew install ccache pkg-config
Expand Down Expand Up @@ -127,16 +127,16 @@ jobs:
fail-fast: false
# 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']
python_version: ['3.8', '3.9', '3.10', '3.11']
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: false
python_version: '3.10'

env:
BUILD_CUDA_MODULE: OFF
Expand Down Expand Up @@ -234,16 +234,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
python_version: ['3.8', '3.9', '3.10', '3.11']
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: false
python_version: '3.10'

env:
OPEN3D_ML_ROOT: ${{ github.workspace }}/Open3D-ML
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'
- name: Install dependencies
run: |
pip install -U clang-format~=10.0.0 yapf==0.30.0 nbformat
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/ubuntu-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ concurrency:

env:
GCE_CLI_GHA_VERSION: '416.0.0' # Fixed to avoid dependency on API changes
BUILD_CUDA_MODULE: 'ON'
BUILD_PYTORCH_OPS: 'ON'
BUILD_TENSORFLOW_OPS: 'OFF' # Turn ON when cxx11_abi is same for TF and PyTorch

jobs:
build-wheel:
Expand All @@ -27,16 +30,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
python_version: ['3.8', '3.9', '3.10', '3.11']
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: false
python_version: '3.10'
env:
DEVELOPER_BUILD: ${{ github.event.inputs.developer_build || 'ON' }}
PYTHON_VERSION: ${{ matrix.python_version }}
Expand All @@ -53,22 +56,22 @@ jobs:
# `docker/docker_build.sh xxx` command to execute locally.
- name: Docker build
run: |
if [ "${{ env.PYTHON_VERSION }}" = "3.7" ] && [ "${{ env.DEVELOPER_BUILD }}" = "ON" ]; then
docker/docker_build.sh cuda_wheel_py37_dev
elif [ "${{ env.PYTHON_VERSION }}" = "3.8" ] && [ "${{ env.DEVELOPER_BUILD }}" = "ON" ]; then
if [ "${{ env.PYTHON_VERSION }}" = "3.8" ] && [ "${{ env.DEVELOPER_BUILD }}" = "ON" ]; then
docker/docker_build.sh cuda_wheel_py38_dev
elif [ "${{ env.PYTHON_VERSION }}" = "3.9" ] && [ "${{ env.DEVELOPER_BUILD }}" = "ON" ]; then
docker/docker_build.sh cuda_wheel_py39_dev
elif [ "${{ env.PYTHON_VERSION }}" = "3.10" ] && [ "${{ env.DEVELOPER_BUILD }}" = "ON" ]; then
docker/docker_build.sh cuda_wheel_py310_dev
elif [ "${{ env.PYTHON_VERSION }}" = "3.7" ] && [ "${{ env.DEVELOPER_BUILD }}" = "OFF" ]; then
docker/docker_build.sh cuda_wheel_py37
elif [ "${{ env.PYTHON_VERSION }}" = "3.11" ] && [ "${{ env.DEVELOPER_BUILD }}" = "ON" ]; then
docker/docker_build.sh cuda_wheel_py311_dev
elif [ "${{ env.PYTHON_VERSION }}" = "3.8" ] && [ "${{ env.DEVELOPER_BUILD }}" = "OFF" ]; then
docker/docker_build.sh cuda_wheel_py38
elif [ "${{ env.PYTHON_VERSION }}" = "3.9" ] && [ "${{ env.DEVELOPER_BUILD }}" = "OFF" ]; then
docker/docker_build.sh cuda_wheel_py39
elif [ "${{ env.PYTHON_VERSION }}" = "3.10" ] && [ "${{ env.DEVELOPER_BUILD }}" = "OFF" ]; then
docker/docker_build.sh cuda_wheel_py310
elif [ "${{ env.PYTHON_VERSION }}" = "3.11" ] && [ "${{ env.DEVELOPER_BUILD }}" = "OFF" ]; then
docker/docker_build.sh cuda_wheel_py311
fi
PIP_PKG_NAME="$(basename ${GITHUB_WORKSPACE}/open3d-[0-9]*.whl)"
PIP_CPU_PKG_NAME="$(basename ${GITHUB_WORKSPACE}/open3d_cpu*.whl)"
Expand Down Expand Up @@ -114,16 +117,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
python_version: ['3.8', '3.9', '3.10', '3.11']
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: false
python_version: '3.10'
env:
OPEN3D_ML_ROOT: ${{ github.workspace }}/Open3D-ML
steps:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
env:
BUILD_SHARED_LIBS: ${{ matrix.BUILD_SHARED_LIBS }}
BUILD_CUDA_MODULE: OFF
BUILD_TENSORFLOW_OPS: ${{ matrix.MLOPS }}
BUILD_PYTORCH_OPS: ${{ matrix.MLOPS }}
DEVELOPER_BUILD: ${{ github.event.inputs.developer_build || 'ON' }}
OPEN3D_CPU_RENDERING: true
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/vtk_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:

Linux:
# TODO: Convert to docker
runs-on: ubuntu-18.04
steps:
- name: Checkout source code
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ concurrency:
cancel-in-progress: true

env:
PIP_VER: "21.1.1"
PIP_VER: "23.2.1"
WHEEL_VER: "0.38.4"
STOOLS_VER: "67.3.2"
PYTEST_VER: "7.1.2"
PYTEST_RANDOMLY_VER: "3.8.0"
SCIPY_VER: "1.7.3"
JEDI_VER: "0.17.2" # https://github.com/ipython/ipython/issues/12740
IDNA_VER: "2.8" # https://github.com/psf/requests/issues/5710
TENSORBOARD_VER: "2.8"
SRC_DIR: "D:\\a\\open3d\\open3d"
BUILD_DIR: "C:\\Open3D\\build"
NPROC: 2
Expand Down Expand Up @@ -101,7 +97,7 @@ jobs:
- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8

- name: Config
# Move build directory to C: https://github.com/actions/virtual-environments/issues/1341
Expand Down Expand Up @@ -246,16 +242,16 @@ jobs:
fail-fast: false
# 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']
python_version: ['3.8', '3.9', '3.10', '3.11']
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: false
python_version: '3.10'

steps:
- name: Checkout source code
Expand Down Expand Up @@ -351,16 +347,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
python_version: ['3.8', '3.9', '3.10', '3.11']
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: false
python_version: '3.10'

steps:
- name: Checkout source code
Expand Down Expand Up @@ -388,10 +384,7 @@ jobs:
python -m pip install --upgrade pip==${{ env.PIP_VER }} `
wheel==${{ env.WHEEL_VER }} `
setuptools==${{ env.STOOLS_VER }}
python -m pip install -U pytest==${{ env.PYTEST_VER }}
python -m pip install -U pytest-randomly==${{ env.PYTEST_RANDOMLY_VER }}
python -m pip install -U scipy==${{ env.SCIPY_VER }} `
tensorboard==${{ env.TENSORBOARD_VER }}
python -m pip install -U -r python/requirements_test.txt
$py_tag=(python -c "import sys; print(f'cp{sys.version_info.major}{sys.version_info.minor}')")
if (Test-Path -Path "pip_package") {
$PIP_PKG_NAME=(Get-ChildItem pip_package\open3d*-$py_tag-*.whl).Name
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ docs/tutorial/**/*.ply
docs/tutorial/**/*.pcd
docs/tutorial/**/*.json
docs/_out/
docs/_build/
docs/python_api/
docs/python_example/
docs/conf.py
Expand Down
45 changes: 35 additions & 10 deletions 3rdparty/cmake/FindPytorch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,43 @@ foreach(lib ${TORCH_LIBRARIES})
endforeach(lib)

# Check if the c++11 ABI is compatible on Linux
if(UNIX AND NOT APPLE AND ((Pytorch_CXX11_ABI AND (NOT GLIBCXX_USE_CXX11_ABI)) OR
(NOT Pytorch_CXX11_ABI AND GLIBCXX_USE_CXX11_ABI)))
if(Pytorch_CXX11_ABI)
set(NEEDED_ABI_FLAG "ON")
if(UNIX AND NOT APPLE)
if((Pytorch_CXX11_ABI AND (NOT GLIBCXX_USE_CXX11_ABI)) OR
(NOT Pytorch_CXX11_ABI AND GLIBCXX_USE_CXX11_ABI))
if(Pytorch_CXX11_ABI)
set(NEEDED_ABI_FLAG "ON")
else()
set(NEEDED_ABI_FLAG "OFF")
endif()
message(FATAL_ERROR "PyTorch and Open3D ABI mismatch: ${Pytorch_CXX11_ABI} != ${GLIBCXX_USE_CXX11_ABI}.\n"
"Please use -DGLIBCXX_USE_CXX11_ABI=${NEEDED_ABI_FLAG} "
"in the cmake config command to change the Open3D ABI.")
else()
set(NEEDED_ABI_FLAG "OFF")
message(STATUS "PyTorch matches Open3D ABI: ${Pytorch_CXX11_ABI} == ${GLIBCXX_USE_CXX11_ABI}")
endif()
message(FATAL_ERROR "PyTorch and Open3D ABI mismatch: ${Pytorch_CXX11_ABI} != ${GLIBCXX_USE_CXX11_ABI}.\n"
"Please use -DGLIBCXX_USE_CXX11_ABI=${NEEDED_ABI_FLAG} "
"in the cmake config command to change the Open3D ABI.")
else()
message(STATUS "PyTorch matches Open3D ABI: ${Pytorch_CXX11_ABI} == ${GLIBCXX_USE_CXX11_ABI}")
endif()

message(STATUS "Pytorch_VERSION: ${Pytorch_VERSION}, CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}")
if (BUILD_PYTORCH_OPS AND BUILD_CUDA_MODULE AND CUDAToolkit_VERSION
VERSION_GREATER_EQUAL "11.0" AND Pytorch_VERSION VERSION_LESS
"1.9")
message(WARNING
"--------------------------------------------------------------------------------\n"
" \n"
" You are compiling PyTorch ops with CUDA 11 with PyTorch version < 1.9. This \n"
" configuration may have stability issues. See \n"
" https://github.com/isl-org/Open3D/issues/3324 and \n"
" https://github.com/pytorch/pytorch/issues/52663 for more information on this \n"
" problem. \n"
" \n"
" We recommend to compile PyTorch from source with compile flags \n"
" '-Xcompiler -fno-gnu-unique' \n"
" \n"
" or use the PyTorch wheels at \n"
" https://github.com/isl-org/open3d_downloads/releases/tag/torch1.8.2 \n"
" \n"
"--------------------------------------------------------------------------------\n"
)
endif()

include(FindPackageHandleStandardArgs)
Expand Down
26 changes: 14 additions & 12 deletions 3rdparty/cmake/FindTensorflow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if(NOT Tensorflow_FOUND)
# Get Tensorflow_FRAMEWORK_LIB
find_library(
Tensorflow_FRAMEWORK_LIB
NAMES tensorflow_framework libtensorflow_framework.so.2
NAMES tensorflow_framework tensorflow_framework.2 libtensorflow_framework.so.2
PATHS "${Tensorflow_LIB_DIR}"
NO_DEFAULT_PATH
)
Expand All @@ -59,21 +59,23 @@ if (UNIX AND NOT APPLE)
endif()

# Check if the c++11 ABI is compatible
if(UNIX AND NOT APPLE AND ((Tensorflow_CXX11_ABI AND (NOT GLIBCXX_USE_CXX11_ABI)) OR
(NOT Tensorflow_CXX11_ABI AND GLIBCXX_USE_CXX11_ABI)))
if(TensorFlow_CXX11_ABI)
set(NEEDED_ABI_FLAG "ON")
if (UNIX AND NOT APPLE)
if(((Tensorflow_CXX11_ABI AND (NOT GLIBCXX_USE_CXX11_ABI)) OR
(NOT Tensorflow_CXX11_ABI AND GLIBCXX_USE_CXX11_ABI)))
if(TensorFlow_CXX11_ABI)
set(NEEDED_ABI_FLAG "ON")
else()
set(NEEDED_ABI_FLAG "OFF")
endif()
message(FATAL_ERROR "TensorFlow and Open3D ABI mismatch: ${Tensorflow_CXX11_ABI} != ${GLIBCXX_USE_CXX11_ABI}.\n"
"Please use -D GLIBCXX_USE_CXX11_ABI=${NEEDED_ABI_FLAG} "
"in the cmake config command to change the Open3D ABI.")
else()
set(NEEDED_ABI_FLAG "OFF")
message(STATUS "TensorFlow matches Open3D ABI: ${Tensorflow_CXX11_ABI} == ${GLIBCXX_USE_CXX11_ABI}")
endif()
message(FATAL_ERROR "TensorFlow and Open3D ABI mismatch: ${Tensorflow_CXX11_ABI} != ${GLIBCXX_USE_CXX11_ABI}.\n"
"Please use -D GLIBCXX_USE_CXX11_ABI=${NEEDED_ABI_FLAG} "
"in the cmake config command to change the Open3D ABI.")
else()
message(STATUS "TensorFlow matches Open3D ABI: ${Tensorflow_CXX11_ABI} == ${GLIBCXX_USE_CXX11_ABI}")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Tensorflow DEFAULT_MSG Tensorflow_INCLUDE_DIR Tensorflow_LIB_DIR
Tensorflow_FRAMEWORK_LIB Tensorflow_DEFINITIONS)
Tensorflow_DEFINITIONS)
4 changes: 2 additions & 2 deletions 3rdparty/pybind11/pybind11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ include(FetchContent)
FetchContent_Declare(
ext_pybind11
PREFIX pybind11
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.6.2.tar.gz
URL_HASH SHA256=8ff2fff22df038f5cd02cea8af56622bc67f5b64534f1b83b9f133b8366acff2
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz
URL_HASH SHA256=d475978da0cdc2d43b73f30910786759d593a9d8ee05b1b6846d1eb16c6d2e0c
DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/pybind11"
)

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/vtk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(WIN32)
endif()

if (APPLE)
set (CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING
set (CMAKE_OSX_DEPLOYMENT_TARGET "12.6" CACHE STRING
"Minimum OS X deployment version" FORCE)
endif()

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Changed TriangleMesh to store materials in a list so they can be accessed by the material index (PR #5938)
* Support multi-threading in the RayCastingScene function to commit scene (PR #6051).
* Fix some bad triangle generation in TriangleMesh::SimplifyQuadricDecimation
* Python 3.11 support. bump pybind11 v2.6.2 -> v2.11.1

## 0.13

Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,14 @@ endif()

# Global flag to set CXX standard.
# This does not affect 3rd party libraries.
if (BUILD_SYCL_MODULE)
# Tensorflow 2.9+ requires cxx_17, but MSVC 19.29 throws errors with C++17
# enabled.
if (BUILD_SYCL_MODULE OR BUILD_TENSORFLOW_OPS)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_EXTENSIONS OFF) # Improved compatibility

# FIXME: Remove this workaround once a fixed Visual Studio 16.10 version is released.
if (BUILD_CUDA_MODULE
Expand Down
Loading

0 comments on commit a2401d0

Please sign in to comment.