Skip to content

NVIDIA/DALI

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Remove the `tensorflow.python` prefix from pure AutoGraph imports.
Remove all imports that start with `from tensorflow...` and lead to
non-AutoGraph functionality.
Adjust some of the imports (mainly inspect and unittest) and add 
some placeholder utilites.

Replace all TensorFlow Operator overloads with calls to OperatorBase 
class that currently is a no-op. 
The new code is in third_party/autograph/autograph/utils/hooks.py
which keeps a _DISPATCH global symbol. We replace it with the instance 
inheriting from OperatorBase. You can see it's inserted in api.py into
the `ag_internal`. `ag_internal` translates to the `ag__`  that is inserted 
as a local object for every transformed function.

Introduce `initialize_autograph` call that allows to set the name and 
provide custom (AutoGraph) operator overloads. User is supposed 
to inherit from OperatorBase. The library can be initialized once.

Remove tests that utilize the TF Tensors, Datasets, operators, etc.
Replace TF-specific test class with unittest.TestCase.
For particular subdirectory:
* `converters/` - replace tf.constant with regular value and test the
    Python fallbacks (as the OperatorBase always indicates that we 
    don't need to select the overload)
* `core/`, `impl/` - keep the test that are not TF-specific, for example
    not use TF decorators, defuns, etc.
* `operators/` - keep mostly the tests that have `python` in name,
    the others indicate that it's TF specific. Those tests explicitly check
    the Python fallback implementation for transformed statements.
* `pyct` - this is the transpiler part, most tests are pure AutoGraph,
    most of the time only imports and test class used need to be adjusted.

Some functionality around decorators and stack trace remapping was removed
or commented out. 
The former was tightly coupled with TF's decorator system.
The latter requires some compiled utilities which can be ported after integration 
into the DALI build system. 

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
792c055

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
Jun 18, 2018

License Documentation Language grade: Python

NVIDIA DALI

The NVIDIA Data Loading Library (DALI) is a library for data loading and pre-processing to accelerate deep learning applications. It provides a collection of highly optimized building blocks for loading and processing image, video and audio data. It can be used as a portable drop-in replacement for built in data loaders and data iterators in popular deep learning frameworks.

Deep learning applications require complex, multi-stage data processing pipelines that include loading, decoding, cropping, resizing, and many other augmentations. These data processing pipelines, which are currently executed on the CPU, have become a bottleneck, limiting the performance and scalability of training and inference.

DALI addresses the problem of the CPU bottleneck by offloading data preprocessing to the GPU. Additionally, DALI relies on its own execution engine, built to maximize the throughput of the input pipeline. Features such as prefetching, parallel execution, and batch processing are handled transparently for the user.

In addition, the deep learning frameworks have multiple data pre-processing implementations, resulting in challenges such as portability of training and inference workflows, and code maintainability. Data processing pipelines implemented using DALI are portable because they can easily be retargeted to TensorFlow, PyTorch, MXNet and PaddlePaddle.

DALI Diagram

DALI in action:

from nvidia.dali.pipeline import pipeline_def
import nvidia.dali.types as types
import nvidia.dali.fn as fn
from nvidia.dali.plugin.pytorch import DALIGenericIterator
import os

# To run with different data, see documentation of nvidia.dali.fn.readers.file
# points to https://github.com/NVIDIA/DALI_extra
data_root_dir = os.environ['DALI_EXTRA_PATH']
images_dir = os.path.join(data_root_dir, 'db', 'single', 'jpeg')


def loss_func(pred, y):
    pass


def model(x):
    pass


def backward(loss, model):
    pass


@pipeline_def(num_threads=4, device_id=0)
def get_dali_pipeline():
    images, labels = fn.readers.file(
        file_root=images_dir, random_shuffle=True, name="Reader")
    # decode data on the GPU
    images = fn.decoders.image_random_crop(
        images, device="mixed", output_type=types.RGB)
    # the rest of processing happens on the GPU as well
    images = fn.resize(images, resize_x=256, resize_y=256)
    images = fn.crop_mirror_normalize(
        images,
        crop_h=224,
        crop_w=224,
        mean=[0.485 * 255, 0.456 * 255, 0.406 * 255],
        std=[0.229 * 255, 0.224 * 255, 0.225 * 255],
        mirror=fn.random.coin_flip())
    return images, labels


train_data = DALIGenericIterator(
    [get_dali_pipeline(batch_size=16)],
    ['data', 'label'],
    reader_name='Reader'
)


for i, data in enumerate(train_data):
    x, y = data[0]['data'], data[0]['label']
    pred = model(x)
    loss = loss_func(pred, y)
    backward(loss, model)

Highlights

  • Easy-to-use functional style Python API.
  • Multiple data formats support - LMDB, RecordIO, TFRecord, COCO, JPEG, JPEG 2000, WAV, FLAC, OGG, H.264, VP9 and HEVC.
  • Portable across popular deep learning frameworks: TensorFlow, PyTorch, MXNet, PaddlePaddle.
  • Supports CPU and GPU execution.
  • Scalable across multiple GPUs.
  • Flexible graphs let developers create custom pipelines.
  • Extensible for user-specific needs with custom operators.
  • Accelerates image classification (ResNet-50), object detection (SSD) workloads as well as ASR models (Jasper, RNN-T).
  • Allows direct data path between storage and GPU memory with GPUDirect Storage.
  • Easy integration with NVIDIA Triton Inference Server with DALI TRITON Backend.
  • Open source.

DALI Roadmap

The following issue represents a high-level overview of our 2022 plan. You should be aware that this roadmap may change at any time and the order below does not reflect any type of priority.

We strongly encourage you to comment on our roadmap and provide us feedback on the mentioned GitHub issue.


Installing DALI

To install the latest DALI release for the latest CUDA version (11.x):

pip install --extra-index-url https://developer.download.nvidia.com/compute/redist --upgrade nvidia-dali-cuda110

DALI comes preinstalled in the TensorFlow, PyTorch, and MXNet containers on NVIDIA GPU Cloud (versions 18.07 and later).

For other installation paths (TensorFlow plugin, older CUDA version, nightly and weekly builds, etc), please refer to the Installation Guide.

To build DALI from source, please refer to the Compilation Guide.


Examples and Tutorials

An introduction to DALI can be found in the Getting Started page.

More advanced examples can be found in the Examples and Tutorials page.

For an interactive version (Jupyter notebook) of the examples, go to the docs/examples directory.

Note: Select the Latest Release Documentation or the Nightly Release Documentation, which stays in sync with the main branch, depending on your version.


Additional Resources

  • GPU Technology Conference 2022; Effective NVIDIA DALI: Accelerating Real-life Deep-learning Applications; Rafał Banaś: event.
  • GPU Technology Conference 2022; Introduction to NVIDIA DALI: GPU-accelerated Data Preprocessing; Joaquin Anton Guirao: event.
  • GPU Technology Conference 2021; NVIDIA DALI: GPU-Powered Data Preprocessing by Krzysztof Łęcki and Michał Szołucha: event.
  • GPU Technology Conference 2020; Fast Data Pre-Processing with NVIDIA Data Loading Library (DALI); Albert Wolant, Joaquin Anton Guirao recording.
  • GPU Technology Conference 2019; Fast AI data pre-preprocessing with DALI; Janusz Lisiecki, Michał Zientkiewicz: slides, recording.
  • GPU Technology Conference 2019; Integration of DALI with TensorRT on Xavier; Josh Park and Anurag Dixit: slides, recording.
  • GPU Technology Conference 2018; Fast data pipeline for deep learning training, T. Gale, S. Layton and P. Trędak: slides, recording.
  • Developer Page.
  • Blog Posts.

Contributing to DALI

We welcome contributions to DALI. To contribute to DALI and make pull requests, follow the guidelines outlined in the Contributing document.

If you are looking for a task good for the start please check one from external contribution welcome label.

Reporting Problems, Asking Questions

We appreciate feedback, questions or bug reports. When you need help with the code, follow the process outlined in the Stack Overflow https://stackoverflow.com/help/mcve document. Ensure that the posted examples are:

  • minimal: Use as little code as possible that still produces the same problem.
  • complete: Provide all parts needed to reproduce the problem. Check if you can strip external dependency and still show the problem. The less time we spend on reproducing the problems, the more time we can dedicate to the fixes.
  • verifiable: Test the code you are about to provide, to make sure that it reproduces the problem. Remove all other problems that are not related to your request.

Acknowledgements

DALI was originally built with major contributions from Trevor Gale, Przemek Tredak, Simon Layton, Andrei Ivanov and Serge Panev.