Skip to content

Commit 25a27d1

Browse files
authored
Support python 311 (#619)
Companion Open3D PR: isl-org/Open3D#6288 - Add support for python3.11. -️ Upgrade pytorch to 2.0.1 with cuda 11.7 - Upgrade tensorflow / tensorboard to 2.13. - Disable building tensorflow ops on Linux. Keep old cxx11_abi. - Update CI to use requirements files instead of manually specified versions. - Add instructions to build with new cxx11_abi with tensorflow ops support.
1 parent c62c4f5 commit 25a27d1

File tree

9 files changed

+167
-155
lines changed

9 files changed

+167
-155
lines changed

.github/workflows/ubuntu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
NPROC: 2
1717
steps:
1818
- name: Checkout source code
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020
- name: Setup cache
2121
uses: actions/cache@v3
2222
with:
@@ -33,7 +33,7 @@ jobs:
3333
- name: Set up Python version
3434
uses: actions/setup-python@v4
3535
with:
36-
python-version: "3.10"
36+
python-version: "3.11"
3737
# Pre-installed packages: https://github.com/actions/runner-images/tree/main/images
3838
- name: Install ccache
3939
run: |

README.md

Lines changed: 107 additions & 93 deletions
Large diffs are not rendered by default.

ci/run_ci.sh

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,42 @@
11
#!/usr/bin/env bash
2-
#
3-
# The following environment variables are required:
4-
# - NPROC
5-
#
6-
TENSORFLOW_VER="2.8.2"
7-
TORCH_GLNX_VER="1.13.1+cpu"
8-
# OPENVINO_DEV_VER="2021.4.2" # Numpy version conflict with TF 2.8.2
9-
PIP_VER="21.1.1"
10-
WHEEL_VER="0.38.4"
11-
STOOLS_VER="67.3.2"
12-
YAPF_VER="0.30.0"
13-
PYTEST_VER="7.1.2"
14-
PYTEST_RANDOMLY_VER="3.8.0"
152

163
set -euo pipefail
174

5+
NPROC=${NPROC:?'env var must be set to number of available CPUs.'}
6+
PIP_VER="23.2.1"
7+
188
echo 1. Prepare the Open3D-ML repo and install dependencies
199
echo
20-
export PATH_TO_OPEN3D_ML=$(pwd)
10+
export PATH_TO_OPEN3D_ML="$PWD"
11+
echo "$PATH_TO_OPEN3D_ML"
2112
# the build system of the main repo expects a master branch. make sure master exists
2213
git checkout -b master || true
23-
python -m pip install -U pip==$PIP_VER \
24-
wheel=="$WHEEL_VER" \
25-
setuptools=="$STOOLS_VER" \
26-
yapf=="$YAPF_VER" \
27-
pytest=="$PYTEST_VER" \
28-
pytest-randomly=="$PYTEST_RANDOMLY_VER"
29-
30-
python -m pip install -r requirements.txt
31-
echo $PATH_TO_OPEN3D_ML
14+
python -m pip install -U pip==$PIP_VER
15+
python -m pip install -r requirements.txt \
16+
-r requirements-torch.txt
17+
# -r requirements-tensorflow.txt # TF disabled on Linux (Open3D PR#6288)
18+
# -r requirements-openvino.txt # Numpy version conflict with TF 2.8.2
3219
cd ..
3320
python -m pip install -U Cython
3421

3522
echo 2. clone Open3D and install dependencies
3623
echo
37-
git clone --recursive --branch master https://github.com/isl-org/Open3D.git
24+
git clone --branch master https://github.com/isl-org/Open3D.git
3825

3926
./Open3D/util/install_deps_ubuntu.sh assume-yes
40-
python -m pip install -U tensorflow-cpu==$TENSORFLOW_VER \
41-
torch==${TORCH_GLNX_VER} --extra-index-url https://download.pytorch.org/whl/cpu/
42-
# openvino-dev=="$OPENVINO_DEV_VER"
27+
python -m pip install -r Open3D/python/requirements.txt \
28+
-r Open3D/python/requirements_style.txt \
29+
-r Open3D/python/requirements_test.txt
4330

4431
echo 3. Configure for bundling the Open3D-ML part
4532
echo
4633
mkdir Open3D/build
4734
pushd Open3D/build
35+
# TF disabled on Linux (Open3D PR#6288)
4836
cmake -DBUNDLE_OPEN3D_ML=ON \
49-
-DOPEN3D_ML_ROOT=$PATH_TO_OPEN3D_ML \
37+
-DOPEN3D_ML_ROOT="${PATH_TO_OPEN3D_ML}" \
5038
-DGLIBCXX_USE_CXX11_ABI=OFF \
51-
-DBUILD_TENSORFLOW_OPS=ON \
39+
-DBUILD_TENSORFLOW_OPS=OFF \
5240
-DBUILD_PYTORCH_OPS=ON \
5341
-DBUILD_GUI=ON \
5442
-DBUILD_UNIT_TESTS=OFF \
@@ -66,12 +54,13 @@ echo
6654
popd
6755
mkdir test_workdir
6856
pushd test_workdir
69-
mv $PATH_TO_OPEN3D_ML/tests .
57+
mv "$PATH_TO_OPEN3D_ML/tests" .
7058
echo Add --randomly-seed=SEED to the test command to reproduce test order.
7159
python -m pytest tests
7260

73-
echo ... now do the same but in dev mode by setting OPEN3D_ML_ROOT
74-
export OPEN3D_ML_ROOT=$PATH_TO_OPEN3D_ML
61+
echo "... now do the same but in dev mode by setting OPEN3D_ML_ROOT"
62+
echo
63+
export OPEN3D_ML_ROOT="$PATH_TO_OPEN3D_ML"
7564
echo Add --randomly-seed=SEED to the test command to reproduce test order.
7665
python -m pytest tests
7766
unset OPEN3D_ML_ROOT

requirements-tensorflow.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
tensorflow~=2.8.4 ; sys_platform != 'darwin' or platform_machine != 'arm64'
2-
tensorflow-macos==2.8.0 ; sys_platform == 'darwin' and platform_machine == 'arm64'
1+
tensorflow~=2.13.0

requirements-torch-cuda.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-f https://download.pytorch.org/whl/torch/
2-
torch==1.13.1+cu116
2+
torch==2.0.1+cu117
33
-f https://download.pytorch.org/whl/torchvision/
4-
torchvision==0.14.1+cu116
4+
torchvision==0.15.2+cu117
55
tensorboard

requirements-torch.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--extra-index-url https://download.pytorch.org/whl/cpu/
2-
torch==1.13.1+cpu ; sys_platform != 'darwin'
3-
torchvision==0.14.1+cpu ; sys_platform != 'darwin'
4-
torch==1.13.1 ; sys_platform == 'darwin'
5-
torchvision==0.14.1 ; sys_platform == 'darwin'
2+
torch==2.0.1+cpu ; sys_platform != 'darwin'
3+
torchvision==0.15.2+cpu ; sys_platform != 'darwin'
4+
torch==2.0.1 ; sys_platform == 'darwin'
5+
torchvision==0.15.2 ; sys_platform == 'darwin'
66
tensorboard

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
addict
22
pillow>=9.3.0
33
matplotlib>=3
4-
numpy>1.15
4+
numpy>1.18
55
pandas>=1.0
66
pyyaml>=5.4.1
77
scikit-learn>=0.21

tests/test_integration.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import os
3+
import open3d as o3d
34

45
if 'PATH_TO_OPEN3D_ML' in os.environ.keys():
56
base = os.environ['PATH_TO_OPEN3D_ML']
@@ -8,6 +9,7 @@
89
# base = '../Open3D-ML'
910

1011

12+
@pytest.mark.skipif("not o3d._build_config['BUILD_PYTORCH_OPS']")
1113
def test_integration_torch():
1214
import torch
1315
import open3d.ml.torch as ml3d
@@ -25,6 +27,7 @@ def test_integration_torch():
2527
print(model)
2628

2729

30+
@pytest.mark.skipif("not o3d._build_config['BUILD_TENSORFLOW_OPS']")
2831
def test_integration_tf():
2932
import tensorflow as tf
3033
import open3d.ml.tf as ml3d
@@ -45,15 +48,10 @@ def test_integration_tf():
4548
def test_integration_openvino():
4649
try:
4750
from openvino.inference_engine import IECore
48-
openvino_available = True
49-
except:
50-
openvino_available = False
51-
52-
if not openvino_available:
51+
except ImportError:
5352
return
5453

55-
from open3d.ml.torch.models import OpenVINOModel
56-
from open3d.ml.tf.models import OpenVINOModel
57-
58-
59-
test_integration_torch()
54+
if o3d._build_config['BUILD_TORCH_OPS']:
55+
from open3d.ml.torch.models import OpenVINOModel
56+
if o3d._build_config['BUILD_TENSORFLOW_OPS']:
57+
from open3d.ml.tf.models import OpenVINOModel

tests/test_models.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import pytest
22
import os
33
import numpy as np
4-
import torch
5-
import tensorflow as tf
4+
import open3d as o3d
5+
try:
6+
import torch
7+
except ImportError:
8+
torch = None
69

710
if 'PATH_TO_OPEN3D_ML' in os.environ.keys():
811
base = os.environ['PATH_TO_OPEN3D_ML']
912
else:
1013
base = '.'
1114

12-
gpus = tf.config.list_physical_devices('GPU')
13-
if gpus:
14-
# Use first GPU and restrict memory growth.
15-
try:
15+
try:
16+
import tensorflow as tf
17+
gpus = tf.config.list_physical_devices('GPU')
18+
if gpus:
19+
# Use first GPU and restrict memory growth.
1620
tf.config.experimental.set_visible_devices(gpus[0], 'GPU')
17-
tf.config.set_memory_growth(gpu[0], True)
18-
except RuntimeError as e:
19-
print(e)
21+
tf.config.set_memory_growth(gpus[0], True)
22+
except RuntimeError as e:
23+
print(e)
24+
except ImportError:
25+
tf = None
2026

2127
try:
2228
from open3d.ml.torch.models import OpenVINOModel
@@ -25,6 +31,7 @@
2531
openvino_available = False
2632

2733

34+
@pytest.mark.skipif("not o3d._build_config['BUILD_PYTORCH_OPS']")
2835
def test_randlanet_torch():
2936
import open3d.ml.torch as ml3d
3037

@@ -66,6 +73,7 @@ def test_randlanet_torch():
6673
assert out.shape == (1, 5000, 10)
6774

6875

76+
@pytest.mark.skipif("not o3d._build_config['BUILD_TENSORFLOW_OPS']")
6977
def test_randlanet_tf():
7078
import open3d.ml.tf as ml3d
7179

@@ -106,6 +114,7 @@ def test_randlanet_tf():
106114
assert np.max(np.abs(ov_out - out)) < 1e-6
107115

108116

117+
@pytest.mark.skipif("not o3d._build_config['BUILD_PYTORCH_OPS']")
109118
def test_kpconv_torch():
110119
import open3d.ml.torch as ml3d
111120

@@ -144,6 +153,7 @@ def test_kpconv_torch():
144153
assert np.max(np.abs(ov_out - out)) < 1e-7
145154

146155

156+
@pytest.mark.skipif("not o3d._build_config['BUILD_TENSORFLOW_OPS']")
147157
def test_kpconv_tf():
148158
import open3d.ml.tf as ml3d
149159

@@ -191,6 +201,7 @@ def test_kpconv_tf():
191201
assert np.max(np.abs(ov_out - out)) < 1e-5
192202

193203

204+
@pytest.mark.skipif("not o3d._build_config['BUILD_PYTORCH_OPS']")
194205
def test_pointpillars_torch():
195206
import open3d.ml.torch as ml3d
196207
from open3d.ml.utils import Config
@@ -225,6 +236,7 @@ def test_pointpillars_torch():
225236
assert torch.max(torch.abs(out - ref)) < 1e-5
226237

227238

239+
@pytest.mark.skipif("not o3d._build_config['BUILD_TENSORFLOW_OPS']")
228240
def test_pointpillars_tf():
229241
import open3d.ml.tf as ml3d
230242
from open3d.ml.utils import Config

0 commit comments

Comments
 (0)