Home / AI & GenAI

AI & GenAITroubleshootingAdvanced

NVIDIA NIM LLM container won't start: registry login, cache permissions, no compatible profile and GPU memory checks

Fix NIM for LLMs containers that fail to pull, exit with PermissionError on the cache, find no compatible profile, refuse to start on memory checks or never report ready.

Deepak Bhardwaj8 min read

Applies toNVIDIA NIM for LLMs 1.x and 2.x containers on Docker with the NVIDIA Container Toolkit (Linux or WSL2)

Symptom

You run a NIM for LLMs container and it doesn't serve traffic. Either the image never pulls, the container exits within seconds, it loops on downloads, or it runs but /v1/health/ready never returns 200. Most failures fall into one of five groups. The logs usually say which one in the first 50 lines.

docker logs --tail 100 nim-llm 2>&1 | grep -iE "error|denied|permission|profile|memory|unauthor"

Note

NIM behaviour changed between 1.x and 2.x, especially for API keys and cache permissions. Check which version you run: look at the image tag, or the version line at the top of docker logs. Then read the matching section below.

Quick map

Log or error Cause Section
unauthorized, denied on docker pull nvcr.io/... Not logged in to nvcr.io, wrong username, or legacy key 1
401 or 403 while downloading model files NGC_API_KEY or HF_TOKEN missing in the container, or no access to the model 1
PermissionError or Permission denied under /opt/nim/.cache Host cache folder not writable by the container user 2
Model downloads again on every restart Cache volume not mounted 2
No compatible profile, or the profile you chose isn't runnable GPU type or count doesn't match a profile in the manifest 3
Startup refused on free-memory check, or CUDA out of memory GPU memory already in use, or the model plus KV cache doesn't fit 4
Container up, readiness never 200 Still downloading or building, port mismatch, or proxy blocks downloads 5

1. Registry login and model access

The registry username is the literal string $oauthtoken, in single quotes so the shell doesn't expand it. The password is your NGC key:

echo "$NGC_API_KEY" | docker login nvcr.io --username '$oauthtoken' --password-stdin
docker pull nvcr.io/nim/meta/llama-3.1-8b-instruct:latest

Checks:

  • Use a Personal API key from NGC. Recent 1.x docs say legacy keys aren't supported.
  • Logging in on the host does not pass the key into the container. Pass it with -e NGC_API_KEY if your NIM downloads weights from NGC at startup.
  • In NIM 2.x, the docs say an NGC key is only needed for Production Branch models or NIMs released before 2.0.10. Models pulled from Hugging Face need -e HF_TOKEN=... instead, and your HF account must have accepted the model's licence if it is gated.
  • Behind a corporate proxy, pass -e https_proxy=.... If the proxy inspects TLS, also mount your CA bundle and set SSL_CERT_FILE.

2. Cache permissions

NIM stores model files in /opt/nim/.cache inside the container (NIM_CACHE_PATH). Mount a host folder there. If you don't, every restart downloads the model again.

The container runs as a non-root user, so the host folder must be writable by that user. The fix depends on the version.

NIM 2.x — the container runs with group ID 0. Make the cache group-writable for GID 0 and keep :0 in -u:

export LOCAL_NIM_CACHE=/data/nim-cache
sudo mkdir -p "$LOCAL_NIM_CACHE"
sudo chgrp -R 0 "$LOCAL_NIM_CACHE"
sudo chmod -R g+rwX "$LOCAL_NIM_CACHE"

docker run -d --name nim-llm --gpus all -u $(id -u):0 \
  -v "$LOCAL_NIM_CACHE:/opt/nim/.cache" -p 8000:8000 \
  nvcr.io/nim/<org>/<model>:<tag>

If you leave out :0, the docs warn you'll get PermissionError on cache, config or log paths.

NIM 1.x — the documented pattern is a world-writable cache and running as your host UID:

mkdir -p ~/.cache/nim && chmod -R a+w ~/.cache/nim
docker run ... -u $(id -u) -v ~/.cache/nim:/opt/nim/.cache ...

Warning

Don't fix cache permission errors by running the container as root or with chmod 777 on a shared mount. On multi-tenant hosts, that lets any local user replace model weights that the server will load. Use a dedicated folder per service and group permissions.

On Kubernetes, the equivalent is securityContext.runAsGroup: 0 and fsGroup: 0 on the pod, or an init container that sets group ownership on the volume.

3. No compatible profile

A NIM image ships a manifest of profiles. Each one is a combination of backend, GPU type, precision, parallelism and optimisation target, with names such as tensorrt_llm-h100-fp8-tp1-throughput. At startup NIM picks one that matches your GPUs. If none matches, or if you forced one that doesn't, it fails.

List what this host can run by adding list-model-profiles to the end of the run command:

docker run --rm --gpus all -e NGC_API_KEY \
  nvcr.io/nim/<org>/<model>:<tag> list-model-profiles

The output lists the detected GPUs, the profiles that are compatible and runnable, and the profiles that are incompatible with the system.

Situation Fix
Your GPU model has no optimised profile Use a generic profile if the list shows one, or set NIM_MODEL_PROFILE=default (the docs describe it as the most compatible choice, which may not be the fastest)
--gpus all exposes 3 GPUs but profiles exist only for tp1, tp2, tp4 Expose a matching count, for example --gpus '"device=0,1"'
You set NIM_MODEL_PROFILE to an ID copied from another host Use an ID from this host's list-model-profiles output
Multi-GPU profile hangs at startup Add --shm-size=16GB (not needed on single GPU)

Pin the profile ID in production with -e NIM_MODEL_PROFILE=<id>. If you don't, a driver or GPU change can quietly switch you to a different profile with different throughput and memory use.

4. GPU memory checks and out of memory

By default NIM wants most of the GPU memory to be free at startup. The 1.x docs say 95% or more. It reserves a large share for the KV cache (NIM_KVCACHE_PERCENT, default 0.9 in the 1.x docs). The most common cause is another process already holding memory:

nvidia-smi --query-gpu=index,name,memory.used,memory.total --format=csv
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv

Fix, in order:

  1. Stop the other process, or give NIM a different GPU with --gpus '"device=1"'.
  2. Reduce the context length with -e NIM_MAX_MODEL_LEN=8192. In the 1.x docs this applies only to TensorRT-LLM profiles or buildable profiles. Check your version's configuration page.
  3. Lower the KV cache share, for example -e NIM_KVCACHE_PERCENT=0.8, when the GPU is shared on purpose.
  4. Use a smaller or lower-precision profile (FP8 instead of BF16), or a larger GPU. As a rough guide from the docs, BF16 weights need about 2 GB per billion parameters before the KV cache.

NIM_RELAX_MEM_CONSTRAINTS=1 skips the startup memory check and logs a warning. Use it for WSL2 or deliberate GPU sharing, not to hide a model that doesn't fit. It moves the failure from startup to the first busy hour.

5. Running but never ready

curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8000/v1/health/ready
curl -s http://localhost:8000/v1/models | jq '.data[].id'

The docs say to use the ready endpoint, not the logs, to decide whether NIM is ready.

  • Still downloading or building. Large models take a long time on the first start. Watch the cache grow with du -sh $LOCAL_NIM_CACHE. To avoid this on every new node, pre-fill the cache once with download-to-cache inside the container and copy it, or follow the air-gap deployment guide for your version.
  • Port mismatch. If you set NIM_SERVER_PORT, the container side of -p must match it.
  • Wrong model name from clients. /v1/models shows the served name. Set NIM_SERVED_MODEL_NAME if clients expect a different one. Otherwise they'll get a 404 even though the server is healthy.

Get more detail with -e NIM_LOG_LEVEL=DEBUG. Keep NIM_DISABLE_LOG_REQUESTS at its default, because turning it off writes prompts to the container logs.

Caution

NIM exposes an OpenAI-compatible API on port 8000 with no authentication by default. Never publish it on 0.0.0.0 on a host with a public IP. Bind to 127.0.0.1:8000:8000 or put it behind a gateway that checks identity.

Prevent it next time

  • Bake the working docker run (or Helm values) into source control: pinned image tag, pinned NIM_MODEL_PROFILE, cache path, -u flags and served model name.
  • Run list-model-profiles in CI against each GPU node type when you upgrade the NIM image.
  • Use a readiness probe on /v1/health/ready with a long enough startup budget for the first download, plus a persistent volume for the cache.
  • Alert when GPU memory used before startup is above a few percent. A leftover process from a previous deploy is the usual cause of the next failed start.