Skip to content

Commit 4eb8865

Browse files
authored
Move to Ubuntu 22.04, build shared libraries by default, simplified (smaller) python package. (#7516)
- This PR simplifies how Open3D is built and packaged: libOpen3D is now a shared library by default, and Python ships a single open3d.pybind DLL instead of separate cpu/cuda variants. __init__.py is much simplified. - BUILD_SHARED_LIBS now defaults to ON - Device strings accept a bare type name (e.g. Device("cuda"), "cpu"), defaulting id to 0, alongside the existing "CUDA:0" form. - 2 stage build: build-lib -> package -> build-wheel. Reduces total builds.
1 parent 53c4ac4 commit 4eb8865

54 files changed

Lines changed: 1552 additions & 574 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ either due to lack of resources or GPU quota exhaustion.
134134

135135
The custom VM image has NVIDIA drivers, `nvidia-container-toolkit` and `docker`
136136
installed. It contains today's date in the name and the image family is set to
137-
`ubuntu-os-docker-gpu-2004-lts`. The latest image from this family is
137+
`ubuntu-os-docker-gpu-2204-lts`. The latest image from this family is
138138
used for running CI.
139139
140140
#### Step 3: GitHub

.github/workflows/macos.yml

100644100755
Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626
BUILD_CUDA_MODULE: OFF
2727

2828
jobs:
29-
MacOS:
29+
build-lib:
3030
permissions:
3131
contents: write # upload
3232
id-token: write
@@ -66,19 +66,30 @@ jobs:
6666

6767
- name: Install dependencies
6868
run: |
69-
brew install ccache glslang spirv-cross
70-
# Fix gfortran not found issue.
71-
brew install gcc
69+
brew install ccache glslang spirv-cross gcc
7270
ln -s $(brew --prefix gcc)/bin/gfortran-* /usr/local/bin/gfortran
7371
7472
ccache -M 2G # See .github/workflows/readme.md for ccache strategy.
7573
- name: Config and build
7674
run: |
7775
PATH=/usr/local/var/homebrew/linked/ccache/libexec:$PATH
7876
ccache -s
77+
export BUILD_PYTHON_MODULE=OFF
7978
./util/run_ci.sh
8079
DEVEL_PKG_NAME="$(basename build/package/open3d-devel-*.tar.xz)"
8180
echo "DEVEL_PKG_NAME=$DEVEL_PKG_NAME" >> $GITHUB_ENV
81+
82+
# Compress build directory for reuse (exclude some large potentially unnecessary files if needed)
83+
# We need 'build' directory.
84+
tar -caf build.tar.xz build
85+
86+
- name: Upload build artifact
87+
if: ${{ matrix.CONFIG == 'OFF' }}
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: open3d-build-${{ matrix.os }}
91+
path: build.tar.xz
92+
retention-days: 1
8293
- name: Build Open3D viewer app
8394
if: ${{ env.BUILD_SHARED_LIBS == 'OFF' }}
8495
run: |
@@ -130,6 +141,7 @@ jobs:
130141
fi
131142
132143
build-wheel:
144+
needs: build-lib
133145
name: Build wheel
134146
permissions:
135147
contents: write # upload
@@ -172,6 +184,14 @@ jobs:
172184
ref: main
173185
path: ${{ env.OPEN3D_ML_ROOT }}
174186

187+
- name: Download build artifact
188+
uses: actions/download-artifact@v4
189+
with:
190+
name: open3d-build-${{ matrix.os }}
191+
192+
- name: Unpack build artifact
193+
run: tar -xf build.tar.xz
194+
175195
- name: Setup cache
176196
uses: actions/cache@v4
177197
with:
@@ -183,8 +203,7 @@ jobs:
183203
# Restore any ccache cache entry, if none for
184204
# ${{ runner.os }}-${{ runner.arch }}-ccache-${{ github.sha }} exists.
185205
# Common prefix will be used so that ccache can be used across commits.
186-
restore-keys: |
187-
${{ runner.os }}-${{ runner.arch }}-ccache
206+
restore-keys: ${{ runner.os }}-${{ runner.arch }}-ccache
188207

189208
- name: Set up Python
190209
uses: actions/setup-python@v5
@@ -202,13 +221,10 @@ jobs:
202221
source util/ci_utils.sh
203222
install_python_dependencies
204223
205-
# Fix macos-14 arm64 runner image issues, see comments in MacOS job.
206-
# brew install gcc is required so that `brew --prefix gcc` resolves;
207-
brew install gcc
208-
ln -s $(brew --prefix gcc)/bin/gfortran-* /usr/local/bin/gfortran
209-
210-
brew install ccache glslang spirv-cross
224+
brew install ccache glslang spirv-cross gcc
211225
ccache -M 2G # See .github/workflows/readme.md for ccache strategy.
226+
# Fix gfortran not found issue
227+
ln -s $(brew --prefix gcc)/bin/gfortran-* /usr/local/bin/gfortran
212228
213229
- name: Config and build wheel
214230
run: |

.github/workflows/ubuntu-cuda.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@ jobs:
5757
fail-fast: false
5858
matrix:
5959
include:
60-
- CI_CONFIG: 2-jammy
61-
- CI_CONFIG: 3-ml-shared-jammy
62-
- CI_CONFIG: 5-ml-noble
60+
- CI_CONFIG: 2-noble
61+
- CI_CONFIG: 3-ml-shared-noble
6362
env:
6463
# Export everything from matrix to be easily used.
6564
# Docker tag and ccache names must be consistent with docker_build.sh
6665
CI_CONFIG : ${{ matrix.CI_CONFIG }}
67-
BUILD_PACKAGE : ${{ contains(fromJson('["3-ml-shared-jammy"]'), matrix.CI_CONFIG) }}
66+
BUILD_PACKAGE : ${{ contains(fromJson('["3-ml-shared-noble"]'), matrix.CI_CONFIG) }}
6867
GCE_INSTANCE_PREFIX: open3d-ci-${{ matrix.CI_CONFIG }}
6968
DOCKER_TAG : open3d-ci:${{ matrix.CI_CONFIG }}
7069
CCACHE_TAR_NAME : open3d-ci-${{ matrix.CI_CONFIG }}

.github/workflows/ubuntu-openblas.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,48 @@ jobs:
3434
- name: Docker test
3535
run: docker/docker_test.sh openblas-amd64-py312-dev
3636

37-
openblas-arm64:
37+
build-lib-arm64:
38+
name: Build Lib ARM64
3839
permissions:
3940
contents: write # Release upload
4041
id-token: write
4142
attestations: write
4243
artifact-metadata: write
4344
runs-on: ubuntu-24.04-arm # latest
45+
env:
46+
DEVELOPER_BUILD: 'ON'
47+
OPEN3D_CPU_RENDERING: true
48+
steps:
49+
- name: Checkout source code
50+
uses: actions/checkout@v4
51+
- name: Maximize build space
52+
run: |
53+
source util/ci_utils.sh
54+
maximize_ubuntu_github_actions_build_space
55+
56+
- name: Docker build lib
57+
run: |
58+
# Use py310 as dummy
59+
docker/docker_build.sh openblas-arm64-py310-dev build-lib
60+
# Image name open3d-ci:openblas-arm64-py310-dev (check valid tag in script)
61+
docker tag open3d-ci:openblas-arm64-py310-dev open3d-lib-arm64:latest
62+
docker save open3d-lib-arm64:latest | gzip > open3d-lib-arm64.tar.gz
63+
64+
- name: Upload Lib Image
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: open3d-lib-arm64
68+
path: open3d-lib-arm64.tar.gz
69+
retention-days: 1
70+
71+
build-wheel-arm64:
72+
name: Build Wheel ARM64
73+
permissions:
74+
contents: write # Release upload
75+
id-token: write
76+
attestations: write
77+
runs-on: ubuntu-24.04-arm
78+
needs: build-lib-arm64
4479
strategy:
4580
fail-fast: false
4681
matrix:
@@ -68,6 +103,15 @@ jobs:
68103
source util/ci_utils.sh
69104
maximize_ubuntu_github_actions_build_space
70105
106+
- name: Download Lib Image
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: open3d-lib-arm64
110+
path: .
111+
112+
- name: Load Lib Image
113+
run: docker load -i open3d-lib-arm64.tar.gz # Restore open3d-lib-arm64:latest
114+
71115
- name: Compute Docker tag for this matrix entry
72116
run: |
73117
# Strip the dot: 3.12 ➜ 312, 3.14 ➜ 314 …
@@ -78,6 +122,7 @@ jobs:
78122
79123
- name: Docker build
80124
run: |
125+
export BASE_IMAGE=open3d-lib-arm64:latest
81126
docker/docker_build.sh "${DOCKER_TAG}"
82127
shopt -s failglob
83128
PIP_PKG_NAME="$(basename ${GITHUB_WORKSPACE}/open3d-[0-9]*.whl)"

.github/workflows/ubuntu-sycl.yml

Lines changed: 91 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ env:
2323
DEVELOPER_BUILD: ${{ github.event.inputs.developer_build || 'ON' }}
2424

2525
jobs:
26-
ubuntu-sycl:
26+
build-lib:
27+
name: Build Lib
2728
permissions:
2829
contents: write # Release upload
2930
id-token: write
@@ -41,39 +42,37 @@ jobs:
4142
run: |
4243
source util/ci_utils.sh
4344
maximize_ubuntu_github_actions_build_space
44-
- name: Docker build
45+
- name: Docker build lib
4546
run: |
47+
# Use py310 as dummy
4648
if [ "${{ matrix.BUILD_SHARED_LIBS }}" = "ON" ]; then
47-
docker/docker_build.sh sycl-shared
49+
docker/docker_build.sh sycl-shared build-lib
50+
docker tag open3d-ci:sycl-shared open3d-lib-sycl-shared:latest
51+
docker save open3d-lib-sycl-shared:latest -o open3d-lib-sycl-shared.tar
52+
xz open3d-lib-sycl-shared.tar
53+
ls -lhs open3d-lib-sycl-shared.tar.xz
4854
else
49-
docker/docker_build.sh sycl-static
50-
fi
51-
- name: Docker test
52-
run: |
53-
du -hs $PWD
54-
if [ "${{ matrix.BUILD_SHARED_LIBS }}" = "ON" ]; then
55-
docker/docker_test.sh sycl-shared
56-
else
57-
docker/docker_test.sh sycl-static
55+
docker/docker_build.sh sycl-static build-lib
56+
# Static build usually doesn't produce wheels or shared libs for python
57+
# But we might need artifacts. For now keep simple.
5858
fi
5959
60-
- name: Generate artifact attestation
60+
- name: Upload Lib Image
6161
if: ${{ matrix.BUILD_SHARED_LIBS == 'ON' }}
62-
uses: actions/attest@v4
62+
uses: actions/upload-artifact@v4
6363
with:
64-
subject-path: |
65-
${{ github.workspace }}/open3d*.whl
66-
${{ github.workspace }}/open3d-devel-*.tar.xz
64+
name: open3d-lib-sycl-shared
65+
path: open3d-lib-sycl-shared.tar.xz
66+
retention-days: 1
6767

68-
- name: Upload Python wheel and C++ binary package to GitHub artifacts
68+
- name: Upload C++ binary package to GitHub artifacts
6969
if: ${{ matrix.BUILD_SHARED_LIBS == 'ON' }}
7070
uses: actions/upload-artifact@v4
7171
with:
72-
name: open3d-sycl-linux-wheel-and-binary
73-
path: |
74-
open3d*.whl
75-
open3d-devel-*.tar.xz
72+
name: open3d-devel-sycl
73+
path: open3d-devel-*.tar.xz
7674
if-no-files-found: error
75+
7776
- name: Update devel release
7877
if: ${{ github.ref == 'refs/heads/main' && matrix.BUILD_SHARED_LIBS == 'ON' }}
7978
env:
@@ -97,3 +96,73 @@ jobs:
9796
if: ${{ github.ref == 'refs/heads/main' }}
9897
run: |
9998
gsutil cp ${GITHUB_WORKSPACE}/open3d-ci-sycl.tar.gz gs://open3d-ci-cache/ || true
99+
100+
build-wheel:
101+
name: Build Wheel
102+
permissions:
103+
contents: write # Release upload
104+
id-token: write
105+
attestations: write
106+
artifact-metadata: write
107+
runs-on: ubuntu-latest
108+
needs: build-lib
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
python_version: ['3.10', '3.11', '3.12', '3.13']
113+
is_main:
114+
- ${{ github.ref == 'refs/heads/main' }}
115+
exclude:
116+
- is_main: false
117+
python_version: '3.10'
118+
- is_main: false
119+
python_version: '3.11'
120+
- is_main: false
121+
python_version: '3.12'
122+
env:
123+
PYTHON_VERSION: ${{ matrix.python_version }}
124+
steps:
125+
- name: Checkout source code
126+
uses: actions/checkout@v4
127+
- name: Maximize build space
128+
run: |
129+
source util/ci_utils.sh
130+
maximize_ubuntu_github_actions_build_space
131+
132+
- name: Download Lib Image
133+
uses: actions/download-artifact@v4
134+
with:
135+
name: open3d-lib-sycl-shared
136+
path: .
137+
138+
- name: Load Lib Image
139+
run: docker load -i open3d-lib-sycl-shared.tar.xz
140+
141+
- name: Docker build
142+
run: |
143+
export BASE_IMAGE=open3d-lib-sycl-shared:latest
144+
145+
# We execute docker buildscript with python version argument.
146+
docker/docker_build.sh sycl-shared py${{ matrix.python_version }}
147+
148+
- name: Generate artifact attestation
149+
uses: actions/attest@v4
150+
with:
151+
subject-path: |
152+
${{ github.workspace }}/open3d*.whl
153+
154+
- name: Upload wheel to GitHub artifacts
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: open3d-sycl-wheel-py${{ matrix.python_version }}
158+
path: open3d*.whl
159+
if-no-files-found: error
160+
161+
- name: Update devel release
162+
if: ${{ github.ref == 'refs/heads/main' }}
163+
env:
164+
GH_TOKEN: ${{ github.token }}
165+
run: |
166+
gh release upload main-devel open3d-*.whl --clobber
167+
gh release view main-devel
168+

0 commit comments

Comments
 (0)