Configuration
NIM LLM and VLM offers several configuration options using environment variables to control caching, logging, and model profiles. Use this page to export credentials, map a persistent host cache, and optionally set a model-free source.
Export the API Key
Export NGC API Key
Export your NGC Personal API key before pulling either type of PB7 container or starting a NIM that needs to download model files. When you start the container, pass the exported key with -e NGC_API_KEY.
A serving container can start offline without an NGC key when its cache or local model store already contains every required file. For the download helper workflows, see Model Downloads.
Export Hugging Face Access Token
For gated or private Hugging Face models, also export a Hugging Face access token and pass it with -e HF_TOKEN.
Model Cache and Source
NIM downloads model weights and other assets to a cache directory inside the container. Map a persistent directory on your host machine to that path so files survive restarts and later deployments can reuse them.
Local Cache
An essential host variable is LOCAL_NIM_CACHE, which maps the host cache directory to the container cache path. Assets (for example, model weights) download to this host directory and persist across container restarts. This guide uses LOCAL_NIM_CACHE=~/.cache/nim in all examples to keep commands consistent and copy-paste safe.
To create and map the local cache, complete the following steps:
-
Create the cache directory and export
LOCAL_NIM_CACHE: -
Make the cache writable by GID 0, the container’s group, using the commands under Cache Directory Permissions below.
When you start the NIM container, you must map your host machine’s local cache directory ($LOCAL_NIM_CACHE) to the container’s internal cache path (/opt/nim/.cache) using a Docker volume mount, such as -v "$LOCAL_NIM_CACHE:/opt/nim/.cache". This mapping ensures that the large model weights downloaded by the container are saved to your host machine. Because containers are ephemeral, any data stored only inside the container is lost when it stops. By using a volume mount, subsequent container runs detect the existing model files in your local cache and skip the lengthy download process, allowing the NIM to start up faster.
Cache Directory Permissions
The NIM container runs as a non-root user with GID 0 (root group). The cache directory on your host must be writable by GID 0. To set permissions and mount the cache, complete the following steps:
-
Set group ownership so GID 0 can write to the cache:
-
Run the container with the cache mounted:
To run as a custom user (for example, your host user), pass -u <uid>:0:
When using -u <uid>, you must include :0 to set GID 0 (for example, -u $(id -u):0). The container’s writable directories are group-owned by GID 0. Without it, the container fails with PermissionError when writing to cache, config, or log paths.
NIM creates its scratch directory, $LOCAL_NIM_CACHE/tmp, writable by GID 0 and sticky, like /tmp, so UIDs in GID 0 can share it. Earlier releases could create that directory without group write. To reuse such a cache under a different UID, first run sudo chmod g+rwx,+t "$LOCAL_NIM_CACHE/tmp" on the host. Or start this release one time as the user that owns that directory: the image’s default user, unless your first run passed -u.
To make this setting permanent across terminal sessions, you can add export LOCAL_NIM_CACHE=~/.cache/nim to your ~/.bashrc or ~/.zshrc profile.
Custom Model Source (Model-Free NIM Only)
You can configure model-free NIM to download a model from Hugging Face or other supported sources. To do this, specify the directory where the model files should be stored and set the appropriate environment variable.
To set a Hugging Face model source, complete the following steps:
-
Specify a Hugging Face model directly using the
hf://prefix: -
Map
$LOCAL_NIM_CACHEto/opt/nim/.cachewhen you run the container.
NIM automatically downloads the model from Hugging Face and caches it in your configured LOCAL_NIM_CACHE. When running the container, map your host machine’s local cache directory to a path inside the container using the -v flag. This ensures that the downloaded model weights persist on your host machine across ephemeral container restarts.
For example, using -v "$LOCAL_NIM_CACHE:/opt/nim/.cache" tells Docker: “Take the folder at $LOCAL_NIM_CACHE on my host machine, and make it available inside the container at the path /opt/nim/.cache.”
If you plan to use a model source other than Hugging Face, such as a pre-downloaded local model or private cloud storage, the URI and path are different. Refer to Model Download for instructions.
Advanced Configurations
For production deployments or specific organizational requirements, you can configure additional environment variables. NIM LLM and VLM supports advanced settings such as:
- TLS/SSL Configuration (
NIM_SSL_MODE,NIM_SSL_KEY_PATH,NIM_SSL_CERTS_PATH,NIM_SSL_CA_CERTS_PATH): Control whether SSL/TLS is enabled for API connections, and specify the locations of SSL private keys, certificates, and CA certificates. - Unified Structured Logging and Verbosity (
NIM_JSONL_LOGGING,NIM_LOG_LEVEL): Enable structured JSONL log output and set the logging verbosity level for debugging or monitoring. - Manual Model Profile Overrides (
NIM_MODEL_PROFILE): Manually select or override the model execution profile, allowing control over parameters like precision or hardware acceleration.
For more details on these advanced settings, refer to Advanced Configurations.