Compiling DALI from source ========================== Compiling DALI from source (using Docker builder) - recommended --------------------------------------------------------------- Following these steps, it is possible to recreate Python wheels in a similar fashion as we provide as an official prebuild binary. Prerequisites ^^^^^^^^^^^^^ .. |docker link| replace:: **Docker** .. _docker link: https://docs.docker.com/install/ .. table:: :align: center +----------------------------------------+---------------------------------------------------------------------------------------------+ | Linux x64 | | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |docker link|_ | Follow installation guide and manual at the link (version 17.05 or later is required). | +----------------------------------------+---------------------------------------------------------------------------------------------+ Building Python wheel and (optionally) Docker image ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Change directory (``cd``) into Docker directory and run ``./build.sh``. If needed, set the following environment variables: * PYVER - Python version. Default is ``2.7``. * CUDA_VERSION - CUDA toolkit version (9 for 9.0 or 10 for 10.0). Default is ``10``. * NVIDIA_BUILD_ID - Custom ID of the build. Default is ``1234``. * CREATE_WHL - Create a standalone wheel. Default is ``YES``. * CREATE_RUNNER - Create Docker image with cuDNN, CUDA and DALI installed inside. It will create the ``Docker_run_cuda`` image, which needs to be run using ``nvidia-docker`` and DALI wheel in the ``wheelhouse`` directory under$ * DALI_BUILD_FLAVOR - adds a suffix to DALI package name and put a note about it in the whl package description, i.e. `nightly` will result in the `nvidia-dali-nightly` * CMAKE_BUILD_TYPE - build type, available options: Debug, DevDebug, Release, RelWithDebInfo. Default is ``Release``. * BUILD_INHOST - ask docker to mount source code instead of copying it. Thank to that consecutive builds are resuing existing object files and are faster for the development. Uses $DALI_BUILD_DIR as a directory for build objects. Default is ``YES``. * REBUILD_BUILDERS - if builder docker images need to be rebuild or can be reused from the previous build. Default is ``NO``. * REBUILD_MANYLINUX - if manylinux base image need to be rebuild. Default is ``NO``. * DALI_BUILD_DIR - where DALI build should happen. It matters only bit the in-tree build where user may provide different path for every python/CUDA version. Default is ``build-docker-${CMAKE_BUILD_TYPE}-${PYV}-${CUDA_VERSION}``. It is worth to mention that build.sh should accept the same set of environment variables as the project CMake. The recommended command line is: .. code-block:: bash PYVER=X.Y CUDA_VERSION=Z ./build.sh For example: .. code-block:: bash PYVER=3.6 CUDA_VERSION=10 ./build.sh Will build CUDA 10 based DALI for Python 3.6 and place relevant Python wheel inside DALI_root/wheelhouse ---- Compiling DALI from source (bare metal) --------------------------------------- Prerequisites ^^^^^^^^^^^^^ .. |cuda link| replace:: **NVIDIA CUDA 9.0** .. _cuda link: https://developer.nvidia.com/cuda-downloads .. |nvjpeg link| replace:: **nvJPEG library** .. _nvjpeg link: https://developer.nvidia.com/nvjpeg .. |protobuf link| replace:: **protobuf** .. _protobuf link: https://github.com/google/protobuf .. |cmake link| replace:: **CMake 3.11** .. _cmake link: https://cmake.org .. |jpegturbo link| replace:: **libjpeg-turbo 1.5.x** .. _jpegturbo link: https://github.com/libjpeg-turbo/libjpeg-turbo .. |ffmpeg link| replace:: **FFmpeg 3.4.2** .. _ffmpeg link: https://developer.download.nvidia.com/compute/redist/nvidia-dali/ffmpeg-3.4.2.tar.bz2 .. |opencv link| replace:: **OpenCV 3** .. _opencv link: https://opencv.org .. |lmdb link| replace:: **liblmdb 0.9.x** .. _lmdb link: https://github.com/LMDB/lmdb .. |gcc link| replace:: **GCC 4.9.2** .. _gcc link: https://www.gnu.org/software/gcc/ .. |boost link| replace:: **Boost 1.66** .. _boost link: https://www.boost.org/ .. |mxnet link| replace:: **MXNet 1.3** .. _mxnet link: http://mxnet.incubator.apache.org .. |pytorch link| replace:: **PyTorch 0.4** .. _pytorch link: https://pytorch.org .. |tf link| replace:: **TensorFlow 1.7** .. _tf link: https://www.tensorflow.org .. table:: +----------------------------------------+---------------------------------------------------------------------------------------------+ | Required Component | Notes | +========================================+=============================================================================================+ | Linux x64 | | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |gcc link|_ or later | | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |boost link|_ or later | Modules: *preprocessor*. | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |cuda link|_ | *CUDA 8.0 compatibility is provided unofficially.* | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |nvjpeg link|_ | *This can be unofficially disabled. See below.* | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |protobuf link|_ | | Version 2 or later | | | | (Version 3 or later is required for TensorFlow TFRecord file format support). | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |cmake link|_ or later | | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |jpegturbo link|_ or later | *This can be unofficially disabled. See below.* | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |ffmpeg link|_ or later | We recommend using version 3.4.2 compiled following the *instructions below*. | +----------------------------------------+---------------------------------------------------------------------------------------------+ | |opencv link|_ or later | Supported version: 3.4 | +----------------------------------------+---------------------------------------------------------------------------------------------+ | (Optional) |lmdb link|_ or later | | +----------------------------------------+---------------------------------------------------------------------------------------------+ | One or more of the following Deep Learning frameworks: | | * |mxnet link|_ ``mxnet-cu90`` or later | | * |pytorch link|_ | | * |tf link|_ or later | +----------------------------------------+---------------------------------------------------------------------------------------------+ .. note:: TensorFlow installation is required to build the TensorFlow plugin for DALI. .. note:: Items marked *"unofficial"* are community contributions that are believed to work but not officially tested or maintained by NVIDIA. .. note:: This software uses the FFmpeg licensed code under the LGPLv2.1. Its source can be downloaded `from here. `_ FFmpeg was compiled using the following command line: .. code-block:: bash ./configure \ --prefix=/usr/local \ --disable-static \ --disable-all \ --disable-autodetect \ --disable-iconv \ --enable-shared \ --enable-avformat \ --enable-avcodec \ --enable-avfilter \ --enable-protocol=file \ --enable-demuxer=mov,matroska \ --enable-bsf=h264_mp4toannexb,hevc_mp4toannexb && \ make Get the DALI source ^^^^^^^^^^^^^^^^^^^ .. code-block:: bash git clone --recursive https://github.com/NVIDIA/dali cd dali Make the build directory ^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash mkdir build cd build Compile DALI ^^^^^^^^^^^^ Building DALI without LMDB support: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash cmake .. make -j"$(nproc)" Building DALI with LMDB support: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash cmake -DBUILD_LMDB=ON .. make -j"$(nproc)" Building DALI using Clang (experimental): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. note:: This build is experimental. It is neither maintained nor tested. It is not guaranteed to work. We recommend using GCC for production builds. .. code-block:: bash cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang .. make -j"$(nproc)" **Optional CMake build parameters**: - ``BUILD_PYTHON`` - build Python bindings (default: ON) - ``BUILD_TEST`` - include building test suite (default: ON) - ``BUILD_BENCHMARK`` - include building benchmarks (default: ON) - ``BUILD_LMDB`` - build with support for LMDB (default: OFF) - ``BUILD_NVTX`` - build with NVTX profiling enabled (default: OFF) - ``BUILD_TENSORFLOW`` - build TensorFlow plugin (default: OFF) - ``BUILD_NVJPEG`` - build with ``nvJPEG`` support (default: ON) - ``BUILD_NVOF`` - build with ``NVIDIA OPTICAL FLOW SDK`` support (default: ON) - ``BUILD_NVDEC`` - build with ``NVIDIA NVDEC`` support (default: ON) - ``BUILD_NVML`` - build with ``NVIDIA Management Library`` (``NVML``) support (default: ON) - ``WERROR`` - treat all build warnings as errors (default: OFF) - ``DALI_BUILD_FLAVOR`` - Allow to specify custom name sufix (i.e. 'nightly') for nvidia-dali whl package - *(Unofficial)* ``BUILD_JPEG_TURBO`` - build with ``libjpeg-turbo`` (default: ON) .. note:: DALI release packages are built with the options listed above set to ON and NVTX turned OFF. Testing is done with the same configuration. We ensure that DALI compiles with all of those options turned OFF, but there may exist cross-dependencies between some of those features. Following CMake parameters could be helpful in setting the right paths: .. |libjpeg-turbo_cmake link| replace:: **libjpeg CMake docs page** .. _libjpeg-turbo_cmake link: https://cmake.org/cmake/help/v3.11/module/FindJPEG.html .. |protobuf_cmake link| replace:: **protobuf CMake docs page** .. _protobuf_cmake link: https://cmake.org/cmake/help/v3.11/module/FindProtobuf.html * FFMPEG_ROOT_DIR - path to installed FFmpeg * NVJPEG_ROOT_DIR - where nvJPEG can be found (from CUDA 10.0 it is shipped with the CUDA toolkit so this option is not needed there) * libjpeg-turbo options can be obtained from |libjpeg-turbo_cmake link|_ * protobuf options can be obtained from |protobuf_cmake link|_ Install Python bindings ^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash pip install dali/python Cross-compiling DALI C++ API for aarch64 Linux (Docker) ------------------------------------------------------- .. note:: Support for aarch64 Linux platform is experimental. Some of the features are available only for x86-64 target and they are turned off in this build. There is no support for DALI Python library on aarch64 yet. Some Operators may not work as intended due to x86-64 specific implementations. Build the aarch64 Linux Build Container ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: bash docker build -t dali_builder:aarch64-linux -f Dockerfile.build.aarch64-linux . Compile ^^^^^^^ From the root of the DALI source tree .. code-block:: bash docker run -v $(pwd):/dali dali_builder:aarch64-linux The relevant artifacts will be in ``build/install`` and ``build/dali/python/nvidia/dali``