Skills · Infrastructure & ops

Spark Environment Setup

Unverified30/40

Set up a working ML training/inference environment on NVIDIA DGX Spark (GB10, aarch64, CUDA 13). Use when installing PyTorch/Unsloth/TRL/vLLM on DGX Spark, hitting libcudart or wheel-ABI errors on aarch64, or choosing between NGC containers and bare pip installs.

Originally by wshobson · MIT

Claude CodePartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor·UnknownWe have not crawled the repo tree, so we will not guess
Codex·UnknownWe have not crawled the repo tree, so we will not guess
Gemini CLI·UnknownThe spec defines no detection rule for Gemini
Copilot·UnknownWe have not crawled the repo tree, so we will not guess
npx agentalley add spark-environment-setup

This command does not work yet — the CLI is still being built. Until then, use Raw in the reader below to take the file.

Who is stuck, and on what

Set up a working ML training/inference environment on NVIDIA DGX Spark (GB10, aarch64, CUDA 13). Use when installing PyTorch/Unsloth/TRL/vLLM on DGX Spark, hitting libcudart or wheel-ABI errors on aarch64, or choosing between NGC containers and bare pip installs.

The whole source

No sign-in, no blur, nothing truncated
spark-environment-setup/SKILL.md201 lines7.9 KBRawView on GitHub
Frontmatter — 2 properties
namespark-environment-setup
descriptionSet up a working ML training/inference environment on NVIDIA DGX Spark (GB10, aarch64, CUDA 13). Use when installing PyTorch/Unsloth/TRL/vLLM on DGX Spark, hitting libcudart or wheel-ABI errors on aarch64, or choosing between NGC containers and bare pip installs.
1---
2name: spark-environment-setup
3description: Set up a working ML training/inference environment on NVIDIA DGX Spark (GB10, aarch64, CUDA 13). Use when installing PyTorch/Unsloth/TRL/vLLM on DGX Spark, hitting libcudart or wheel-ABI errors on aarch64, or choosing between NGC containers and bare pip installs.
4---A5No allowed-tools declared — no way to tell what this skill may touch
5 
6# Spark Environment Setup
7 
8DGX Spark ships a GB10 Grace Blackwell chip: aarch64 CPU, SM121
9GPU, 128GB unified memory, CUDA 13. This is a narrower and
10younger platform than a standard x86 CUDA 12 box, so package
11selection and ABI matching matter more than usual — the wheel
12ecosystem for aarch64 + CUDA 13 is still filling in.
13 
14## When to Use This Skill
15 
16- Setting up a fresh Spark box for training or inference.
17- Hitting an import error mentioning `libcudart`, a missing
18 symbol, or a wheel that "installed fine but won't load."
19- A framework install (PyTorch, Unsloth, TRL, vLLM, xformers)
20 fails, hangs, or silently falls back to CPU.
21- Deciding whether to use an NGC container or bare pip.
22- Restoring a working setup after an OS reinstall or a
23 base-image update, needing to re-verify from scratch.
24 
25Each of these accepts the same general fix: match the
26container/wheel combination to CUDA 13 and SM121, don't fight
27the ABI.
28 
29## Container-First Rule
30 
31Quick decision, before the detail below:
32 
33- Standard training/inference work → NGC PyTorch container.
34- Unsloth-centric fine-tuning → Unsloth container (it ships
35 the pinned Triton/xformers/transformers combination already
36 validated for that path).
37- Neither fits (custom system package, local IDE interpreter)
38 → bare pip, following the exact sequence further down.
39 
40Default to a container. Use `nvcr.io/nvidia/pytorch:25.09-py3`
41as the base for general work — the newest tag confirmed working
42on this hardware; pull a newer blessed tag if locally available
43rather than hard-blocking on `25.11-py3`. NGC's tag is dated, so
44running it directly is fine:
45 
46```bash
47docker run --runtime=nvidia --gpus all -it --rm \
48 nvcr.io/nvidia/pytorch:25.09-py3
49```
50 
51`unsloth/unsloth:dgxspark-latest` is a *moving* tag by
52contrast — resolve and pin its digest before running it for
53anything reproducible; the bare tag is a discovery step only,
54not the default invocation. Full pull-inspect-pin sequence and
55flag rationale/volume mounts for `finetuning/` run dirs:
56`references/container-workflow.md`. Treat bare pip as the exception.
57 
58The reason for the container-first stance is pinning, not
59convenience. Triton, xformers, and transformers versions
60interact narrowly with GB10's SM121 target and CUDA 13; a
61container locks all of them together against a combination
62already validated on this hardware. Bare pip leaves that
63resolution to you, one broken import at a time.
64 
65When bare pip is warranted, follow the NVIDIA playbook's
66install sequence verbatim and in order:
67 
68```bash
69pip install "transformers==5.13.1" "peft==0.19.1" "hf_transfer==0.1.9" "datasets==4.3.0" "trl==1.8.0"
70pip install --no-deps "unsloth==2026.7.2" "unsloth_zoo==2026.7.2" "bitsandbytes==0.49.2"
71pip install -U "torchao==0.17.0"
72```
73 
74The second command's `--no-deps` flag is not optional —
75letting pip re-resolve Unsloth's dependency tree on aarch64 is
76a common way to pull in an incompatible torch or triton build.
77The third line is not optional either: the NGC base image's
78bundled `torchao` is too old for current `peft`'s LoRA-attach
79path (`ImportError: ... torchao ... only versions above 0.16.0
80are supported`) — a hard blocker, not a warning. Every `==` pin
81above is load-bearing, taken from the dated known-good version
82matrix in `references/stack-matrix.md` (its `Last verified` date
83governs staleness) — an unpinned install resolves current PyPI
84versions well outside what this Unsloth release supports.
85 
86Pull a fresh tag when a new blessed release is announced.
87Rebuild locally from one of the two bases only when a project
88needs an extra system package layered in — not to "upgrade" a
89component the image already pins. Details on both paths:
90`references/container-workflow.md`.
91 
92One more preflight: official DGX Spark playbooks have shipped
93broken before. Check recent issues on
94`github.com/NVIDIA/dgx-spark-playbooks` (and the other
95resources in `references/stack-matrix.md`) before trusting a
96recipe verbatim for a long run.
97 
98## The ABI Rule
99 
100The single most common failure on Spark is a CUDA 12/13 ABI
101mismatch: a wheel built against `libcudart.so.12` loaded on a
102system that only has `libcudart.so.13`. The install usually
103succeeds; the failure surfaces later as a missing-symbol error
104or a segfault that doesn't obviously point at CUDA.
105 
106Fix: pull wheels from `download.pytorch.org/whl/cu130` (theA4This skill pulls in web or user content but never says to treat that content as data. A signal, not proof.
107cu130-tagged aarch64 builds), or use one of the containers
108above, which already carry a matched build. Before chasing a
109stack trace that mentions a CUDA symbol, check which CUDA tag
110the installed wheel was built against:
111 
112```bash
113python3 -c "import torch; print(torch.version.cuda)"
114```
115 
116If that output doesn't start with `13`, the ABI mismatch is the
117first thing to fix. NGC container builds (e.g.
118`nvcr.io/nvidia/pytorch:25.09-py3`) build torch internally
119against CUDA 13 with no `+cu130` wheel tag — `pip show torch`
120won't say `cu130` there, and that absence alone is not a failure.
121 
122Typical symptoms:
123 
124- `ImportError: undefined symbol` referencing a CUDA runtime
125 function.
126- A segfault on the first `.cuda()` call, no useful traceback.
127- A wheel that installs cleanly, then fails at import time —
128 pip's resolver doesn't check CUDA ABI, only version constraints.
129- Two "identical" environments behaving differently — usually one
130 has a cu130 wheel, the other a cu121/cu124 leftover.
131 
132The fix is the same regardless of symptom: match the wheel's
133CUDA tag to the system, or use a container that already does.
134 
135## Component Quick Table
136 
137Condensed status for the components most likely to come up.
138Full table with wheel URLs, build flags, the sm_121 vs sm_121a
139distinction, and the dated known-good version matrix:
140`references/stack-matrix.md`.
141 
142| Component | Status |
143|---|---|
144| PyTorch | ✅ official cu130 aarch64 wheels |
145| bitsandbytes | ✅ works out of the box |
146| Triton | ✅ needs the `TRITON_PTXAS_PATH` parameter set |
147| flash-attn | ❌ skip pip build; NGC bundles a working one — see `spark-training-gotchas` G2 |
148| xformers | source build only (`TORCH_CUDA_ARCH_LIST=12.1`) |
149| vLLM | nightly wheels only |
150| TransformerEngine / NVFP4 train | container-only |
151 
152Everything else — Unsloth, Axolotl, TRL, PEFT — installs
153cleanly through the container-first path above. LLaMA-Factory
154and NeMo are fragile on Spark; check upstream issues first.
155 
156## Verification Commands
157 
158Confirm the environment can actually see the GPU before
159running anything expensive:
160 
161```python
162import torch
163print(torch.cuda.is_available(), torch.version.cuda)
164```
165 
166This call returns two values; the exact output format is one
167line, `<bool> <cuda-version>`:
168 
169```text
170True 13.0
171```
172 
173If it prints `False` instead, don't jump straight to a wheel
174reinstall — ABI mismatch is one cause among several:
175 
176| Hypothesis | Quick check |
177|---|---|
178| Runtime/flags | `nvidia-smi` fails in-container too |
179| Device visibility | `echo $CUDA_VISIBLE_DEVICES` |
180| Permissions | `ls -l /dev/nvidia*` |
181| CUDA init state | wedged process; retry fresh shell/container |
182| ABI mismatch (usual culprit) | `torch.version.cuda` not `13.x` |
183 
184Check `nvidia-smi` first — if it doesn't show the GPU, it's one
185of the first three, not ABI. Reinstall a wheel only once ABI is
186confirmed. Per-hypothesis detail: `references/stack-matrix.md`.
187Run right after the container starts, before installing
188project-specific packages.
189 
190One more check: if Triton kernel compilation fails once
191training starts, set
192`TRITON_PTXAS_PATH=/usr/local/cuda/bin/ptxas` and retry — see
193`references/stack-matrix.md` for the full workaround list.
194 
195## Next Steps
196 
197A verified environment is only the starting point. See also:
198`spark-training-gotchas` for failure preflights before a
199training run, and `spark-memory-thermal-ops` for unified-memory
200OOMs and thermal throttling during long ones.
201 

Reviews

Installed this one?Write the first review and take the Trailblazer badge.

Reviews only open after a real install, so this is empty — and we leave it empty rather than invent one.

Alternatives

Also in Infrastructure & ops