TutorialsGB10
Run an NVIDIA NIM on a DGX Spark
One container that holds a model already tuned for the machine: sign in to NVIDIA’s registry, choose a NIM, start it, test it, and keep its model on the disk.
- Time
- 15 to 30 minutes
- For
- A developer or an IT lead with a DGX Spark
- Status
- NVIDIA’s public guide · not yet run by AI Deskside
What you will have
- An NVIDIA NIM running on the Spark: one container that holds a model, already tuned for the machine.
- An OpenAI-compatible address on port 8000.
- A model cache on the disk, so the next start does not download again.
What you need
- A DGX Spark with its drivers:
nvidia-smimust answer. - Docker with the NVIDIA Container Toolkit.
- A free NVIDIA NGC account and its API key. NIM containers are downloaded from NVIDIA’s registry with it.
- Free disk space for the model: typically 10 to 50 GB.
On this page
What a NIM is
A NIM is a container NVIDIA prepares for one model: the model server, its settings for the machine, and a start that waits until the model is ready. You choose a NIM, not a server and a model separately. Understand Tech’s office boxes serve their models this way.
Step 1
Check the machine
nvidia-smi docker --version docker run --rm --gpus all nvcr.io/nvidia/cuda:13.0.1-devel-ubuntu24.04 nvidia-smi
If Docker refuses for lack of permission:
sudo usermod -aG docker $USER newgrp docker
Step 2
Sign in to NVIDIA’s registry
export NGC_API_KEY="<YOUR_NGC_API_KEY>" echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
The user name is the literal text $oauthtoken, in single quotes. The key is the password.
Step 3
Choose the NIM and prepare its cache
The guide uses Llama 3.1 8B. NVIDIA’s catalogue lists the other NIMs built for the Spark.
export CONTAINER_NAME="nim-llm-demo" export IMG_NAME="nvcr.io/nim/meta/llama-3.1-8b-instruct-dgx-spark:latest" export LOCAL_NIM_CACHE=~/.cache/nim export LOCAL_NIM_WORKSPACE=~/.local/share/nim/workspace mkdir -p "$LOCAL_NIM_WORKSPACE" chmod -R a+w "$LOCAL_NIM_WORKSPACE" mkdir -p "$LOCAL_NIM_CACHE" chmod -R a+w "$LOCAL_NIM_CACHE"
Step 4
Start it
docker run -it --rm --name=$CONTAINER_NAME \ --gpus all \ --shm-size=16GB \ -e NGC_API_KEY=$NGC_API_KEY \ -v "$LOCAL_NIM_CACHE:/opt/nim/.cache" \ -v "$LOCAL_NIM_WORKSPACE:/opt/nim/workspace" \ -p 8000:8000 \ $IMG_NAME
The first start downloads the model and can take several minutes. The container runs in this terminal: leave it open, since you stop the NIM there, and open another one for the next step.
Step 5
Check that it answers
curl -X 'POST' \
'http://0.0.0.0:8000/v1/chat/completions' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"model": "meta/llama-3.1-8b-instruct",
"messages": [
{
"role":"system",
"content":"detailed thinking on"
},
{
"role":"user",
"content":"Can you write me a song?"
}
],
"top_p": 1,
"n": 1,
"max_tokens": 15,
"frequency_penalty": 1.0,
"stop": ["hello"]
}'The answer is a JSON object with the generated text. From another computer, replace 0.0.0.0 with the Spark’s address.
Stop and remove
Press Ctrl+C in the terminal where the NIM runs. It was started with --rm, so Docker removes the container when it stops. NVIDIA’s two commands below are for a container still running, or started without --rm: after Ctrl+C they answer that the container does not exist, which is expected. In a new terminal the values of Step 3 are not set: write nim-llm-demo in place of $CONTAINER_NAME.
docker stop $CONTAINER_NAME docker rm $CONTAINER_NAME
To free the disk as well, delete the model cache; the model will be downloaded again at the next start. In a new terminal, write ~/.cache/nim in place of "$LOCAL_NIM_CACHE":
rm -rf "$LOCAL_NIM_CACHE"
When something fails
| What you see | Cause | What to do |
|---|---|---|
Invalid credentials at sign-in | The key is wrong or has a space around it | Copy the key again from the NGC portal. |
| The download hangs or fails | Network, or not enough disk | Check the connection and the space in the cache folder. |
| Error 404 or connection refused | The container has not finished starting | Wait for the end of the start-up, and check port 8000. |
runtime not found | The NVIDIA Container Toolkit is not configured for Docker | Run sudo nvidia-ctk runtime configure --runtime=docker and restart Docker. |
| Memory errors although the model should fit | The system cache holds part of the shared memory | Free it with the command below. |
sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'
To do for a production deployment
Before you rely on it in production
Pin the NIM. The tag
latestmoves; note the version that worked. Understand Tech’s office box runs NIM 2.0.12.Run it in the background and make it start again after a reboot. The command above runs in the terminal and removes the container when it stops.
Allow for a long start. Understand Tech’s published configuration gives its NIM 45 minutes before a failed health check counts, and one of its lessons records a start of about 30 minutes.
Protect the address: the command publishes port 8000 to the network.
Keep the cache folder on a disk that is backed up or easy to refill, and plan how a new model reaches a machine that has no internet access.
Where the commands come from
Sources
Read on 30 November 2026. Commands are copied from the sources. A step a source does not show is described in words.
Reference
Fact sheet
- Where this comes from
NIM is how Understand Tech’s office boxes serve their models. NVIDIA publishes a short guide for running one on a DGX Spark; this tutorial follows it and adds what Understand Tech’s records say about start-up time and versions.
- Machine
NVIDIA DGX Spark · 128 GB unified. A reference machine helps locate guidance; it does not establish identical behaviour on another maker’s system.
- Software
NVIDIA NIM for LLMs, from NVIDIA’s NGC registry
- Model
meta/llama-3.1-8b-instruct in the guide; other NIMs built for the Spark are in NVIDIA’s catalogue
- Evidence
Commands from NVIDIA’s DGX Spark playbooks (Apache 2.0), read 30 November 2026 at a fixed commit. AI Deskside has not run them yet. The notes on start-up time come from Understand Tech’s public configuration file and from a lesson on AI Deskside.
- Still open
- Which NIMs exist for the Spark on the day you install
- Start-up time of the NIM you choose, first start and restart
- Speed and number of simultaneous users for your prompts
- How to bring a NIM and its model to a machine with no internet access
