Skip to content

fix(edge): discover rocm-smi/amd-smi by absolute path + amdgpu dmesg - #39

Open
rishi-anand wants to merge 1 commit into
spectrocloud:mainfrom
rishi-anand:fix/gpu-info-rocm-amd-smi-discovery
Open

fix(edge): discover rocm-smi/amd-smi by absolute path + amdgpu dmesg#39
rishi-anand wants to merge 1 commit into
spectrocloud:mainfrom
rishi-anand:fix/gpu-info-rocm-amd-smi-discovery

Conversation

@rishi-anand

Copy link
Copy Markdown
Contributor

Summary

On Kairos-based edge hosts the ROCm tooling ships inside GPU-workload containers, not on the host, and it's installed under a versioned directory like /opt/rocm-7.2.1/bin/ that is NOT on the default PATH. The previous logic used command -v / which, which returned nothing even when the binary was there — so bundles arrived with no rocm-smi or amd-smi output, and amd-smi (the modern replacement) wasn't attempted at all.

  • Add find-rocm-tool / find-rocm-tool-in-pod helpers: check PATH, then well-known ROCm install dirs (/opt/rocm/bin, /opt/rocm-*/bin, /usr/local/bin, /usr/bin), then fall back to find /opt / find /opt /usr. All discovered binaries are invoked by absolute path.
  • Attempt both rocm-smi (existing) and amd-smi (new). Capture version, list, static, metric, firmware, bad-pages, topology.
  • Emit rocm-smi-status when neither is found — documents exactly where the script searched so bundle readers can distinguish a missed collection from a genuine absence.
  • Collect dmesg -T | grep -iE "amdgpu|drm|pcieport" — kernel-level GPU driver / DRM / PCIe AER events that userspace tooling doesn't surface.
  • Ordering fix: move set-kubeconfig before gpu-info in the main flow. gpu-info uses kubectl exec as its in-pod fallback, but on Palette edge hosts KUBECONFIG is only set by set-kubeconfig; without this reorder the kubectl fallback silently no-op'd every run.

Test plan

  • Ran the updated collector on an AMD Instinct MI325 edge appliance.
  • gpu/amd/amdgpu-dmesg.log populated with pcieport/pciehp events.
  • gpu/amd/amd-smi-version.txtAMDSMI Tool: 26.2.2 | AMDSMI Library: 26.2.2 | ROCm: 7.2.1 | amdgpu: 6.16.13 | hsmp: 2.5.
  • gpu/amd/amd-smi-list.txt — enumerates all attached GPUs with BDF / UUID / KFD_ID / NODE_ID.
  • Console log confirms discovery: Collecting amd-smi via amd-gpu-operator/pod/default-metrics-exporter-xnsnn (/opt/rocm/bin/amd-smi).
  • bash -n passes.

🤖 Generated with Claude Code

On Kairos-based edge hosts the ROCm tooling ships inside GPU-workload
containers, not on the host, and it's installed under a versioned
directory like /opt/rocm-7.2.1/bin/ that is NOT on the default PATH.
The previous logic used `command -v` / `which`, which returned nothing
even when the binary was present — so support bundles arrived without
any rocm-smi or amd-smi output. amd-smi wasn't attempted at all.

Changes to gpu-info():

- Add find-rocm-tool() and find-rocm-tool-in-pod() helpers that search
  PATH, well-known ROCm install paths (/opt/rocm/bin, /opt/rocm-*/bin,
  /usr/local/bin, /usr/bin), and fall back to `find /opt` / `find /opt
  /usr` when the versioned dir isn't matched. All discovered binaries
  are invoked by absolute path — no PATH dependency.
- Attempt both rocm-smi (existing) and amd-smi (new — the modern
  replacement). Capture version, list, static, metric, firmware,
  bad-pages, topology from amd-smi.
- Emit a rocm-smi-status file when neither tool is found anywhere,
  documenting exactly where we searched so bundle readers can tell a
  missed collection from a genuine absence.
- Collect `dmesg -T | grep -iE "amdgpu|drm|pcieport"` — kernel-level
  GPU driver / DRM / PCIe events that userspace tooling doesn't
  surface. Falls back to non-`-T` dmesg on older utils.

Ordering fix: move set-kubeconfig to run before gpu-info in the main
flow. gpu-info uses `kubectl exec` as its in-pod fallback, but on
Palette edge hosts KUBECONFIG is only set by set-kubeconfig; without
this reorder the kubectl fallback silently no-op'd on every collection.

Verified end-to-end on an MI325 edge appliance:
- amdgpu-dmesg.log populated with pcieport/pciehp events
- amd-smi-version.txt returns AMDSMI 26.2.2 / ROCm 7.2.1 / amdgpu 6.16.13
- amd-smi-list.txt enumerates all attached GPUs (BDF, UUID, KFD_ID)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rishi-anand
rishi-anand requested a review from a team as a code owner August 2, 2026 20:26
@rishi-anand

Copy link
Copy Markdown
Contributor Author

Verified on live AMD Instinct MI325 edge appliance (Kairos host, amd-gpu-operator running):

  • gpu/amd/amdgpu-dmesg.log populated — pcieport / pciehp / DRM events with -T timestamps.
  • gpu/amd/amd-smi-version.txtAMDSMI Tool: 26.2.2 | AMDSMI Library: 26.2.2 | ROCm: 7.2.1 | amdgpu: 6.16.13 | hsmp: 2.5.
  • gpu/amd/amd-smi-list.txt — enumerates all attached GPUs with BDF / UUID / KFD_ID / NODE_ID / PARTITION_ID.
  • Console log confirms path-based discovery: Collecting amd-smi via amd-gpu-operator/pod/default-metrics-exporter-xnsnn (/opt/rocm/bin/amd-smi).
  • rocm-smi legitimately absent in the exporter pod (ships amd-smi only) — script correctly captures whichever is present.
  • Confirmed the ordering fix: without moving set-kubeconfig above gpu-info, the same run only wrote rocm-smi-status ("not found in any candidate pod") because KUBECONFIG was still unset when the pod loop ran.
  • bash -n passes on the final script.

@brathina-spectro brathina-spectro 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.

Changes looks good except the mongo collection related block getting deleted.

} >> "${TMPDIR}/mongo/disk-usage.txt"
done < <(printf '%s\n' "$MONGO_PODS")

techo "Collecting MongoDB database + collection sizes"

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.

Is this being deleted accidentally? We saw a few cases where the mongoDb grew more than expected and so the SB was enhanced to gather info about mongoDb collection.

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.

2 participants