Skip to content

Fix missing NVML_ENABLED guards around nvml.h includes#6255

Open
JanuszL wants to merge 1 commit intoNVIDIA:mainfrom
JanuszL:fix_nvml
Open

Fix missing NVML_ENABLED guards around nvml.h includes#6255
JanuszL wants to merge 1 commit intoNVIDIA:mainfrom
JanuszL:fix_nvml

Conversation

@JanuszL
Copy link
Contributor

@JanuszL JanuszL commented Mar 16, 2026

  • Guards all unconditional includes of dali/util/nvml.h with
    #if NVML_ENABLED, consistent with thread_pool.cc, worker_thread.h,
    gds_mem_test.cu and malloc_resource.cc. Fixes build failures on
    platforms where nvml.h is not available (e.g. Tegra CUDA 12.6).

Category:

Bug fix (non-breaking change which fixes an issue)

Description:

  • Guards all unconditional includes of dali/util/nvml.h with
    #if NVML_ENABLED, consistent with thread_pool.cc, worker_thread.h,
    gds_mem_test.cu and malloc_resource.cc. Fixes build failures on
    platforms where nvml.h is not available (e.g. Tegra CUDA 12.6).

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

  • NA

Tests:

  • Existing tests apply
    • tegra build
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [46231354]: BUILD STARTED

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR fixes build failures on NVML-less platforms (e.g., Tegra CUDA 12.6) by wrapping five unconditional #include "dali/util/nvml.h" directives with #if NVML_ENABLED / #endif guards, consistent with the existing pattern already applied in thread_pool.cc, worker_thread.h, gds_mem_test.cu, and malloc_resource.cc.

  • Guards dali/util/nvml.h include in nvjpeg_decoder_decoupled_api.h, nvjpeg_decoder_decoupled_api_test.cc, optical_flow.cc, optical_flow.h, and new_thread_pool.cc.
  • All nvml:: usages within the modified files were already individually guarded by #if NVML_ENABLED blocks, so the changes are mechanically correct and internally consistent.
  • Adds #include "dali/core/common.h" to new_thread_pool.cc to be explicit about the include providing the NVML_ENABLED preprocessor definition, mirroring the pattern in thread_pool.cc.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted include-guard fix with no logic changes.
  • All five changes follow the same established pattern already in the codebase. Every nvml:: API call in the modified files was already wrapped in #if NVML_ENABLED before this PR; the missing piece was just the include guard. The added #include "dali/core/common.h" in new_thread_pool.cc is consistent with the existing thread_pool.cc pattern. No functionality is altered on NVML-enabled builds, and the fix enables successful compilation on platforms without NVML.
  • No files require special attention.

Important Files Changed

Filename Overview
dali/operators/decoder/nvjpeg/nvjpeg_decoder_decoupled_api.h Adds #if NVML_ENABLED guard around #include "dali/util/nvml.h". All downstream uses of nvml:: types (nvml_handle_ at line 1220, usage at line 128) were already guarded consistently.
dali/operators/decoder/nvjpeg/nvjpeg_decoder_decoupled_api_test.cc Adds #if NVML_ENABLED guard around #include "dali/util/nvml.h". The only direct nvml API usages in the test (nvml::NvmlInstance, nvml::GetDriverVersion, nvml::isHWDecoderSupported) are already gated by #if NVJPEG_VER_MAJOR >= 11 && NVML_ENABLED at line 187.
dali/operators/sequence/optical_flow/optical_flow.cc Adds #if NVML_ENABLED guard around #include "dali/util/nvml.h". The nvml::GetDriverVersion() call at line 111 is inside an existing #if NVML_ENABLED block, so guarding the include is consistent.
dali/operators/sequence/optical_flow/optical_flow.h Adds #if NVML_ENABLED guard around #include "dali/util/nvml.h". The nvml::NvmlInstance nvml_handle_ member declaration (line 221) and its initializer (line 77) were already guarded by #if NVML_ENABLED.
dali/pipeline/util/new_thread_pool.cc Adds #if NVML_ENABLED guard around #include "dali/util/nvml.h" and adds #include "dali/core/common.h" (consistent with thread_pool.cc). All nvml:: usages are already within #if NVML_ENABLED guards.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Compiler invocation] --> B{NVML_ENABLED\ndefined?}
    B -- Yes --> C[Include dali/util/nvml.h]
    B -- No --> D[Skip nvml.h include]
    C --> E[nvml:: APIs available]
    D --> F[nvml:: APIs unavailable\ne.g. Tegra CUDA 12.6]
    E --> G[NVML code paths active\nin guarded blocks]
    F --> H[Fallback code paths active\ne.g. cuDriverGetVersion]
    G --> I[Build succeeds on\nNVML-enabled platforms]
    H --> J[Build succeeds on\nNVML-less platforms]
Loading

Last reviewed commit: 5db1732

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [46231354]: BUILD FAILED

- Guards all unconditional includes of dali/util/nvml.h with
  #if NVML_ENABLED, consistent with thread_pool.cc, worker_thread.h,
  gds_mem_test.cu and malloc_resource.cc. Fixes build failures on
  platforms where nvml.h is not available (e.g. Tegra CUDA 12.6).
- Adds direct include of dali/core/common.h in new_thread_pool.cc to
  make CPU_ONLY_DEVICE_ID available without relying on the transitive
  include chain through nvml.h (broken when NVML_ENABLED=0).

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [46242365]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [46242365]: BUILD FAILED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants