Build from source¶
System requirements¶
C++14 compiler:
Ubuntu 18.04+: GCC 5+, Clang 7+
macOS 10.14+: XCode 8.0+
Windows 10 (64-bit): Visual Studio 2019+
CMake: 3.18+
Ubuntu (18.04 / 20.04):
Install with
apt-get
: see official APT repositoryInstall with
snap
:sudo snap install cmake --classic
Install with
pip
(run inside a Python virtualenv):pip install cmake
macOS: Install with Homebrew:
brew install cmake
Windows: Download from: CMake download page
CUDA (optional): Open3D supports GPU acceleration of an increasing number of operations through CUDA on Linux. We recommend using CUDA 11.0 for the best compatibility with recent GPUs and optional external dependencies such as Tensorflow or PyTorch.
Please see the official documentation to install the CUDA toolkit from Nvidia.
Cloning Open3D¶
Make sure to use the --recursive
flag when cloning Open3D.
git clone --recursive https://github.com/intel-isl/Open3D
# You can also update the submodule manually
git submodule update --init --recursive
Ubuntu/macOS¶
1. Install dependencies¶
# On Ubuntu
util/install_deps_ubuntu.sh
# On macOS: skip this step
2. Setup Python environments¶
Activate the python virtualenv
or Conda environment. Check
which python
to ensure that it shows the desired Python executable.
Alternatively, set the CMake flag -DPYTHON_EXECUTABLE=/path/to/python
to specify the python executable.
If Python binding is not needed, you can turn it off by -DBUILD_PYTHON_MODULE=OFF
.
3. Config¶
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=<open3d_install_directory> ..
The CMAKE_INSTALL_PREFIX
argument is optional and can be used to install
Open3D to a user location. In the absence of this argument Open3D will be
installed to a system location where sudo
is required) For more
options of the build, see Compilation options.
4. Build¶
# On Ubuntu
make -j$(nproc)
# On macOS
make -j$(sysctl -n hw.physicalcpu)
5. Install¶
To install Open3D C++ library:
make install
To link a C++ project against the Open3D C++ library, please refer to Link Open3D in C++ projects.
To install Open3D Python library, build one of the following options:
# Activate the virtualenv first
# Install pip package in the current python environment
make install-pip-package
# Create Python package in build/lib
make python-package
# Create pip wheel in build/lib
# This creates a .whl file that you can install manually.
make pip-package
# Create conda package in build/lib
# This creates a .tar.bz2 file that you can install manually.
make conda-package
Finally, verify the python installation with:
python -c "import open3d"
Windows¶
1. Setup Python binding environments¶
Most steps are the steps for Ubuntu: 2. Setup Python environments.
Instead of which
, check the Python path with where python
.
2. Config¶
mkdir build
cd build
:: Specify the generator based on your Visual Studio version
:: If CMAKE_INSTALL_PREFIX is a system folder, admin access is needed for installation
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="<open3d_install_directory>" ..
3. Build¶
cmake --build . --config Release --target ALL_BUILD
Alternatively, you can open the Open3D.sln
project with Visual Studio and
build the same target.
4. Install¶
To install Open3D C++ library, build the INSTALL
target in terminal or
in Visual Studio.
cmake --build . --config Release --target INSTALL
To link a C++ project against the Open3D C++ library, please refer to Link Open3D in C++ projects.
To install Open3D Python library, build the corresponding python installation targets in terminal or Visual Studio.
:: Activate the virtualenv first
:: Install pip package in the current python environment
cmake --build . --config Release --target install-pip-package
:: Create Python package in build/lib
cmake --build . --config Release --target python-package
:: Create pip package in build/lib
:: This creates a .whl file that you can install manually.
cmake --build . --config Release --target pip-package
:: Create conda package in build/lib
:: This creates a .tar.bz2 file that you can install manually.
cmake --build . --config Release --target conda-package
Finally, verify the Python installation with:
python -c "import open3d; print(open3d)"
Compilation options¶
OpenMP¶
We automatically detect if the C++ compiler supports OpenMP and compile Open3D
with it if the compilation option WITH_OPENMP
is ON
.
OpenMP can greatly accelerate computation on a multi-core CPU.
The default LLVM compiler on OS X does not support OpenMP.
A workaround is to install a C++ compiler with OpenMP support, such as gcc
,
then use it to compile Open3D. For example, starting from a clean build
directory, run
brew install gcc --without-multilib
cmake -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6 ..
make -j
Note
This workaround has some compatibility issues with the source code of
GLFW included in 3rdparty
.
Make sure Open3D is linked against GLFW installed on the OS.
Filament¶
The visualization module depends on the Filament rendering engine and, by default,
Open3D uses a prebuilt version of it. You can also build Filament from source
by setting BUILD_FILAMENT_FROM_SOURCE=ON
.
Note
Whereas Open3D only requires a C++14 compiler, Filament needs a C++17 compiler
and only supports Clang 7+, the most recent version of Xcode, and Visual Studio 2019,
see their building instructions.
Make sure to use one of these compiler if you build Open3D with BUILD_FILAMENT_FROM_SOURCE=ON
.
ML Module¶
The ML module consists of primitives like operators and layers as well as high
level code for models and pipelines. To build the operators and layers, set
BUILD_PYTORCH_OPS=ON
and/or BUILD_TENSORFLOW_OPS=ON
. Don’t forget to also
enable BUILD_CUDA_MODULE=ON
for GPU support. To include the models and
pipelines from Open3D-ML in the python package, set BUNDLE_OPEN3D_ML=ON
and
OPEN3D_ML_ROOT
to the Open3D-ML repository. You can directly download
Open3D-ML from GitHub during the build with
OPEN3D_ML_ROOT=https://github.com/intel-isl/Open3D-ML.git
.
Warning
Compiling PyTorch ops with CUDA 11 may have stability issues. See Open3D issue #3324 and PyTorch issue #52663 for more information on this problem.
We recommend to compile Pytorch from source
with compile flags -Xcompiler -fno-gnu-unique
or use the PyTorch
wheels from Open3D.
To reproduce the Open3D PyTorch wheels see the builder repository here.
The following example shows the command for building the ops with GPU support for all supported ML frameworks and bundling the high level Open3D-ML code.
# In the build directory
cmake -DBUILD_CUDA_MODULE=ON \
-DBUILD_PYTORCH_OPS=ON \
-DBUILD_TENSORFLOW_OPS=ON \
-DBUNDLE_OPEN3D_ML=ON \
-DOPEN3D_ML_ROOT=https://github.com/intel-isl/Open3D-ML.git \
..
# Install the python wheel with pip
make -j install-pip-package
Note
Importing Python libraries compiled with different CXX ABI may cause segfaults in regex. https://stackoverflow.com/q/51382355/1255535. By default, PyTorch and TensorFlow Python releases use the older CXX ABI; while when they are compiled from source, newer ABI is enabled by default.
When releasing Open3D as a Python package, we set
-DGLIBCXX_USE_CXX11_ABI=OFF
and compile all dependencies from source,
in order to ensure compatibility with PyTorch and TensorFlow Python releases.
If you build PyTorch or TensorFlow from source or if you run into ABI compatibility issues with them, please:
Check PyTorch and TensorFlow ABI with
python -c "import torch; print(torch._C._GLIBCXX_USE_CXX11_ABI)" python -c "import tensorflow; print(tensorflow.__cxx11_abi_flag__)"
Configure Open3D to compile all dependencies from source with the corresponding ABI version obtained from step 1.
After installation of the Python package, you can check Open3D ABI version with:
python -c "import open3d; print(open3d.pybind._GLIBCXX_USE_CXX11_ABI)"
To build Open3D with CUDA support, configure with:
cmake -DBUILD_CUDA_MODULE=ON -DCMAKE_INSTALL_PREFIX=<open3d_install_directory> ..
Please note that CUDA support is work in progress and experimental. For building Open3D with CUDA support, ensure that CUDA is properly installed by running following commands:
nvidia-smi # Prints CUDA-enabled GPU information
nvcc -V # Prints compiler version
If you see an output similar to command not found
, you can install CUDA toolkit
by following the official
documentation.
WebRTC remote visualization¶
We provide pre-built binaries of the WebRTC library to
build Open3D with remote visualization. Currently, Linux, macOS and Windows are
supported for x86_64
architecture. If you wish to use a different version of
WebRTC or build for a different configuration or platform, please see the
official WebRTC documentation
and the Open3D build scripts.
Linux and macOS¶
Please see the build script 3rdparty/webrtc/webrtc_build.sh
. For Linux, you
can also use the provided 3rdparty/webrtc/Dockerfile.webrtc
for building.
Windows¶
We provide Windows MSVC static libraries built in Release and Debug mode built with
the static Windows runtime. This corresponds to building with the /MT
and
/MTd
options respectively. For the build procedure, please see
.github/workflows/webrtc.yml
. Other configrations are not supported.
Unit test¶
To build and run C++ unit tests:
cmake -DBUILD_UNIT_TESTS=ON ..
make -j$(nproc)
./bin/tests
To run Python unit tests:
# Activate virtualenv first
pip install pytest
make install-pip-package -j$(nproc)
pytest ../python/test