Skip to content

Commit 6bc3e68

Browse files
authored
[misc] Add support of Linux ARM. (#1961)
1 parent a876fdf commit 6bc3e68

File tree

17 files changed

+72
-30
lines changed

17 files changed

+72
-30
lines changed

.github/workflows/generic.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
PYTHON_VERSION: "3.12"
3232
GS_BACKEND: "cpu"
3333
GS_ENABLE_NDARRAY: "1"
34+
- OS: "ubuntu-24.04-arm"
35+
PYTHON_VERSION: "3.12"
36+
GS_BACKEND: "cpu"
37+
GS_ENABLE_NDARRAY: "1"
3438
- OS: "windows-2025"
3539
PYTHON_VERSION: "3.12"
3640
GS_BACKEND: "cpu"
@@ -40,6 +44,10 @@ jobs:
4044
PYTHON_VERSION: "3.12"
4145
GS_BACKEND: "cpu"
4246
GS_ENABLE_NDARRAY: "0"
47+
- OS: "ubuntu-24.04-arm"
48+
PYTHON_VERSION: "3.12"
49+
GS_BACKEND: "cpu"
50+
GS_ENABLE_NDARRAY: "0"
4351
- OS: "windows-2025"
4452
PYTHON_VERSION: "3.12"
4553
GS_BACKEND: "cpu"
@@ -126,8 +134,13 @@ jobs:
126134
black --line-length 120 --check .
127135
128136
- name: Install Genesis
137+
shell: bash
129138
run: |
130-
pip install -e '.[dev]'
139+
PYTHON_DEPS="dev"
140+
if [[ "${{ matrix.OS }}" != 'ubuntu-24.04-arm' ]] ; then
141+
PYTHON_DEPS="${PYTHON_DEPS},usd"
142+
fi
143+
pip install -e ".[${PYTHON_DEPS}]"
131144
132145
- name: Get artifact prefix name
133146
id: artifact_prefix

genesis/engine/mesh.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,7 @@ def tetrahedralize(self, tet_cfg):
155155
"""
156156
Tetrahedralize the mesh.
157157
"""
158-
# Importing pyvista and tetgen are very slow and not used very often. Let's delay import.
159-
import pyvista as pv
160-
import tetgen
161-
162-
pv_obj = pv.PolyData(
163-
self.verts, np.concatenate([np.full((self.faces.shape[0], 1), self.faces.shape[1]), self.faces], axis=1)
164-
)
165-
tet = tetgen.TetGen(pv_obj)
166-
switches = mu.make_tetgen_switches(tet_cfg)
167-
verts, elems = tet.tetrahedralize(switches=switches)
168-
# visualize_tet(tet, pv_obj, show_surface=False, plot_cell_qual=False)
169-
return verts, elems
158+
return mu.tetrahedralize_mesh(self._mesh, tet_cfg)
170159

171160
def particlize(
172161
self,

genesis/ext/pyrender/viewer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from threading import Event, RLock, Semaphore, Thread
1010
from typing import Optional, TYPE_CHECKING
1111

12-
import cv2
1312
import numpy as np
1413
import OpenGL
1514
from OpenGL.GL import *
@@ -1107,6 +1106,9 @@ def _get_save_filename(self, file_exts):
11071106
return filename
11081107

11091108
def _save_image(self):
1109+
# Postpone import of OpenCV at runtime to reduce hard system dependencies
1110+
import cv2
1111+
11101112
filename = self._get_save_filename(["png", "jpg", "gif", "all"])
11111113
if filename is not None:
11121114
self.viewer_flags["save_directory"] = os.path.dirname(filename)

genesis/utils/image_exporter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from concurrent.futures import ThreadPoolExecutor, Executor
44
from functools import partial
55

6-
import cv2
76
import torch
87
import numpy as np
98

@@ -168,6 +167,9 @@ def export_frame_single_camera(
168167
Executor to which I/O bounded jobs (saving to PNG) will be submitted. A local executor will be instantiated
169168
if none is provided.
170169
"""
170+
# Postpone import of OpenCV at runtime to reduce hard system dependencies
171+
import cv2
172+
171173
# Pack frames data for convenience
172174
frame_data = (rgb, depth, segmentation, normal)
173175

genesis/utils/mesh.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import math
55
import os
66
import pickle as pkl
7+
import platform
78
from itertools import chain
89
from functools import lru_cache
910
from pathlib import Path
@@ -981,6 +982,9 @@ def make_tetgen_switches(cfg):
981982

982983

983984
def tetrahedralize_mesh(mesh, tet_cfg):
985+
if platform.machine() == "aarch64":
986+
gs.raise_exception("This method is not support on Linux ARM because 'tetgen' module is crashing.")
987+
984988
# Importing pyvista and tetgen are very slow to import and not used very often. Let's delay import.
985989
import pyvista as pv
986990
import tetgen

genesis/utils/misc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ def get_platform():
183183

184184
def get_device(backend: gs_backend, device_idx: Optional[int] = None):
185185
if backend == gs_backend.cpu:
186-
device_name = cpuinfo.get_cpu_info()["brand_raw"]
186+
cpu_info = cpuinfo.get_cpu_info()
187+
device_name = next(filter(None, map(cpu_info.get, ("brand_raw", "hardware_raw", "vendor_id_raw"))))
187188
total_mem = psutil.virtual_memory().total / 1024**3
188189
device = torch.device("cpu", device_idx)
189190
elif backend == gs_backend.cuda:

genesis/utils/particle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import pickle as pkl
3+
import platform
34
import subprocess
45
import sys
56
import shutil
@@ -83,8 +84,8 @@ def trimesh_to_particles_pbs(mesh, p_size, sampler, pos=(0, 0, 0)):
8384
"""
8485
assert "pbs" in sampler
8586

86-
if gs.platform != "Linux":
87-
gs.raise_exception(f"Physics-based particle sampler '{sampler}' is only supported on Linux.")
87+
if not (gs.platform == "Linux" and platform.machine() == "x86_64"):
88+
gs.raise_exception(f"Physics-based particle sampler '{sampler}' is only supported on Linux x86.")
8889

8990
# compute file name via hashing for caching
9091
ptc_file_path = msu.get_ptc_path(mesh.vertices, mesh.faces, p_size, sampler)

genesis/utils/usda.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
try:
1818
from pxr import Usd, UsdGeom, UsdShade, Sdf
1919
except ImportError as e:
20-
gs.raise_exception_from(
21-
"Failed to import USD dependencies. Try installing Genesis with 'usd' optional dependencies.", e
22-
)
20+
raise ImportError(
21+
"Failed to import USD dependencies. Try installing Genesis with 'usd' optional dependencies."
22+
) from e
2323

2424

2525
cs_encode = {

genesis/vis/camera.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import time
55
from functools import cached_property
66

7-
import cv2
87
import numpy as np
98
import torch
109

@@ -475,6 +474,9 @@ def render(
475474

476475
# Display images if requested and supported
477476
if self._GUI and self._visualizer.has_display:
477+
# Postpone import of OpenCV at runtime to reduce hard system dependencies
478+
import cv2
479+
478480
title = f"Genesis - Camera {self._idx}"
479481
if self._debug:
480482
title += " (debug)"

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
requires-python = ">=3.10,<3.14"
1111
dependencies = [
1212
"psutil",
13-
"gstaichi==3.2.1",
13+
"gstaichi==3.3.0",
1414
"pydantic>=2.11.0",
1515
"numpy>=1.26.4",
1616
"trimesh",
@@ -35,12 +35,12 @@ dependencies = [
3535
"pycollada",
3636
# Used for parsing `.glb` mesh files
3737
"pygltflib==1.16.0",
38-
# Used for parsing `.usd` mesh files
39-
"usd-core<25.11",
4038
# Use by `PBD3DEntity.sample` to tetrahedralize a mesh
41-
"tetgen>=0.6.4",
39+
"tetgen>=0.6.4; platform_machine!='aarch64'",
4240
# Used for some advanced mesh processing such as `skeletonization`
4341
"PyGEL3D",
42+
# Used to convert VTK output to numpy when converting volume to particles for PBS
43+
"vtk",
4444
# Used here and there to load and export images
4545
# * 11.0 dramatically improves performance when exporting images to PNG
4646
"Pillow>11.0",
@@ -116,7 +116,7 @@ render = [
116116
]
117117
usd = [
118118
# Used for parsing `.usd` mesh files
119-
"usd-core",
119+
"usd-core<25.11",
120120
]
121121

122122
[project.scripts]

0 commit comments

Comments
 (0)