Skip to content

Add collect_env environment report tool for bug reports - #400

Merged
Anerudhan merged 1 commit into
NVIDIA:developfrom
YangXu1990uiuc:yanxu/collect-env
Jul 16, 2026
Merged

Add collect_env environment report tool for bug reports#400
Anerudhan merged 1 commit into
NVIDIA:developfrom
YangXu1990uiuc:yanxu/collect-env

Conversation

@YangXu1990uiuc

@YangXu1990uiuc YangXu1990uiuc commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Description

Issue reporters often can't state their environment precisely, and the most common unreproducible-issue root cause is version confusion — multiple cuDNN/CUDA copies installed where the loaded one is not the one the user assumes. This is especially acute for cudnn-frontend: the Python bindings dlopen libcudnn via a search order (LD_LIBRARY_PATH → pip nvidia/cudnn/lib → soname fallback) that can resolve to a different copy than the one torch linked.

This PR adds an environment-forensics tool and wires it into the bug-report issue template and README:

python -m cudnn.collect_env          # or --json

What the report covers

  • cudnn-frontend version with mismatch flags: imported cudnn.__version__ vs pip nvidia-cudnn-frontend metadata (stale build / shadowing checkout), and torch.backends.cudnn.version() vs the frontend's loaded backend (two libcudnn copies in one process)
  • The frontend's _dlopen_cudnn() search-order resolution, traced read-only
  • GPU/driver properties in CUDA enumeration order (nvidia-smi order as no-torch fallback), CUDA toolkit / nvcc
  • Loaded vs installed GPU libraries (libcudnn incl. sublibraries, libcublas, libcudart, libnvrtc, driver): parses /proc/self/maps for what is truly mapped, scans LD_LIBRARY_PATH / site-packages / CUDA_HOME / ldconfig for other on-disk installs; aggregated per directory with pip provenance, ⚠ on real conflicts including mixed sublibrary versions in one directory
  • Relevant packages (incl. torch's declared cuDNN pin, stated factually), CUDNN_*/CUDA_*/… env vars, GPU topology

Design constraints (documented in the module docstring)

  • stdlib-only at module level and every probe individually guarded → still produces a report when import cudnn or torch is broken; the file can be curl-ed and run standalone with bare Python (useful triage even for C++-only users: it inventories every libcudnn on disk)
  • strictly offline and read-only

Example headline section from a box with a local backend build plus pip wheels:

==== GPU Libraries: loaded vs on disk ====
libcudnn  ⚠ other installs on disk (check which one you expect):
    LOADED   /opt/cudnn/lib/  [v9.26.0]
    on disk  .../site-packages/nvidia/cudnn/lib/  [v9.13.0, pip nvidia-cudnn-cu13==9.13.0.50]

Tests

test/python/test_collect_env.py (L0) asserts the core contract: collection never raises, sections present, frontend/backend versions reported, JSON-serializable. Verified manually: full run in a venv on a multi-arch box (SM80/89/90/100), standalone run with bare /usr/bin/python3 (no torch — degrades gracefully), --json parses, black clean.

Reviewer notes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added an environment diagnostic tool for collecting cuDNN, CUDA, GPU, driver, framework, and library information.
    • Reports are available in Markdown or JSON format.
    • The tool can run even when cuDNN or PyTorch imports are unavailable.
    • Added checks for loaded-versus-installed library conflicts and backend version mismatches.
  • Documentation

    • Added instructions for generating environment reports when submitting bug reports.
    • Updated the bug report template with fallback instructions for broken imports.
  • Tests

    • Added coverage for report contents, formatting, version details, and JSON serialization.

Issue reporters often can't state their environment precisely, and the
most common unreproducible-issue root cause is version confusion:
multiple cuDNN/CUDA copies installed where the loaded one is not the
one the user assumes.

python -m cudnn.collect_env produces an offline, read-only report:
frontend/backend versions with mismatch flags (stale pip metadata,
torch's libcudnn vs the frontend's dlopen'ed backend), the frontend's
libcudnn search-order resolution, GPUs in CUDA enumeration order,
loaded-vs-on-disk GPU libraries via /proc/self/maps with pip
provenance, relevant packages incl. torch's declared cuDNN pin, and
CUDNN_*/CUDA_* env vars.

Stdlib-only at module level with every probe individually guarded, so
the file also runs standalone with bare Python when import cudnn is
broken. Referenced from the bug-report issue template and README.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@YangXu1990uiuc

Copy link
Copy Markdown
Collaborator Author

example

(fe) yanxu@cudnn-dev-parley-22-04:/home/scratch.yanxu_libs/cudnn_frontend$ python -m cudnn.collect_env
### cuDNN frontend environment report
<!-- generated by `python -m cudnn.collect_env`; paste into your issue -->

==== cuDNN Frontend ====
cudnn-frontend              : 1.25.0
nvidia-cudnn-frontend (pip) : 1.21.0  ⚠ MISMATCH vs imported cudnn.__version__ == 1.25.0
cudnn-frontend file         : /home/scratch.yanxu_libs/fe/lib/python3.10/site-packages/cudnn/__init__.py
compiled module             : /home/scratch.yanxu_libs/fe/lib/python3.10/site-packages/cudnn/_compiled_module.cpython-310-x86_64-linux-gnu.so
cudnn backend (loaded)      : 9.26.0 (92600)
backend search order picks  : /home/scratch.yanxu_libs/cudnn/lib/libcudnn.so.9.26.0 (via LD_LIBRARY_PATH)

==== Python / Platform ====
Python            : 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0]
Python executable : /home/scratch.yanxu_libs/fe/bin/python
Virtual env       : /home/scratch.yanxu_libs/fe
Platform          : Linux-5.15.0-133-generic-x86_64-with-glibc2.35
libc              : glibc 2.35
OS                : Ubuntu 22.04.5 LTS
Container         : no / not detected

==== GPU / Driver ====
Driver version       : 595.71.05
CUDA_VISIBLE_DEVICES : <unset>
GPU 0 (CUDA order)   : NVIDIA L40S | SM89 | 142 SMs | 44.4 GiB
GPU 1 (CUDA order)   : NVIDIA Graphics Device | SM100 | 148 SMs | 178.3 GiB
GPU 2 (CUDA order)   : NVIDIA H100 NVL | SM90 | 132 SMs | 93.1 GiB
GPU 3 (CUDA order)   : NVIDIA A100-PCIE-40GB | SM80 | 108 SMs | 39.5 GiB
GPU 4 (CUDA order)   : NVIDIA DRIVE P2021 | SM100 | 68 SMs | 47.3 GiB

==== CUDA Toolkit ====
nvcc on PATH    : not found
CUDA_HOME (env) : <unset>

==== PyTorch ====
torch                          : 2.10.0.dev20250923+cu130
torch.version.cuda             : 13.0
torch file                     : /home/scratch.yanxu_libs/fe/lib/python3.10/site-packages/torch/__init__.py
torch.backends.cudnn.version() : 92600

==== GPU Libraries: loaded vs on disk ====
libcudnn  ⚠ other installs on disk (check which one you expect):
    LOADED   /home/scratch.yanxu_libs/cudnn/lib/  [v9.21.0 / v9.22.0 / v9.24.0 / v9.26.0, ⚠ mixed versions in one directory]
    on disk  /home/scratch.yanxu_libs/cudnn/out/cu132/  [v9.23.0 / v9.30.0, ⚠ mixed versions in one directory]
libcublas  ⚠ other installs on disk (check which one you expect):
    LOADED   /home/scratch.yanxu_libs/fe/lib/python3.10/site-packages/nvidia/cu13/lib/  [pip nvidia-cublas==13.0.0.19]
    on disk  /home/scratch.yanxu_libs/cuda-13.2/targets/x86_64-linux/lib/  [v13.3.0.5]
libcudart  ⚠ other installs on disk (check which one you expect):
    LOADED   /home/scratch.yanxu_libs/fe/lib/python3.10/site-packages/nvidia/cu13/lib/  [pip nvidia-cuda-runtime==13.0.48]
    on disk  /home/scratch.yanxu_libs/cuda-13.2/targets/x86_64-linux/lib/  [v13.2.20]
libnvrtc  ⚠ multiple installs on disk:
    on disk  /home/scratch.yanxu_libs/cuda-13.2/targets/x86_64-linux/lib/  [v13.2.46]
    on disk  /home/scratch.yanxu_libs/fe/lib/python3.10/site-packages/nvidia/cu13/lib/  [pip nvidia-cuda-nvrtc==13.0.48]
libcuda (driver)  ⚠ other installs on disk (check which one you expect):
    LOADED   /usr/lib/x86_64-linux-gnu/  [v595.71.05]
    on disk  /usr/lib32/  [v595.71.05]

==== Relevant Packages ====
cuda-bindings               : 13.0.2
cuda-core                   : 0.6.0
cuda-pathfinder             : 1.5.3
cuda-python                 : 13.0.2
cuda-toolkit                : 13.2.0
cudnn                       : 1.0.0
looseversion                : 1.3.0
ninja                       : 1.13.0
numpy                       : 2.1.2
nvidia-cublas               : 13.0.0.19
nvidia-cuda-cupti           : 13.0.48
nvidia-cuda-nvdisasm        : 13.3.73
nvidia-cuda-nvrtc           : 13.0.48
nvidia-cuda-runtime         : 13.0.48
nvidia-cudnn-cu13           : 9.13.0.50
nvidia-cudnn-frontend       : 1.21.0
nvidia-cufft                : 12.0.0.15
nvidia-cufile               : 1.15.0.42
nvidia-curand               : 10.4.0.35
nvidia-cusolver             : 12.0.3.29
nvidia-cusparse             : 12.6.2.49
nvidia-cusparselt-cu13      : 0.8.0
nvidia-cutlass-dsl-internal : 0.3.0+20260706043000.55bde60
nvidia-ml-py                : 13.595.45
nvidia-nccl-cu13            : 2.27.7
nvidia-nvjitlink            : 13.0.39
nvidia-nvshmem-cu13         : 3.3.24
nvidia-nvtx                 : 13.0.39
nvidia-nvvm                 : 13.2.51
pybind11                    : 3.0.2
torch                       : 2.10.0.dev20250923+cu130  (declares nvidia-cudnn-cu13==9.13.0.50; platform_system == "Linux")

==== Environment Variables ====
CUDA_MODULE_LOADING : LAZY
CUDNN_AUTO_CLANG    : 1
CUDNN_CONFIG        : cudnn.cfg
LD_LIBRARY_PATH     : /home/scratch.yanxu_libs/cudnn/lib:/home/scratch.yanxu_libs/cuda-13.2/lib64:/home/scratch.yanxu_libs/cudnn/lib:/home/scratch.yanxu_libs/cuda-13.2/lib64::/home/scratch.yanxu_libs/tools:.:/home/scratch.yanxu_libs/tools:.:/home/scratch.yanxu_libs/tools:.
PATH                : /home/scratch.yanxu_libs/fe/bin:/home/scratch.yanxu_gpu/linuxbrew/bin:/home/scratch.yanxu_gpu/linuxbrew/sbin:/home/yanxu/.local/bin:/home/scratch.yanxu_libs/cudnn/scripts/:/var/tmp/yanxu/vscode-server/.vscode-server/data/User/globalStorage/github.copilot-chat/debugCommand:/var/tmp/yanxu/vscode-server/.vscode-server/data/User/globalStorage/github.copilot-chat/copilotCli:/var/tmp/yanxu/vscode-server/.vscode-server/cli/servers/Stable-125df4672b8a6a34975303c6b0baa124e560a4f7/server/bin/remote-cli:/home/scratch.yanxu_gpu/linuxbrew/bin:/home/scratch.yanxu_gpu/linuxbrew/sbin:/home/yanxu/.local/bin:/home/scratch.yanxu_libs/cudnn/scripts/:/home/scratch.yanxu_gpu/linuxbrew/bin:/home/scratch.yanxu_gpu/linuxbrew/sbin:/home/yanxu/.nvm/versions/node/v22.22.2/bin:/home/yanxu/.local/bin:/home/scratch.yanxu_libs/cudnn/scripts/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/dotnet-sdk/current:/snap/dotnet-sdk/current:/snap/dotnet-sdk/current
VIRTUAL_ENV         : /home/scratch.yanxu_libs/fe

==== GPU Topology ====
nvidia-smi topo -m:
GPU0    GPU1    GPU2    GPU3    GPU4    NIC0    NIC1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      NODE    NODE    SYS     SYS     PHB     PHB     0-63,128-191    0               N/A
GPU1    NODE     X      NODE    SYS     SYS     NODE    NODE    0-63,128-191    0               N/A
GPU2    NODE    NODE     X      SYS     SYS     NODE    NODE    0-63,128-191    0               N/A
GPU3    SYS     SYS     SYS      X      NODE    SYS     SYS     64-127,192-255  1               N/A
GPU4    SYS     SYS     SYS     NODE     X      SYS     SYS     64-127,192-255  1               N/A
NIC0    PHB     NODE    NODE    SYS     SYS      X      PIX
NIC1    PHB     NODE    NODE    SYS     SYS     PIX      X

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a standalone cuDNN environment-reporting CLI that collects guarded system, GPU, CUDA, framework, package, and library-linkage details, supports Markdown or JSON output, and is documented and tested.

Changes

Environment report collection

Layer / File(s) Summary
Environment probes and backend discovery
python/cudnn/collect_env.py
Adds guarded probes for frontend/backend versions, platform and GPU details, CUDA toolkit state, framework metadata, and package pins.
GPU library linkage and conflict reporting
python/cudnn/collect_env.py
Inspects loaded and on-disk GPU libraries, their locations, and package provenance by library family.
Report assembly and CLI output
python/cudnn/collect_env.py
Coordinates report sections and provides Markdown, JSON, and source-checkout entrypoint handling.
CLI validation and usage guidance
test/python/test_collect_env.py, README.md, .github/ISSUE_TEMPLATE/bug_report.yml
Tests report structure, versions, formatting, and JSON serialization while documenting module and standalone usage.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant main
  participant collect_env_info
  participant nvidia_smi as nvidia-smi
  participant torch
  participant proc_maps as /proc/self/maps
  main->>collect_env_info: collect environment sections
  collect_env_info->>nvidia_smi: query GPU and topology details
  collect_env_info->>torch: inspect CUDA and cuDNN linkage when available
  collect_env_info->>proc_maps: inspect loaded GPU library paths
  collect_env_info-->>main: return ordered report
  main->>main: format Markdown or emit JSON
Loading

Suggested reviewers: hwanseoc

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change and testing, but it does not follow the required template or include several required sections. Add the template sections: Before submitting, Affected area, Summary, Why, Related issues, API and compatibility impact, and Testing.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a collect_env environment report tool for bug reports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@Anerudhan
Anerudhan self-requested a review July 16, 2026 20:33
@Anerudhan Anerudhan added mod-frontend cuDNN frontend APIs, operation graph construction, plans, and user-facing wrappers. orig-nv-eng Reported or requested by NVIDIA engineering. cat-enhancements labels Jul 16, 2026
@Anerudhan Anerudhan added this to the Frontend 1.27.0 milestone Jul 16, 2026
@Anerudhan

Copy link
Copy Markdown
Collaborator

@cudnn-ci-bot run

@cudnn-ci-bot

Copy link
Copy Markdown

🚀 Running mirror pipeline

Branch: cudnn-gh/pr-400-2d82817
Pipeline: 58345309

@Anerudhan
Anerudhan merged commit 1085001 into NVIDIA:develop Jul 16, 2026
1 check was pending

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
test/python/test_collect_env.py (2)

17-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the GPU Topology section too.

collect_env_info() also emits GPU Topology (python/cudnn/collect_env.py:502-519), but this whitelist omits it, so a missing section could regress without failing the test.

         "Environment Variables",
+        "GPU Topology",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/python/test_collect_env.py` around lines 17 - 28, Update the section
whitelist in the collect_env report test to include “GPU Topology” alongside the
existing expected sections. Keep the existing presence and dictionary-type
assertions unchanged so collect_env_info() regressions for that section are
detected.

52-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test the CLI --json path, not just dictionary serialization.

json.dumps(report) can pass even if main() mishandles --json or prints invalid output. Invoke the CLI (or main() with patched arguments), capture stdout, and validate it with json.loads().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/python/test_collect_env.py` around lines 52 - 54, Update
test_json_serializable to exercise the CLI --json path by invoking main() or the
CLI with patched arguments, capturing stdout, and parsing the emitted output
with json.loads(). Preserve the report fixture while validating the actual
command output rather than only calling json.dumps(report).
README.md (1)

158-167: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document both output modes and the standalone command.

The collector supports python -m cudnn.collect_env --json, but the README only documents Markdown output. Also show the fallback command explicitly, e.g. python collect_env.py, so the recovery path is directly copy-pastable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 158 - 167, Update the “Environment report” section to
document both default Markdown output and the JSON mode using the --json option.
Make the broken-import fallback explicitly copy-pastable by showing the
standalone command as python collect_env.py after downloading collect_env.py,
while preserving the existing module invocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/cudnn/collect_env.py`:
- Around line 451-460: Update the library-report construction around by_dir and
_describe_lib_dir so loaded paths and disk-only paths are rendered as separate
entries. Iterate over loaded[family] and on_disk[family] - loaded[family]
independently, preserving each exact loaded copy and labeling only loaded paths
as LOADED, including when both sets share a directory.
- Around line 112-121: Use a shared distribution-name normalization helper for
both _installed_distributions and the requirement-name handling around lines
287–290. The helper must strip whitespace, lowercase names, and canonicalize
dots, underscores, and hyphens consistently so equivalent names resolve to the
same key and existing package/pin diagnostics remain complete.
- Around line 486-490: Update _get_env_vars to exclude or redact environment
entries whose names indicate credentials, such as API keys, tokens, passwords,
or secrets, even when they match _ENV_PREFIXES or _ENV_EXACT. Preserve the
existing collection of non-sensitive diagnostic variables and ensure the
returned data is safe to print in public bug reports.

---

Nitpick comments:
In `@README.md`:
- Around line 158-167: Update the “Environment report” section to document both
default Markdown output and the JSON mode using the --json option. Make the
broken-import fallback explicitly copy-pastable by showing the standalone
command as python collect_env.py after downloading collect_env.py, while
preserving the existing module invocation.

In `@test/python/test_collect_env.py`:
- Around line 17-28: Update the section whitelist in the collect_env report test
to include “GPU Topology” alongside the existing expected sections. Keep the
existing presence and dictionary-type assertions unchanged so collect_env_info()
regressions for that section are detected.
- Around line 52-54: Update test_json_serializable to exercise the CLI --json
path by invoking main() or the CLI with patched arguments, capturing stdout, and
parsing the emitted output with json.loads(). Preserve the report fixture while
validating the actual command output rather than only calling
json.dumps(report).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2e5402a3-a09d-4a44-bb23-72b2db3c759c

📥 Commits

Reviewing files that changed from the base of the PR and between 1df2e37 and 2d82817.

📒 Files selected for processing (4)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • README.md
  • python/cudnn/collect_env.py
  • test/python/test_collect_env.py

Comment on lines +112 to +121
def _installed_distributions():
"""{normalized_name: version} for every installed distribution."""
import importlib.metadata

dists = {}
for dist in importlib.metadata.distributions():
name = (dist.metadata.get("Name") or "").strip()
if name:
dists[name.lower()] = dist.version
return dists

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Canonicalize distribution names consistently.

Lines 118–120 only lowercase metadata names, while Lines 287–290 normalize requirement names by replacing ., _, and -. Equivalent names such as transformer_engine and transformer-engine therefore fail lookup, producing incomplete package and pin diagnostics.

Use one normalization helper for both paths.

Also applies to: 287-290

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/collect_env.py` around lines 112 - 121, Use a shared
distribution-name normalization helper for both _installed_distributions and the
requirement-name handling around lines 287–290. The helper must strip
whitespace, lowercase names, and canonicalize dots, underscores, and hyphens
consistently so equivalent names resolve to the same key and existing
package/pin diagnostics remain complete.

Comment on lines +451 to +460
by_dir = {}
for p in loaded[family] | on_disk[family]:
by_dir.setdefault(os.path.dirname(p), set()).add(p)
if not by_dir:
continue
loaded_dirs = {os.path.dirname(p) for p in loaded[family]}
lines = []
for d in sorted(by_dir, key=lambda d: (d not in loaded_dirs, d)):
state = "LOADED " if d in loaded_dirs else "on disk"
lines.append(f"{state} {_describe_lib_dir(family, d, by_dir[d], dists)}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve which exact library copy is loaded.

The union on Line 452 merges loaded and disk-only versions by directory, then Line 459 labels the entire directory LOADED. If one directory contains multiple versions, the report shows all versions as loaded and cannot identify the mapped copy—the primary diagnostic this section promises.

Render loaded[family] and on_disk[family] - loaded[family] separately, even when they share a directory.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/collect_env.py` around lines 451 - 460, Update the
library-report construction around by_dir and _describe_lib_dir so loaded paths
and disk-only paths are rendered as separate entries. Iterate over
loaded[family] and on_disk[family] - loaded[family] independently, preserving
each exact loaded copy and labeling only loaded paths as LOADED, including when
both sets share a directory.

Comment on lines +486 to +490
def _get_env_vars():
info = {}
for k in sorted(os.environ):
if k.startswith(_ENV_PREFIXES) or k in _ENV_EXACT:
info[k] = os.environ[k]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Redact credentials before printing environment variables.

Broad prefixes such as NVIDIA_, CUDA_, and TORCH_ can match API keys, tokens, or passwords. Because this output is intended for public bug reports, redact sensitive names while retaining diagnostic variables.

Proposed fix
 def _get_env_vars():
     info = {}
     for k in sorted(os.environ):
         if k.startswith(_ENV_PREFIXES) or k in _ENV_EXACT:
-            info[k] = os.environ[k]
+            if re.search(r"(?:TOKEN|SECRET|PASSWORD|API_KEY|CREDENTIAL|AUTH)", k, re.I):
+                info[k] = "<redacted>"
+            else:
+                info[k] = os.environ[k]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def _get_env_vars():
info = {}
for k in sorted(os.environ):
if k.startswith(_ENV_PREFIXES) or k in _ENV_EXACT:
info[k] = os.environ[k]
def _get_env_vars():
info = {}
for k in sorted(os.environ):
if k.startswith(_ENV_PREFIXES) or k in _ENV_EXACT:
if re.search(r"(?:TOKEN|SECRET|PASSWORD|API_KEY|CREDENTIAL|AUTH)", k, re.I):
info[k] = "<redacted>"
else:
info[k] = os.environ[k]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/collect_env.py` around lines 486 - 490, Update _get_env_vars to
exclude or redact environment entries whose names indicate credentials, such as
API keys, tokens, passwords, or secrets, even when they match _ENV_PREFIXES or
_ENV_EXACT. Preserve the existing collection of non-sensitive diagnostic
variables and ensure the returned data is safe to print in public bug reports.

@Anerudhan Anerudhan mentioned this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat-enhancements mod-frontend cuDNN frontend APIs, operation graph construction, plans, and user-facing wrappers. orig-nv-eng Reported or requested by NVIDIA engineering.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants