# How to deploy NVIDIA DGX Spark in a company: setup, local models and cost

> AI Release · @ai_releaseorg · https://ai-release.org/guides/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal_en.html

## AI summary

Time to complete: ~120 minutes from first boot to a model answering requests, plus 1–2 days to collect the numbers your finance team will ask for. Difficulty level: Intermediate

### Key facts

1. Time to complete: ~120 minutes from first boot to a model answering requests, plus 1–2 days to collect the numbers your finance team will ask for. (source: #tldr; status: заявление источника)
2. Difficulty level: Intermediate (source: #tldr; status: заявление источника)
3. You will need: one DGX Spark unit with its factory DGX OS image, an admin account with sudo, an NVIDIA NGC account and API key, Docker with the NVIDIA Container Toolkit, curl and jq, a Python 3 virtualenv for the benchmark script, and a spreadsheet. (source: #tldr; status: заявление источника)
4. DGX Spark unit, power supply and network cable; record the serial number — you will need it for support cases. (source: #requirements; status: заявление источника)
5. The DGX OS image the unit shipped with. Do not re-image before capturing the baseline in Step 1. (source: #requirements; status: заявление источника)
6. sudo rights on the device. (source: #requirements; status: заявление источника)

### Direct answers

**What is required?** — DGX Spark unit, power supply and network cable; record the serial number — you will need it for support cases.; The DGX OS image the unit shipped with. Do not re-image before capturing the baseline in Step 1.; sudo rights on the device.; NVIDIA NGC account: the container registry nvcr.io requires an API key, and the… (#requirements)
**How to do it?** — Step 1. Capture a verified baseline of the device → Step 2. Serve a local model behind an OpenAI-compatible API → Step 3. Measure throughput and build the cost model (#step-1)
**Which topics does it cover?** — nvidia dgx spark настройка, dgx spark внедрение, локальные ии для бизнеса, dgx spark стоимость, запуск llm на dgx spark (#entities)
**What are the key points?** — Time to complete: ~120 minutes from first boot to a model answering requests, plus 1–2 days to collect the numbers your finance team will ask for. Difficulty level: Intermediate (#tldr)

- Canonical: https://ai-release.org/guides/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal_en.html
- Markdown: https://ai-release.org/guides/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal_en.md
- JSON: https://ai-release.org/guides/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal_en.json

## TL;DR

- Time to complete: ~120 minutes from first boot to a model answering requests, plus 1–2 days to collect the numbers your finance team will ask for.
- Difficulty level: Intermediate
- You will need: one DGX Spark unit with its factory DGX OS image, an admin account with `sudo`, an NVIDIA NGC account and API key, Docker with the NVIDIA Container Toolkit, `curl` and `jq`, a Python 3 virtualenv for the benchmark script, and a spreadsheet.

## What you will get

- A written baseline log (`~/dgx-baseline/baseline-<date>.log`) proving the GPU, driver, container runtime and free unified memory, captured before anything is changed.
- A local, OpenAI-compatible inference endpoint on `http://<dgx-ip>:8000/v1` that your existing tools can call by swapping `base_url` only.
- A filled cost worksheet that turns your own measured tokens/second into a `$ per 1M tokens` figure and a break-even point against any API price.

Most write-ups stop at "it runs". The deliverable that decides whether the unit stays in the office is the third bullet: a measured cost-per-token number from your own hardware, not a vendor slide.

## Quick start

```bash
nvidia-smi
docker run --rm --gpus all nvcr.io/nvidia/cuda:<cuda-tag> nvidia-smi
export NGC_API_KEY=<your-ngc-key>
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
docker run --rm --gpus all -p 8000:8000 -v ~/.cache/nim:/opt/nim/.cache -e NGC_API_KEY <inference-image>:<tag>
curl -s http://localhost:8000/v1/models | jq
```

Details and verification are in the steps below.

## Requirements and setup
![Illustration: Requirements and setup](https://ai-release.org/guides/img/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal-en-1.jpg?v=1796374104)


- DGX Spark unit, power supply and network cable; record the serial number — you will need it for support cases.
- The DGX OS image the unit shipped with. Do not re-image before capturing the baseline in Step 1.
- `sudo` rights on the device.
- NVIDIA NGC account: the container registry `nvcr.io` requires an API key, and the username for key auth is the literal string `$oauthtoken`.
- Docker Engine plus the NVIDIA Container Toolkit, so containers can see the GPU.
- Client workstation with `curl`, `jq`, and Python 3 (for the benchmark script in Step 3).
- Free disk for model weights — check the model card for the exact size before pulling; weights can be tens of GB.
- Placeholders used below: `<cuda-tag>` — the CUDA tag listed in the NGC catalog for your DGX OS release; `<inference-image>:<tag>` — the serving container you pick from NGC; `<model-id>` — the model identifier the container reports; `<dgx-ip>` — the unit's LAN address.

Checklist before you start:

- [ ] Unit is on a UPS-backed outlet
- [ ] `nvidia-smi` runs without `sudo`
- [ ] `docker info` lists an `nvidia` runtime
- [ ] NGC API key exported in the shell, not pasted into a file in git
- [ ] At least one internal application identified as the first consumer

## Step 1. Capture a verified baseline of the device

**What to do:** create a dated inventory of OS, kernel, driver, GPU, memory and disk before you install or pull anything.

```bash
mkdir -p ~/dgx-baseline && cd ~/dgx-baseline
{ uname -a; cat /etc/os-release; nvidia-smi; df -h; free -h; } | tee baseline-$(date +%F).log
nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv | tee gpu.csv
```

**Why:** DGX Spark uses a unified memory pool shared between CPU and GPU, so "how much VRAM do I have" is not a fixed number — the OS and your containers draw from the same pool. You need the free figure at idle as your budget for model weights plus KV cache, and you need the driver and CUDA versions to pick a matching container tag.

**How to check:** `nvidia-smi` prints a table with a GPU name row and a `CUDA Version` in the header; `gpu.csv` shows the same values as CSV. Confirm `free -h` and `nvidia-smi` report a comparable total. If the numbers disagree wildly, stop and check the documentation for how unified memory is reported on your image.

**Example:** the log line `baseline-2025-06-14.log` opens with the kernel string, then the `nvidia-smi` table, then a `Mem:` row from `free -h`. Keep this file; every later measurement is compared against it.

Also record the container runtime state:

```bash
docker info --format '{{json .Runtimes}}' | jq
```

Expected: a JSON object containing `"nvidia"`. If it is absent, install the NVIDIA Container Toolkit before continuing.

## Step 2. Serve a local model behind an OpenAI-compatible API
![Illustration: Step 2. Serve a local model behind an OpenAI-compatible API](https://ai-release.org/guides/img/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal-en-2.jpg?v=1796374111)


**What to do:** authenticate to NGC, start a serving container on port `8000`, and expose it on the LAN behind a reverse proxy with an API key.

```bash
export NGC_API_KEY=<your-ngc-key>
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin

docker run -d --name local-llm --restart unless-stopped --gpus all \
  -p 8000:8000 \
  -v ~/.cache/model-cache:/opt/nim/.cache \
  -e NGC_API_KEY \
  <inference-image>:<tag>

docker logs -f local-llm
```

**Why:** an OpenAI-compatible `/v1/chat/completions` surface means every downstream tool changes one setting instead of its code. That is exactly how you wire automation platforms to a local model — see [how to connect n8n to a local LLM](https://ai-release.org/guides/kak-podklyuchit-n8n-k-lokalnoy-yazykovoy-modeli-poshago.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide) for the client side of that swap. The same applies to CLI coding agents reconfigured to point at a different base URL.

**How to check:**

```bash
curl -s http://localhost:8000/v1/models | jq -r '.data[].id'

curl -s http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"<model-id>","messages":[{"role":"user","content":"Reply with the single word: ready"}],"max_tokens":16}' \
  | jq -r '.choices[0].message.content'
```

Expected: the model id from the first command, and `ready` from the second. A JSON body with `"object": "list"` and an empty `data` array means the container is up but no model is loaded — read `docker logs local-llm`.

Memory budgeting matters here: a model whose weights nearly fill the pool will serve short prompts and then fail on long contexts because the KV cache cannot grow. Watch `nvidia-smi` during the first long request:

```bash
watch -n 1 'nvidia-smi --query-gpu=memory.used,memory.total --format=csv'
```

If the used figure climbs to the total, drop to a smaller quantization or reduce the served context length. Consult the model card and the container documentation for the exact flags.

## Step 3. Measure throughput and build the cost model
![Illustration: Step 3. Measure throughput and build the cost model](https://ai-release.org/guides/img/kak-vnedrit-nvidia-dgx-spark-v-kompanii-nastroyka-lokal-en-3.jpg?v=1796374115)


**What to do:** run a fixed workload three times, record tokens/second, then feed the numbers into the worksheet.

```python
import json, time, urllib.request

URL = "http://localhost:8000/v1/chat/completions"
payload = {"model": "<model-id>",
           "messages": [{"role": "user", "content": "Explain TCP retransmission in 200 words."}],
           "max_tokens": 256}

for i in range(3):
    t0 = time.time()
    req = urllib.request.Request(URL, data=json.dumps(payload).encode(),
                                 headers={"Content-Type": "application/json"})
    body = json.load(urllib.request.urlopen(req))
    elapsed = time.time() - t0
    out = body["usage"]["completion_tokens"]
    print(f"run {i+1}: {out} tokens in {elapsed:.2f}s -> {out/elapsed:.1f} tok/s")
```

**Why:** the `usage.completion_tokens` field is the only trustworthy token count — character counts overflow context windows and distort every downstream number. Three runs expose a cold-start outlier.

**How to check:** the three lines should be within roughly 10% of each other; if run 1 is far slower, it was the model load and you should rerun.

| Cost line | Formula | Your inputs |
|---|---|---|
| Device capex | price on your quote, incl. tax and shipping | `<capex>` |
| Amortized per month | capex ÷ useful life in months | `<capex>` ÷ `<months>` |
| Power per month | watts ÷ 1000 × hours × $/kWh | `<watts>` × 730 × `<tariff>` |
| Tokens per month | tok/s × 2,592,000 × utilization | `<tok/s>` × 2,592,000 × `<0–1>` |
| Cost per 1M tokens | monthly cost ÷ (tokens ÷ 1,000,000) | computed |
| Break-even vs API | monthly cost ÷ API price per token | computed |

**Example (assumed inputs, replace with your own):** 800 tok/s aggregate at 25% utilization gives 800 × 2,592,000 × 0.25 = 518.4M tokens/month. With $150 amortization + $35 power + $50 operations = $235/month, the cost is 235 ÷ 518.4 = **$0.45 per 1M tokens**. If your API quote is $2.00 per 1M output tokens, local break-even is 235 ÷ 0.000002 ≈ 117.5M tokens/month.

Where this does not work: workloads that are bursty and low-volume. At 5% utilization the same device produces ~130M tokens/month and the per-token cost roughly quadruples — for that profile a hosted API is usually cheaper. If you need a hybrid, the [OpenAI models via Google Cloud setup](https://ai-release.org/guides/kak-podklyuchit-modeli-openai-cherez-google-cloud-posha.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide) is a practical way to keep a cloud path for overflow while the Spark handles steady-state traffic.

## Troubleshooting

**Problem. The GPU is invisible to containers**

- Error: `docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]`
- Cause: the NVIDIA Container Toolkit is missing or Docker was configured before the toolkit was installed.
- Solution: register the runtime and restart Docker, then retest:
```bash
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
docker run --rm --gpus all nvcr.io/nvidia/cuda:<cuda-tag> nvidia-smi
```

**Problem. Image pull from NGC is rejected**

- Error: `unauthorized: authentication required`
- Cause: `docker login` was done with your email instead of the literal username `$oauthtoken`, or the API key was regenerated in the NGC portal.
- Solution:
```bash
echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
docker pull <inference-image>:<tag>
```

**Problem. The model dies on long prompts**

- Error: `CUDA out of memory. Tried to allocate <N> MiB` in `docker logs local-llm`
- Cause: unified memory is shared with the OS; weights plus the growing KV cache exceed the free pool once context length increases.
- Solution: reduce served context length or use a smaller quantization, then reload and watch memory:
```bash
docker restart local-llm
watch -n 1 'nvidia-smi --query-gpu=memory.used,memory.total --format=csv'
```

## Summary and next steps

You now have a baselined DGX Spark, a local OpenAI-compatible endpoint on port 8000, and a cost-per-token figure derived from your own measurements. Next, point one internal tool at the endpoint, re-run the Step 3 benchmark after any driver or container update, and keep the baseline log for comparison.

## FAQ

**Does DGX Spark replace a data-center GPU server?**
It is a compact office unit, not a rack server. Use it for team-scale inference, prototyping and private data that must not leave the building; keep data-center hardware for multi-tenant, high-concurrency serving. Confirm the supported concurrency for your model against the documentation.

**Can I serve several models at once on one unit?**
Yes in principle, but every loaded model reserves its weights in the same unified memory pool. Measure free memory at idle in Step 1, subtract the OS overhead, and divide what remains across models. Most teams start with one model and add a second only after the Step 3 numbers are stable.

**How do I let the whole team use the endpoint safely?**
Keep the container on `localhost`, put a reverse proxy in front of it with TLS and a per-user API key, and expose only the proxy port. Never publish port 8000 directly to the office network — the container has no authentication by default.

**What if our usage is too bursty for local serving?**
Run the Step 3 worksheet at your realistic utilization figure. Below roughly 10% utilization the amortized hardware cost dominates; in that case keep the Spark for sensitive or latency-critical requests and route the rest to a hosted API.
