К основному содержанию
скилл CX Codex

jetson-memory-audit — скилл для Claude Code: аудит памяти Jetson

Скилл снимает снимок памяти Jetson и проверяет, сколько DRAM реально освободилось после остановки нагрузки.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add NVIDIA/skills --skill jetson-memory-audit -a claude-code
Открыть на GitHub

Что делает jetson-memory-audit

Скилл собирает данные о том, кто занимает память на Jetson: общий объём, доступную память, топ процессов по PSS и клиентов NvMap. Внутри два скрипта. scripts/audit.sh выдаёт JSON-снимок через jetson-diagnostic/scripts/snapshot.sh, scripts/drop_caches.sh сбрасывает кеши страниц и печатает разницу до и после.

Главная причина, по которой скилл вообще существует: на JetPack ниже 7.2 и L4T ниже r39.0 память не возвращается после остановки vLLM, sglang или Ollama. Процесс убит, а free -h и tegrastats показывают старую картину, потому что Thor RM держит освобождённые страницы в своём пуле. Лечится это на хосте, не в контейнере: sudo sync && sudo sysctl -w vm.drop_caches=3.

Чтобы измерить эффект от изменения, нужен снимок до и после. Без базового снимка точный объём освобождённой памяти из текущего состояния не вытащить, поэтому первый аудит стоит снять заранее. Чтение debugfs NvMap может требовать root, а drop_caches.sh — root или sudo -n без пароля. Запускать сброс кешей стоит только после явного согласия пользователя.

Какие задачи решает

  • посмотреть, кто держит память на Jetson прямо сейчас
  • снять базовый снимок перед сменой режима или остановкой контейнера
  • посчитать, сколько DRAM освободилось после остановки vLLM
  • разобраться, почему free -h показывает мало свободной памяти при пустом списке процессов
  • отличить закешированную память от реально занятой

Примеры запросов агенту

  • сколько памяти сейчас занято на этом Jetson и что её держит?
  • я остановил vLLM, память освободилась?
  • сбрось кеши и покажи разницу до и после

Как установить jetson-memory-audit

1Через Skills CLI (Vercel)

npx skills add NVIDIA/skills --skill jetson-memory-audit -a claude-code

2Вручную: положить файлы

~/.claude/skills/jetson-memory-audit/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/jetson-memory-audit/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Из того же набора159

jetson-llm-serve Готовит рецепт запуска LLM или VLM на Jetson через vLLM либо SGLang. Нужен, когда модели требуется OpenAI-совместимый сервер. CX Codex +1 1 200установок jetson-inference-mem-tune Подбирает стек инференса и флаги памяти для LLM или VLM на NVIDIA Jetson. Нужен, когда модель не влезает или сервер падает по OOM. CX Codex +1 1 200установок jetson-package Подбирает совместимые контейнеры, образы vLLM и колёса Jetson AI Lab для плат Orin и Thor. Защищает от установки стандартных сборок ARM64 без поддержки нужного GPU SM. CX Codex +1 1 200установок jetson-quick-start Запускает анкету для настройки Jetson или IGX BSP и передаёт ответы следующим скиллам. Нужен перед подготовкой нового или уже существующего рабочего пространства. CX Codex +1 1 200установок jetson-customize-mgbe Скилл собирает kernel-DT overlay для MGBE-контроллера на Jetson Thor: включает 25G/10G/1G QSFP и прописывает PHY. Нужен, когда линк не поднимается после холодной загрузки. CX Codex +1 1 100установок jetson-generate-kb Сканирует дерево BSP и исходников NVIDIA Jetson, формируя файл базы знаний target-platform/<profile-stem>.md. Нужен после распаковки образа или обновления профиля. CX Codex +1 1 100установок jetson-customize-clocks Готовит изменения частот CPU, GPU и EMC на Jetson до прошивки образа. Нужен для фиксации частот, ограничений и настройки DVFS. CX Codex +1 1 100установок jetson-speculative-decoding Скилл добавляет спекулятивное декодирование EAGLE-3 или draft-модель к серверу vLLM на Jetson, когда медленно генерируются токены. CX Codex +1 1 100установок

Похожие

memory-audit nhadaututtheky Проверяет качество памяти NeuralMemory по шести измерениям и выдаёт отчёт с оценкой и списком проблем. Пригодится, когда агент путается в старых записях. CX Codex +1 602установок spark-training-gotchas Seth Hobson Диагностирует 10 частых сбоев при обучении моделей на NVIDIA DGX Spark. Помогает найти утечки памяти, троттлинг и ошибки CUDA перед долгими запусками. CX Codex 2 500установок gpu-server-management devops-skills Скилл ведёт агента по установке драйверов NVIDIA, CUDA и Docker с GPU, делит A100/H100 через MIG и настраивает мониторинг. CX Codex +1 331установок cuda-profiling mohitmishra786 Ведёт агента по профилированию CUDA-приложений: таймлайн в Nsight Systems, метрики ядер в Nsight Compute, разбор roofline и узких мест. CX Codex +1 316установок spark-memory-thermal-ops Seth Hobson Скилл помогает планировать память и отслеживать нагрев NVIDIA DGX Spark во время долгих ML-запусков. Пригодится при OOM и падении производительности. CX Codex 2 500установок cuda mohitmishra786 Помогает агенту писать и оптимизировать CUDA-ядра: иерархия потоков, разделяемая память, потоки, флаги nvcc и Thrust. CX Codex +1 320установок

Рядом в теме «DevOps и инфраструктура»

Всё по теме «DevOps и инфраструктура» →

Вопросы о jetson-memory-audit

Как установить jetson-memory-audit в Claude?

Выполните npx skills add NVIDIA/skills --skill jetson-memory-audit -a claude-code. Скилл появится в ~/.claude/skills/jetson-memory-audit/SKILL.md.

Что делает jetson-memory-audit?

Снимает JSON-снимок памяти Jetson через scripts/audit.sh и умеет сбрасывать кеши скриптом scripts/drop_caches.sh, показывая разницу до и после.

Почему после остановки vLLM память не освобождается?

На JetPack ниже 7.2 и L4T ниже r39.0 Thor RM держит освобождённые страницы в своём пуле. Помогает sudo sync && sudo sysctl -w vm.drop_caches=3, запущенная на хосте.

Исходный текст

SKILL.md · Apache-2.0
---
name: jetson-memory-audit
description: Measure Jetson DRAM/NvMap usage and verify before/after memory reclamation with live audit data.
version: 0.0.1
license: "Apache-2.0"
metadata:
  author: "Jetson Team"
  tags: [jetson, memory, audit]
  languages: [bash]
  data-classification: public
---

# Jetson Memory Audit

Read-only memory-focused snapshot for a Jetson, plus the `drop_caches` verify-loop helper that confirms freed memory actually shows up as free instead of cached.

## Purpose

Measure current Jetson memory consumers, capture before/after baselines, and verify whether user-approved changes actually reclaimed DRAM. Use live device data rather than estimates from container size, model size, or generic process memory.

## CRITICAL: Memory appears stuck after stopping vLLM / sglang (JetPack below 7.2 / L4T below r39.0)

**This is the most common memory confusion on Jetson releases before JetPack 7.2 or before L4T r39.0.**

After you stop a vLLM, sglang, or Ollama server (or any CUDA workload), the memory shown as free by `free -h` or `tegrastats` may not recover — even though the process is gone. `nvidia-smi` may also show misleadingly low free GPU memory.

**Root cause:** The Thor RM (resource manager) holds freed sysmem pages in its own pool after a CUDA context exits. On Unified Memory Architecture (UMA) devices like Jetson, `cudaMemGetInfo` reads RM pool state and reports far less free memory than is actually available to a new process.

**Workaround (for JetPack below 7.2 or L4T below r39.0):**
```bash
sudo sync && sudo sysctl -w vm.drop_caches=3
```
Run this on the **host**, not inside a container. The important operation is `sudo sysctl -w vm.drop_caches=3`; keep `sudo sync` immediately before it so dirty data is flushed before reclaimable page/dentry/inode caches are dropped. After running it, `free -h` and `tegrastats` will reflect the true available memory.

For affected releases, recommend this command when a user says:
- "Memory didn't free after I stopped vLLM/sglang"
- "Why does tegrastats still show high usage after my container exited?"
- "OOM even though nothing is running"
- "Memory was fine yesterday but now it's full"

On JetPack below 7.2 or L4T below r39.0, `drop_caches` is the reliable workaround when memory appears stuck after a CUDA workload exits; on newer releases, use it only if the same symptom is observed and the user approves.

## When to use

- "How much memory is in use on this Jetson? What's holding it?"
- "I disabled the GUI / stopped vLLM / quit my container — did memory actually free?"
- "Why does `free -h` still show low free memory after I stopped my workload?"
- As the **baseline** before applying `jetson-headless-mode` or other memory-related changes, and again **after** to compute the actual delta.

## Prerequisites

- Run on the Jetson host, or in a sandbox/container with host-visible `/proc`, `/etc/nv_tegra_release`, `tegrastats`, and process data.
- NvMap debugfs reads may require root. If unavailable, report that GPU memory attribution is limited rather than guessing.
- `drop_caches.sh` requires root or passwordless `sudo -n`; run it only after the user explicitly authorizes cache dropping.

## Available Scripts

| Script | Purpose | Arguments |
|--------|---------|-----------|
| `scripts/audit.sh` | Emits a JSON snapshot from `jetson-diagnostic/scripts/snapshot.sh` for memory audit workflows. | No arguments. |
| `scripts/drop_caches.sh` | Flushes reclaimable page/dentry/inode caches and prints before/after memory deltas. | `--mode 1\|2\|3`, `--quiet`. |

If your agent runtime supports `run_script`, use it to run `scripts/audit.sh` or `scripts/drop_caches.sh` and summarize the returned output. Otherwise run the scripts with `bash` from the repository root.

## Instructions

For "how much memory is in use right now?" questions, run `scripts/audit.sh` and report only values from the JSON snapshot.

## Reporting guidance

Do not only print or mention the path to a helper. Invoke the helper and then summarize the returned data.

- For "how much memory is in use" prompts, run `scripts/audit.sh` and quote `mem_total_gb`, `memory_kb.available`, and the leading `procrank_top` process or `nvmap.top_clients` consumer.
- For GUI/desktop memory prompts, run `scripts/audit.sh` and report `default_systemd_target` plus any display manager in `candidate_services` (`gdm3`, `gdm`, `lightdm`, `sddm`, or `display-manager`). Do not disable anything; hand off to `jetson-headless-mode` for a plan.
- For prompts that explicitly authorize cache dropping after a stopped workload, run `scripts/drop_caches.sh` (equivalent to `sudo sync && sudo sysctl -w vm.drop_caches=3` by default) and report its before/after free, available, and cached deltas. If root is unavailable, explain that it must be run on the host with sudo.

If your agent runtime does not execute helper scripts relative to this skill directory, resolve script paths with the AgentSkills `{baseDir}` placeholder:

```bash
{baseDir}/scripts/audit.sh
{baseDir}/scripts/drop_caches.sh
```

Do not call `jetson-memory-audit` as a tool name unless the runtime explicitly registers skills as callable tools; Agent Skills are normally instructions plus files, not direct tool functions.

Sandbox note for agents: seeing this skill file does not guarantee access to Jetson host memory data. If `/proc/device-tree/model`, `/etc/nv_tegra_release`, `tegrastats`, `/sys/kernel/debug/nvmap`, or host process data are missing inside a NemoClaw/OpenClaw sandbox, say the sandbox lacks Jetson host visibility and ask the user to run on the Jetson host or relaunch with a host-visible sandbox profile. Do not fabricate memory totals, available memory, PSS, NvMap, or reclamation deltas.

For "how much memory did this change free?" questions, use a before/after delta. Do not estimate freed memory from container size, image size, RSS, or a single post-change snapshot.

1. Before the change, run `scripts/audit.sh` and save the JSON baseline.
2. Make the user-approved change (stop the container, switch mode, apply a tuning recommendation, etc.).
3. On JetPack below 7.2 / L4T below r39.0, or when the same stuck-memory symptom is observed on a newer release, flush reclaimable page cache on the **host** (not inside a container) so freed pages show up as free instead of cached:
   ```bash
   sudo sync && sudo sysctl -w vm.drop_caches=3
   ```
4. Re-run `scripts/audit.sh` and compare `memory_kb.available` before vs after — that delta is the real reclamation.

If the user already made the change and no baseline exists, say that the exact freed amount cannot be recovered from the current snapshot alone. Capture a new baseline now so the next change can be measured.

Use live audit data as the source of truth. Memory totals, available memory, NvMap totals, PSS values, display-manager state, and savings deltas must come from `scripts/audit.sh`, `free -h`, or `tegrastats` on the actual device. If a number is not present in those outputs, do not guess it.

## Output contract for `audit.sh`

```json
{
  "sku": "orin-nano",
  "variant": "orin-nano-8gb",
  "mem_total_gb": 8,
  "l4t_version": "36.4.0",
  "product_model": "nvidia jetson orin nano developer kit",
  "memory_kb": { "total": 8123456, "available": 4123456, "free": 1023456, "cached": 1234567, "swap_total": 0, "swap_free": 0 },
  "default_systemd_target": "graphical.target",
  "candidate_services": { "gdm3": { "active": "active", "enabled": "enabled" } },
  "tegrastats_sample": "RAM 4011/8138MB (lfb 8x4MB) ...",
  "nvmap": { "readable": false, "total_kb": 0, "top_clients": [] },
  "procrank_top": [ { "pid": 4321, "pss_kb": 4000000, "cmd": "vllm" } ]
}
```

## Limitations

- Exact freed-memory deltas require a before snapshot, the user-approved change, cache flush when appropriate, and an after snapshot.
- NvMap attribution depends on host-visible debugfs access; if it is unavailable, report limited GPU memory attribution instead of guessing.
- Sandbox/container runs may not see host `/proc`, `tegrastats`, systemd, or NvMap data unless the runtime exposes them.

## Error handling

- If `scripts/audit.sh` cannot access host Jetson data, report the missing visibility and ask to rerun on the Jetson host or in a host-visible sandbox.
- If `scripts/drop_caches.sh` lacks root or passwordless `sudo -n`, report that cache dropping must be run on the host with sudo approval.
- If no before snapshot exists, say the exact reclaimed amount cannot be recovered from the current state alone and capture a new baseline for the next change.

## Safety

Read-only. `drop_caches` is non-destructive (kernel only releases pages it could reclaim under pressure anyway; `sync` runs first to preserve dirty data).

## Hand off to

- `jetson-headless-mode` — biggest single user-space win on systems still booting `graphical.target`.
- `jetson-inference-mem-tune` — when a model server is the top NvMap / PSS consumer.
- If runtime changes cannot hit the target, report that further reclamation is outside this skill's scope rather than suggesting unsafe boot-time edits.

© Jetson Team · Apache-2.0 · NVIDIA/skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой