This guide helps a reader run Chapters 1 through 5 on NVIDIA DGX Spark (GB10) with GPU acceleration.
DGX Spark GB10 requires a GPU build of PyTorch that supports compute capability sm_121.
- Use PyTorch wheels from
cu130(or newer). - Do not use
cu126on GB10 for this book flow.
Run these checks before creating the Python environment:
nvidia-smiYou should see:
- A visible NVIDIA GPU (GB10)
- A modern driver (for example, 580+)
- CUDA runtime capability compatible with CUDA 13.x
From repository root:
cd code
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pipInstall GPU PyTorch for GB10:
python -m pip install --upgrade --index-url https://download.pytorch.org/whl/cu130 torch torchvision torchaudioInstall book dependencies:
python -m pip install -e ".[dev,chapter03]"python - <<'PY'
import torch
print('torch', torch.__version__)
print('cuda', torch.cuda.is_available())
print('gpu_count', torch.cuda.device_count())
if torch.cuda.is_available():
print('gpu_name', torch.cuda.get_device_name(0))
x = torch.randn(1024, 1024, device='cuda')
y = x @ x
torch.cuda.synchronize()
print('cuda_matmul_ok', y.shape)
PYExpected:
cuda Truegpu_name NVIDIA GB10- Successful matmul output
python scripts/build_it_support_dataset.py
python scripts/reformat_it_answers.pyRun from code/ with .venv active.
Base-only sidebar run:
python -m chapter01.run_sidebar_example --base_onlyOptional base+LoRA comparison after Chapter 5 smoke adapter exists:
python -m chapter01.run_sidebar_example --lora_dir chapter05/runs/validate_lora_smokeQuickstart training:
python -m chapter02.quickstartOptional adapter preview:
python -m chapter02.run_chapter5_adapter --use-quickstartManifest runnable path:
python -m chapter03.ch03_datasetmanifestSynthetic pipeline path (requires ANTHROPIC_API_KEY):
python -m chapter03.ch03_synthetic_data_generationHF backend (GPU):
python -m chapter04.few_shot_demo --shots 8 --backend hf --output chapter04/runs/few_shot_hf_dgx.jsonValidator (mock backend):
python -m chapter04.prompt_validator --shots 8 --runs 3 --backend mockRAG eval (hash backend):
python -m chapter04.scripts.listing_4_5_rag_eval --k 3 --backend hashChapter preflight + tiny LoRA smoke training:
python chapter05/scripts/validate_chapter05.pyGeneration with smoke adapter:
python -m chapter05.generate --base Qwen/Qwen3-4B-Instruct-2507 --adapter chapter05/runs/validate_lora_smoke --prompt "My laptop won't connect to office Wi-Fi after update. What should I do?"Minimal base-vs-adapter smoke evaluation:
python -m chapter05.scripts.listing_5_3_evaluate \
--base Qwen/Qwen3-4B-Instruct-2507 \
--adapter chapter05/runs/validate_lora_smoke \
--dolly_test chapter05/data/smoke/valid.jsonl \
--toy_golden chapter05/data/golden/toy_test.jsonl \
--safety_prompts chapter05/data/golden/safety_regression_prompts.jsonl \
--out chapter05/runs/eval_report_dgx_smokepython -m pytest -q chapter04/tests chapter05/testsSymptom example:
- Warning about unsupported
sm_121/ compute capability 12.1
Fix:
- Reinstall torch from
cu130index:
python -m pip install --upgrade --index-url https://download.pytorch.org/whl/cu130 torch torchvision torchaudioFix:
- Ensure you are in
code/ - Ensure
.venvis activated - Reinstall editable package:
python -m pip install -e ".[dev,chapter03]"This is expected in a Chapter 1-5 workflow because the SFT artifact is produced in Chapter 6.
Use these scripts:
./DGX-SPARK-RECIPE.sh(chapter-oriented:setup,ch1...ch5,all)code/validation/cuda_dgx_spark/dgx_spark_recipe.sh(one-shot validation path)
Examples:
# Full setup + chapter 1-5 run path
./DGX-SPARK-RECIPE.sh all
# Run only chapter 4
./DGX-SPARK-RECIPE.sh ch4
# Fast smoke checks
./DGX-SPARK-RECIPE.sh smokeValidation logs and run report from a real DGX Spark pass are in:
code/validation/cuda_dgx_spark/
The new chapter-oriented recipe was exercised on DGX Spark in this environment:
./DGX-SPARK-RECIPE.sh smoke-> PASS./DGX-SPARK-RECIPE.sh ch4-> PASS./DGX-SPARK-RECIPE.sh ch1-> PASS./DGX-SPARK-RECIPE.sh ch2-> PASS (after recipe fix)./DGX-SPARK-RECIPE.sh ch3-> PASS./DGX-SPARK-RECIPE.sh ch5-> PASS./DGX-SPARK-RECIPE.sh all-> PASS
Recipe fix applied during validation:
- Updated data reformat step to process both train and valid splits by default:
python scripts/reformat_it_answers.py
If you are trying this on a fresh DGX Spark machine, run setup first, then
smoke, then chapter commands (ch1 ... ch5) or all.