Implementation:NVIDIA DALI TF Plugin Install Tool
| Knowledge Sources | |
|---|---|
| Domains | TensorFlow_Integration, Data_Pipeline |
| Last Updated | 2026-02-08 16:00 GMT |
Overview
Provides the installation tool that detects the build environment, selects prebuilt binaries or compiles from source, and installs the DALI TensorFlow plugin shared library.
Description
This Python script manages the full installation workflow for the DALI TensorFlow plugin. It is centered around the InstallerHelper class, which probes the environment to determine the installed TensorFlow version, the C++ compiler used to build TensorFlow, the default system compiler, platform architecture, and whether a Conda environment is active. Based on these checks, it decides whether to install a prebuilt plugin binary or build from source.
The prebuilt installation path searches for libdali_tf_*.so files in the prebuilt directory, selects the best match for the installed TensorFlow version (preferring exact version matches), and validates the plugin by loading it in a separate process to catch segmentation faults. The build-from-source path generates a DALI stub library from the C API header using stubgen, then compiles the plugin sources (daliop.cc and dali_dataset_op.cc) with the appropriate TensorFlow build flags, CUDA flags, and C++ standard (C++14 for TF < 2.10, C++17 for TF >= 2.10). The compiled library is tested before being installed to the destination directory.
The tool includes robust fallback behavior: if the exact-version prebuilt binary fails, it attempts a from-source build; if that fails and a non-exact prebuilt binary is available, it tries that as a last resort. The DALI_TF_ALWAYS_BUILD environment variable can force a from-source build. A plugin_load_and_test function creates a minimal DALI pipeline with a constant output and runs it through TensorFlow to verify end-to-end functionality of the installed plugin.
Usage
Run this script directly as python dali_tf_plugin_install_tool.py or invoke it programmatically through the InstallerHelper class when installing the DALI TensorFlow plugin package. It is typically executed during the pip install nvidia-dali-tf-plugin post-installation step.
Code Reference
Source Location
- Repository: NVIDIA_DALI
- File: dali_tf_plugin/dali_tf_plugin_install_tool.py
- Lines: 1-455
Signature
def plugin_load_and_test(dali_tf_path):
"""Load and test the DALI TF plugin in a TF 1.x Session."""
...
class InstallerHelper:
def __init__(self, plugin_dest_dir=None):
"""Initialize with environment detection."""
...
def debug_str(self) -> str:
"""Return a formatted string with environment details."""
...
def check_load_plugin(self, lib_path, dali_stub) -> bool:
"""Verify plugin loads in TensorFlow."""
...
def test_plugin(self, lib_path, dali_stub) -> bool:
"""Run end-to-end pipeline test with plugin."""
...
def check_plugin(self, plugin_path, dali_stub_path) -> bool:
"""Test plugin with DALI if available, else just check loading."""
...
def install_prebuilt(self) -> bool:
"""Install a prebuilt plugin binary."""
...
def get_compiler(self) -> str:
"""Determine the C++ compiler to use."""
...
def build(self):
"""Build the plugin from source."""
...
def check_install_env(self):
"""Validate the build environment."""
...
def install(self):
"""Main installation entry point."""
...
def main():
env = InstallerHelper()
env.install()
Import
from dali_tf_plugin.dali_tf_plugin_install_tool import InstallerHelper
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| plugin_dest_dir | str or None | No | Override directory for plugin installation (defaults to nvidia/dali_tf_plugin under source) |
| DALI_TF_ALWAYS_BUILD | env var | No | Set to "1" to force building from source, skipping prebuilt checks |
| CXX | env var | No | Override the C++ compiler path |
| PREFIX | env var | No | System prefix for include paths (defaults to /usr) |
| TensorFlow | package | Yes | An installed TensorFlow package in the Python environment |
Outputs
| Name | Type | Description |
|---|---|---|
| libdali_tf_*.so | file | Compiled or copied DALI TF plugin shared library installed to the destination directory |
| Console output | text | Installation progress messages, environment debug info, and success/failure status |
Usage Examples
Command-line Installation
# Run directly from the command line
# $ python dali_tf_plugin_install_tool.py
# Programmatic usage
from dali_tf_plugin.dali_tf_plugin_install_tool import InstallerHelper
helper = InstallerHelper(plugin_dest_dir="/opt/dali_tf_plugin")
helper.install()
Force Build from Source
import os
os.environ["DALI_TF_ALWAYS_BUILD"] = "1"
from dali_tf_plugin.dali_tf_plugin_install_tool import InstallerHelper
helper = InstallerHelper()
helper.build()