From e1bde3bee03878017dbeaa223ab916ec6f188fda Mon Sep 17 00:00:00 2001 From: Sameer Sheorey Date: Fri, 3 Jan 2025 11:08:54 -0800 Subject: [PATCH] Update docs, fix sycl, fix style --- docker/Dockerfile.ci | 34 +++++----- docs/sycl.rst | 82 +++++++++++++----------- python/test/ml_ops/test_voxel_pooling.py | 8 ++- 3 files changed, 67 insertions(+), 57 deletions(-) diff --git a/docker/Dockerfile.ci b/docker/Dockerfile.ci index 2e58e884ebb..c15dabae54a 100755 --- a/docker/Dockerfile.ci +++ b/docker/Dockerfile.ci @@ -19,17 +19,17 @@ ARG PACKAGE ARG BUILD_SYCL_MODULE ARG CI -RUN if [ -z "${DEVELOPER_BUILD}" ]; then echo "Error: ARG DEVELOPER_BUILD not specified."; exit 1; fi \ - && if [ -z "${CCACHE_TAR_NAME}" ]; then echo "Error: ARG CCACHE_TAR_NAME not specified."; exit 1; fi \ - && if [ -z "${CMAKE_VERSION}" ]; then echo "Error: ARG CMAKE_VERSION not specified."; exit 1; fi \ - && if [ -z "${CCACHE_VERSION}" ]; then echo "Error: ARG CCACHE_VERSION not specified."; exit 1; fi \ - && if [ -z "${PYTHON_VERSION}" ]; then echo "Error: ARG PYTHON_VERSION not specified."; exit 1; fi \ - && if [ -z "${BUILD_SHARED_LIBS}" ]; then echo "Error: ARG BUILD_SHARED_LIBS not specified."; exit 1; fi \ - && if [ -z "${BUILD_CUDA_MODULE}" ]; then echo "Error: ARG BUILD_CUDA_MODULE not specified."; exit 1; fi \ - && if [ -z "${BUILD_TENSORFLOW_OPS}" ]; then echo "Error: ARG BUILD_TENSORFLOW_OPS not specified."; exit 1; fi \ - && if [ -z "${BUILD_PYTORCH_OPS}" ]; then echo "Error: ARG BUILD_PYTORCH_OPS not specified."; exit 1; fi \ - && if [ -z "${PACKAGE}" ]; then echo "Error: ARG PACKAGE not specified."; exit 1; fi \ - && if [ -z "${BUILD_SYCL_MODULE}" ]; then echo "Error: ARG BUILD_SYCL_MODULE not specified."; exit 1; fi +RUN if [[ -z "${DEVELOPER_BUILD}" ]]; then echo "Error: ARG DEVELOPER_BUILD not specified."; exit 1; fi \ + && if [[ -z "${CCACHE_TAR_NAME}" ]]; then echo "Error: ARG CCACHE_TAR_NAME not specified."; exit 1; fi \ + && if [[ -z "${CMAKE_VERSION}" ]]; then echo "Error: ARG CMAKE_VERSION not specified."; exit 1; fi \ + && if [[ -z "${CCACHE_VERSION}" ]]; then echo "Error: ARG CCACHE_VERSION not specified."; exit 1; fi \ + && if [[ -z "${PYTHON_VERSION}" ]]; then echo "Error: ARG PYTHON_VERSION not specified."; exit 1; fi \ + && if [[ -z "${BUILD_SHARED_LIBS}" ]]; then echo "Error: ARG BUILD_SHARED_LIBS not specified."; exit 1; fi \ + && if [[ -z "${BUILD_CUDA_MODULE}" ]]; then echo "Error: ARG BUILD_CUDA_MODULE not specified."; exit 1; fi \ + && if [[ -z "${BUILD_TENSORFLOW_OPS}" ]]; then echo "Error: ARG BUILD_TENSORFLOW_OPS not specified."; exit 1; fi \ + && if [[ -z "${BUILD_PYTORCH_OPS}" ]]; then echo "Error: ARG BUILD_PYTORCH_OPS not specified."; exit 1; fi \ + && if [[ -z "${PACKAGE}" ]]; then echo "Error: ARG PACKAGE not specified."; exit 1; fi \ + && if [[ -z "${BUILD_SYCL_MODULE}" ]]; then echo "Error: ARG BUILD_SYCL_MODULE not specified."; exit 1; fi # Fix Nvidia repo key rotation issue # https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212771 @@ -232,9 +232,9 @@ RUN \ && make VERBOSE=1 -j$(nproc) \ && make install-pip-package -j$(nproc) \ && make install -j$(nproc) \ - && if [ "${PACKAGE}" = "ON" ]; then make package; fi \ - && if [ "${PACKAGE}" = "VIEWER" ]; then make package-Open3DViewer-deb; fi \ - && if [ "${CI:-}a" != "a" ]; then rm -rf _deps assimp embree ipp mkl mkl_install webrtc librealsense; fi + && if [[ "${PACKAGE}" = "ON" ]]; then make package; fi \ + && if [[ "${PACKAGE}" = "VIEWER" ]]; then make package-Open3DViewer-deb; fi \ + && if [[ "${CI:-}a" != "a" ]]; then rm -rf _deps assimp embree ipp mkl mkl_install webrtc librealsense; fi # If CI is not null or unset, remove all large build folders to save disk space # Compress ccache folder, move to / directory @@ -244,9 +244,9 @@ RUN ccache -s \ && CCACHE_DIR_PARENT=$(dirname ${CCACHE_DIR}) \ && cd ${CCACHE_DIR_PARENT} \ && tar -caf /${CCACHE_TAR_NAME}.tar.xz ${CCACHE_DIR_NAME} \ - && if [ "${PACKAGE}" = "ON" ]; then mv /root/Open3D/build/package/open3d-devel*.tar.xz /; fi \ - && if [ "${PACKAGE}" = "VIEWER" ]; then mv /root/Open3D/build/package-Open3DViewer-deb/open3d-viewer-*-Linux.deb /; fi \ - && if [ "${BUILD_SYCL_MODULE}" = "ON" && "${BUILD_SHARED_LIBS}" = "ON" ]; then mv /root/Open3D/build/lib/python_package/pip_package/open3d-*.whl /; fi \ + && if [[ "${PACKAGE}" = "ON" ]]; then mv /root/Open3D/build/package/open3d-devel*.tar.xz /; fi \ + && if [[ "${PACKAGE}" = "VIEWER" ]]; then mv /root/Open3D/build/package-Open3DViewer-deb/open3d-viewer-*-Linux.deb /; fi \ + && if [[ "${BUILD_SYCL_MODULE}" = "ON" && "${BUILD_SHARED_LIBS}" = "ON" ]]; then mv /root/Open3D/build/lib/python_package/pip_package/open3d-*.whl /; fi \ && ls -alh / RUN echo "Docker build done." diff --git a/docs/sycl.rst b/docs/sycl.rst index 4e9c20ed446..e17d085f79f 100644 --- a/docs/sycl.rst +++ b/docs/sycl.rst @@ -8,32 +8,22 @@ support. This backend allows Open3D operations to run on many different GPUs, including integrated GPUs and discrete GPUs from Intel, Nvidia and AMD. We provide pre-built C++ binaries and Python 3.10 wheels for Linux (Ubuntu 22.04+). -Note that the binaries only contain kernels compiled to SPIRV IR. At runtime, -they will be JIT compiled to the target device's native ISA. This means that the -first run of a kernel on a new device may be slower than subsequent runs. You -can cache the compiled kernels by setting the environment variable -`SYCL_CACHE_PERSISTENT=1` for subsequent runs. In addition, you can directly -compile for a specific target device using the OPEN3D_SYCL_TARGETS -(`-fsycl-target` compiler option) and OPEN3D_SYCL_TARGET_BACKEND_OPTIONS (`-Xs` -compiler option) CMake variables. See the `compiler documentation -`_ for -information about building for specific hardware. - -Enabled features: +Enabled features ----------------- Many Tensor API operations and Tensor Geometry operations without custom kernels can now be offloaded to SYCL devices. In addition, HW accelerated raycasting -queries in :ref:`RayCastingScene` are also supported. You will get an error if -an operation is not supported. The implementation is tested on Linux on Intel -integrated and discrete GPUs. Currently, a single GPU (`SYCL:0`, if available) -and the CPU (`SYCL:1` if a GPU is available, else `SYCL:0`) are supported. +queries in :py:class:`open3d.t.geometry.RayCastingScene` are also supported. You +will get an error if an operation is not supported. The implementation is tested +on Linux on Intel integrated and discrete GPUs. Currently, a single GPU +(`SYCL:0`, if available) and the CPU (`SYCL:1` if a GPU is available, else +`SYCL:0`) are supported. -Installation: +Installation ------------- -Both C++ binaries and Python wheels can be downloaded from the Open3D GitHub -releases page. For C++, install the `OneAPI runtime +Both C++ binaries and Python wheels (Python 3.10 only for now) can be downloaded +from the Open3D GitHub releases page. For C++, install the `OneAPI runtime `_ and (optionally) SYCL runtime for your `Nvidia `_ or `AMD @@ -46,26 +36,12 @@ libomp5-11`. Make sure to have the `correct drivers installed raycasting on Intel GPUs, you will also need the `intel-level-zero-gpu-raytracing` package. -Building from source: ---------------------- - -You can build the binaries from source as shown below. To build for a different -Python version, set the `PYTHON_VERSION` variable in `docker/docker_build.sh`. - -.. code-block:: shell - - cd docker - ./docker_build.sh sycl-shared - -This will create the Python wheel and C++ binary archive in the current -directory. - - -Usage: +Usage ------ The SYCL backend requires the new CXX11 ABI (Linux, gcc, libstdc++ only). If you -need to use Open3D PyTorch extension, you should use cxx11_abi wheels for PyTorch: +need to use the Open3D PyTorch extension, you should use cxx11_abi wheels for +PyTorch: .. code-block:: shell @@ -79,8 +55,10 @@ emulate support with these environment variables: export IGC_EnableDPEmulation=1 # Enable float64 emulation during compilation export OverrideDefaultFP64Settings=1 # Enable double precision emulation at runtime. -Use this environment variable to cache the JIT compiled kernels to your home -directory: +The binaries only contain kernels compiled to SPIR-V IR. At runtime, they will +be JIT compiled to your target GPU's native ISA. This means that the first run +of a kernel on a new device will be slower than subsequent runs. Use this +environment variable to cache the JIT compiled kernels to your home directory: .. code-block:: shell @@ -118,3 +96,31 @@ SYCL runtime are installed. You can select a specific device with the # Check if a device is available o3d.core.sycl.is_available(o3d.core.Device("SYCL:0")) + + +Building from source +--------------------- + +You can build the binaries from source as shown below. To build for a different +Python version, set the `PYTHON_VERSION` variable in `docker/docker_build.sh`. + +.. code-block:: shell + + cd docker + ./docker_build.sh sycl-shared + +This will create the Python wheel and C++ binary archive in the current +directory. + +You can directly compile for a specific target device (i.e. ahead of time or AOT +compilation) using the OPEN3D_SYCL_TARGETS (`-fsycl-target` compiler option) and +OPEN3D_SYCL_TARGET_BACKEND_OPTIONS (`-Xs` compiler option) CMake variables in +Open3D. See the `compiler documentation +`_ for +information about building for specific hardware. + +if you want to use different settings (e.g. AOT compilation for a specific +device, or build a wheel for a different Python version), you can update the +``docker_build.sh`` script, or build directly on host after installing the +``intel-basekit`` or ``intel-cpp-essentials`` Debian packages from the Intel +OneAPI repository. \ No newline at end of file diff --git a/python/test/ml_ops/test_voxel_pooling.py b/python/test/ml_ops/test_voxel_pooling.py index 2243db9adc5..7fb85366571 100644 --- a/python/test/ml_ops/test_voxel_pooling.py +++ b/python/test/ml_ops/test_voxel_pooling.py @@ -80,7 +80,9 @@ def test_voxel_pooling(ml, pos_dtype, feat_dtype, position_fn, feature_fn): else: index = [1, 0] - np.testing.assert_allclose(ans.pooled_positions, expected_positions[index], rtol=1.1e-7) + np.testing.assert_allclose(ans.pooled_positions, + expected_positions[index], + rtol=1.1e-7) if feature_fn == 'average': if np.issubdtype(feat_dtype, np.integer): @@ -99,7 +101,9 @@ def test_voxel_pooling(ml, pos_dtype, feat_dtype, position_fn, feature_fn): elif feature_fn == 'nearest_neighbor': expected_features = np.array([features[0], features[3]]) - np.testing.assert_allclose(ans.pooled_features, expected_features[index], rtol=1.1e-7) + np.testing.assert_allclose(ans.pooled_features, + expected_features[index], + rtol=1.1e-7) @mltest.parametrize.ml_cpu_only