Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:NVIDIA DALI PluginManager

From Leeroopedia


Knowledge Sources
Domains Utilities, Plugin_System
Last Updated 2026-02-08 16:00 GMT

Overview

Declares the PluginManager class for dynamically loading DALI plugin shared libraries at runtime from individual files, directories, or the default plugin path.

Description

The PluginManager class in dali/plugin/plugin_manager.h provides a static API for dynamically loading shared library plugins into the DALI runtime. It serves as the entry point for DALI's plugin extensibility mechanism, allowing custom operators and other components to be packaged as shared objects and loaded on demand.

The class exposes three static methods. LoadLibrary loads a single shared library from an explicit filesystem path using dlopen(). It accepts optional flags to control whether symbols are loaded into the global namespace (RTLD_GLOBAL) or remain local (RTLD_LOCAL), and whether load failures should be treated as soft errors. LoadDirectory scans a root directory for plugin shared objects matching the pattern {lib_path}/{subpath}/libdali_{plugin_name}.so, loading each discovered library with the same symbol visibility and error handling options.

LoadDefaultPlugins provides automatic plugin discovery. It checks the DALI_PRELOAD_PLUGINS environment variable, which can contain a colon-separated list of paths (both directories and individual library files). If the environment variable is not set, it falls back to scanning the plugin subdirectory under the DALI installation directory. This enables both explicit user-controlled plugin loading and transparent default plugin discovery.

Usage

Use PluginManager to load custom DALI operators packaged as shared libraries. Call LoadLibrary for a specific plugin file, LoadDirectory to load all plugins from a directory tree, or LoadDefaultPlugins for automatic discovery. Plugin loading is typically done at initialization time before pipeline construction.

Code Reference

Source Location

Signature

namespace dali {

class DLL_PUBLIC PluginManager {
 public:
  static DLL_PUBLIC void LoadLibrary(const std::string& lib_path,
                                     bool global_symbols = false,
                                     bool allow_fail = false);

  static DLL_PUBLIC void LoadDirectory(const std::string& lib_path,
                                       bool global_symbols = false,
                                       bool allow_fail = false);

  static DLL_PUBLIC void LoadDefaultPlugins();
};

}  // namespace dali

Import

#include "dali/plugin/plugin_manager.h"

I/O Contract

Inputs

Name Type Required Description
lib_path const std::string& Yes (LoadLibrary, LoadDirectory) Path to a shared library file or root directory containing plugins
global_symbols bool No If true, loads with RTLD_GLOBAL; otherwise uses RTLD_LOCAL (default: false)
allow_fail bool No If true, load failures produce warnings instead of errors (default: false)

Outputs

Name Type Description
(side effect) N/A Plugin shared library is loaded into the process, registering its operators and components with the DALI runtime

Usage Examples

Loading a Specific Plugin Library

#include "dali/plugin/plugin_manager.h"

// Load a custom plugin with local symbol visibility
dali::PluginManager::LoadLibrary("/usr/lib/libcustomplugin.so");

// Load with global symbols (needed if plugin exports symbols used by other plugins)
dali::PluginManager::LoadLibrary("/usr/lib/libbaseplugin.so", /*global_symbols=*/true);

// Load with soft failure (e.g., optional plugins)
dali::PluginManager::LoadLibrary("/opt/plugins/liboptional.so",
                                 /*global_symbols=*/false,
                                 /*allow_fail=*/true);

Loading All Plugins from a Directory

#include "dali/plugin/plugin_manager.h"

// Scan directory for libdali_*.so plugins and load them
dali::PluginManager::LoadDirectory("/usr/local/lib/dali/plugins/");

Using Default Plugin Discovery

#include "dali/plugin/plugin_manager.h"

// Load plugins from DALI_PRELOAD_PLUGINS env var or default install path
dali::PluginManager::LoadDefaultPlugins();

// Environment variable usage:
// export DALI_PRELOAD_PLUGINS="/path/to/plugin1.so:/path/to/plugin_dir"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment