Skip to main content

A professional tool for auditing NVIDIA NIM containers

Project description

nim-audit

Stop deploying NIM containers blind.

A professional CLI tool for auditing NVIDIA NIM containers before they hit production.

License Python Stars

Installation โ€ข Quick Start โ€ข Commands โ€ข User Guide


Why nim-audit?

Ever upgraded a NIM container and had everything crash 10 minutes later?

nim-audit catches what humans miss:

  • ๐Ÿ”„ Breaking changes between container versions
  • ๐ŸŽฎ GPU compatibility issues before deployment
  • โš™๏ธ Environment variable risks and impacts
  • ๐Ÿ“‹ Policy violations that slip through review
  • ๐Ÿ” Behavioral drift between model versions

One command before every upgrade. Never be surprised again.


Installation

pip install nim-audit

Requirements: Python 3.11+

For development:

git clone https://github.com/ashzak/nim-audit.git
cd nim-audit
pip install -e ".[dev]"

Quick Start

Compare versions before upgrading

nim-audit diff nvcr.io/nim/llama3:1.0.0 nvcr.io/nim/llama3:1.1.0
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Diff Report โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Source: nvcr.io/nim/llama3:1.0.0                                  โ”‚
โ”‚ Target: nvcr.io/nim/llama3:1.1.0                                  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โš ๏ธ  Breaking Changes Detected
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
โ€ข API: /v1/completions response schema changed
โ€ข Config: NIM_MAX_BATCH_SIZE default: 4 โ†’ 8
โ€ข Requirement: Min GPU memory increased to 24GB

Check GPU compatibility

nim-audit compat --image nvcr.io/nim/llama3:1.1.0 --gpu A10
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Compatibility Report โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Image: nvcr.io/nim/llama3:1.1.0                                     โ”‚
โ”‚ Status: โœ… COMPATIBLE                                               โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Lint your environment file

nim-audit env lint --env-file production.env
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Environment Lint Report โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Status: โš ๏ธ  WARN                                                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ”ƒ Severity โ”ƒ Variable           โ”ƒ Message                             โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ WARN     โ”‚ NIM_MAX_BATCH_SIZE โ”‚ Registry marks as increasing memory โ”‚

Commands

Command Description
diff Compare two NIM versions, detect breaking changes
config Analyze configuration with impact assessment
compat Check GPU and driver compatibility
lint Validate against enterprise policies
fingerprint Compare runtime behavioral signatures
cluster Scan Kubernetes cluster compatibility
env Environment variable analysis suite

diff

Compare two NIM container versions:

# Basic diff
nim-audit diff old:tag new:tag

# Only breaking changes
nim-audit diff old:tag new:tag --breaking-only

# JSON output for CI/CD
nim-audit diff old:tag new:tag --format json --output report.json

# Filter by category
nim-audit diff old:tag new:tag --category api

Categories: metadata, model, tokenizer, api, runtime, layer, config, environment


config

Analyze NIM configuration and environment variables:

# Analyze image configuration
nim-audit config --image nvcr.io/nim/llama3:1.1.0

# With your env file
nim-audit config --image nvcr.io/nim/llama3:1.1.0 --env-file prod.env

# Validate configuration
nim-audit config --image nvcr.io/nim/llama3:1.1.0 --env-file prod.env --validate

# Show all options including defaults
nim-audit config --image nvcr.io/nim/llama3:1.1.0 --all

compat

Check GPU and driver compatibility:

# Check specific GPU
nim-audit compat --image nvcr.io/nim/llama3:1.1.0 --gpu A100

# With driver version
nim-audit compat --image nvcr.io/nim/llama3:1.1.0 --gpu A10 --driver 535.104.05

# Auto-detect local GPU
nim-audit compat --image nvcr.io/nim/llama3:1.1.0 --detect

Supported GPUs: A10, A100, H100, L4, L40, L40S, T4, V100, A6000, RTX 4090, RTX 6000


lint

Validate containers against policies:

# Lint with built-in rules
nim-audit lint --image nvcr.io/nim/llama3:1.1.0

# Custom enterprise policy
nim-audit lint --image nvcr.io/nim/llama3:1.1.0 --policy enterprise.yaml

# Only show errors
nim-audit lint --image nvcr.io/nim/llama3:1.1.0 --severity error

Built-in rules:

  • nim-001: Require version label
  • nim-002: No root user
  • nim-003: Require model name
  • nim-004: Check exposed ports
  • nim-005: No sensitive environment variables
Custom Policy Example
name: enterprise-policy
version: "1.0.0"

rules:
  - id: ent-001
    name: require-security-scan
    description: Image must have security scan label
    severity: error
    condition: labels['security.scan.status'] == 'passed'
    remediation: Run security scan and add label

  - id: ent-002
    name: max-batch-size
    description: Batch size must not exceed 64
    severity: warning
    condition: int(env.get('NIM_MAX_BATCH_SIZE', '1')) <= 64

fingerprint

Generate and compare behavioral signatures:

# Generate fingerprint from running container
nim-audit fingerprint --image nvcr.io/nim/llama3:1.0.0 \
                      --endpoint http://localhost:8000 \
                      --output v1.0.0.json

# Compare two fingerprints
nim-audit fingerprint compare v1.0.0.json v1.1.0.json --tolerance 0.05

cluster

Scan Kubernetes cluster for NIM compatibility:

# Scan cluster
nim-audit cluster --image nvcr.io/nim/llama3:1.1.0

# Specific context
nim-audit cluster --image nvcr.io/nim/llama3:1.1.0 --context production

env

Environment variable analysis tools:

# Lint environment file
nim-audit env lint --env-file prod.env

# Describe a variable
nim-audit env describe NIM_MAX_BATCH_SIZE

# Diff two env files
nim-audit env diff staging.env production.env

# List all known variables
nim-audit env registry-list

Library API

Use nim-audit programmatically:

from nim_audit import NIMImage, DiffEngine, ConfigAnalyzer, CompatChecker

# Load images
img1 = NIMImage.from_local("nvcr.io/nim/llama3:1.0.0")
img2 = NIMImage.from_local("nvcr.io/nim/llama3:1.1.0")

# Diff
engine = DiffEngine()
result = engine.diff(img1, img2)
for bc in result.report.breaking_changes:
    print(f"Breaking: {bc.title}")

# Config analysis
analyzer = ConfigAnalyzer()
result = analyzer.analyze(img2, env={"NIM_MAX_BATCH_SIZE": "64"})
for entry in result.report.entries:
    print(f"{entry.name}: {entry.impact.level}")

# Compatibility
checker = CompatChecker()
result = checker.check(img2, gpu="A100")
print(f"Compatible: {result.report.compatible}")

CI/CD Integration

Add nim-audit to your pipeline:

# .github/workflows/nim-validate.yml
name: NIM Validation

on:
  pull_request:
    paths:
      - 'k8s/nim/*.yaml'
      - '.env.nim'

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install nim-audit
        run: pip install nim-audit

      - name: Lint environment
        run: nim-audit env lint --env-file .env.nim

      - name: Check compatibility
        run: nim-audit compat --image ${{ vars.NIM_IMAGE }} --gpu A100

      - name: Policy check
        run: nim-audit lint --image ${{ vars.NIM_IMAGE }} --policy policies/enterprise.yaml

Configuration

Create ~/.nim-audit.yaml:

cache:
  enabled: true
  ttl: 3600

registry:
  ngc_api_key: ${NGC_API_KEY}

output:
  default_format: terminal
  color: true

lint:
  include_builtin: true
  fail_on_warning: false

# Shortcuts for common images
aliases:
  llama3: nvcr.io/nim/meta/llama3-8b-instruct:latest
  llama3-70b: nvcr.io/nim/meta/llama3-70b-instruct:latest

Environment Variables:

  • NGC_API_KEY: NVIDIA NGC API key
  • NIM_AUDIT_CONFIG: Config file override
  • NIM_AUDIT_NO_COLOR: Disable colors

Documentation


Architecture

nim-audit/
โ”œโ”€โ”€ src/nim_audit/
โ”‚   โ”œโ”€โ”€ cli/          # CLI commands (Typer)
โ”‚   โ”œโ”€โ”€ core/         # Core domain logic
โ”‚   โ”‚   โ””โ”€โ”€ env/      # Environment analysis
โ”‚   โ”œโ”€โ”€ extractors/   # Artifact extractors
โ”‚   โ”œโ”€โ”€ registry/     # Container registry clients
โ”‚   โ”œโ”€โ”€ renderers/    # Output formatters
โ”‚   โ”œโ”€โ”€ models/       # Pydantic data models
โ”‚   โ”œโ”€โ”€ knowledge/    # NIM knowledge base
โ”‚   โ””โ”€โ”€ utils/        # Utilities
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ unit/         # Unit tests
    โ””โ”€โ”€ integration/  # Integration tests

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Make your changes
  4. Run tests (pytest)
  5. Submit a pull request

License

MIT - Use it however you want.


Built to prevent production incidents.
Star โญ if this saved you from a 3am page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nim_audit-0.1.0.tar.gz (114.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nim_audit-0.1.0-py3-none-any.whl (124.7 kB view details)

Uploaded Python 3

File details

Details for the file nim_audit-0.1.0.tar.gz.

File metadata

  • Download URL: nim_audit-0.1.0.tar.gz
  • Upload date:
  • Size: 114.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for nim_audit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a561855962ea11f80bcc6f20c290ec8370c196050be558e4b9075ce0e521efcb
MD5 da954e51de5c41ea9b5e7a11f0874561
BLAKE2b-256 9a6e62c5817c390310fe710e656b32cf71e64e66bb4e967230b83f5fef073f07

See more details on using hashes here.

File details

Details for the file nim_audit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nim_audit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 124.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for nim_audit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2c69cf74c9afcca1f7d95411a53e1307e7ec19ec0a948838c52018e29229893
MD5 a0ac9ce987dfd44d61de2a067c387b19
BLAKE2b-256 b1912870c301b0e6be0e0a2d0537cd985d4d06133b8a9c6d498cff1e2f0f2beb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page