Getting Started
Prerequisites
-
Refer to the Support Matrix to make sure that you have the supported hardware and software stack.
-
An NGC personal API key. The NIM microservice uses the API key to download models from NVIDIA NGC. Refer to Generating a Personal API Key in the NVIDIA NGC User Guide for more information.
-
To run the below examples you must have
curl,jq, and the Pythonrequestsmodule installed.When you create an NGC API personal key, select at least the option for NGC Catalog from the Services Included menu. You can specify more services to use the key for additional purposes.
Installing curl, jq, and the Python requests module
-
curlis required to send requests from the command line. On Ubuntu and other Debian-based Linux distributions,curlcan be installed with the following command, which may requiresudoaccess: -
jqis used to process and reformat responses from the NIM so they are easier to read.jqcan be installed using the following command, which may requiresudoaccess: -
The Python
requestsmodule facilitates HTTP requests made in many of the examples for this NIM. The Python requests module can be installed usingpip:
NGC Authentication
Generate an API key
To access NGC resources, you need an NGC API key. You can generate a key here: Generate Personal Key.
When creating an NGC API Personal key, ensure that “NGC Catalog” is selected from the “Services Included” dropdown. You can include more services if you reuse this key for other purposes.
Personal keys allow you to configure an expiration date, revoke, or delete the key using an action button, and rotate the key as needed. For more information about key types, refer to the NGC User Guide.
Export the API key
Pass the value of the API key to the docker run command in the next section as the NGC_API_KEY environment variable to download the appropriate models and resources when starting the NIM.
If you’re not familiar with how to create the NGC_API_KEY environment variable, the simplest way is to export it in your terminal:
Run one of the following commands to make the key available at startup:
Other, more secure options include saving the value in a file, so that you can retrieve with cat $NGC_API_KEY_FILE, or using a password manager.
Docker Login to NGC
To pull the NIM container image from NGC, first authenticate with the NVIDIA Container Registry with the following command:
Use $oauthtoken as the username and NGC_API_KEY as the password. The $oauthtoken username is a special name that indicates that you will authenticate with an API key and not a username and password.
Starting the NIM Container
-
Ensure you have logged in to Docker and set your
NGC_API_KEYenvironment variable as detailed in the preceding section. -
Create a NIM Cache. If one already exists, you may use the existing one.
-
Start the NIM container:
Note: The
--runtime=nvidiaflag is the legacy approach for GPU access and may require additional Docker daemon configuration. For Docker 19.03+, you can use the--gpusflag instead, which works without additional configuration:Use all GPUs:
Or specify a specific GPU device:
The preceding command starts the container with the default profile, using all available system GPUs. Note: This will require localizing up to 30 Gigabytes of data to disk. If you have the model cached, the version in the NIM cache specified at
LOCAL_NIM_CACHEwill be used. -
(Optional) Confirm the service is ready to respond to inference requests:
Example Output
-
Send an inference request:
Curl
Python
The description of all API parameters could be found in the Input Parameters section of the Inference Guide.
Runtime Parameters for the Container
Caching Models
The first time you start the container, the microservice downloads the model from NGC. You can avoid this download step on future runs by caching the model locally.
Stopping the Container
The following commands stop the container by stopping and removing the running docker container.
Running on Slurm With Enroot
This section describes how to run the Boltz2 NIM on a Slurm-based HPC cluster using Enroot to run the NGC container.
NGC_API_KEY: You must export your NGC API key before running the Slurm script so that Enroot can pull the image from NGC. Then run the script (for example, bash boltz2_srun.sh).
Example:
Environment
- Enroot: Version 3.4.1 or newer is supported.
1. Check Enroot is Available
On the login node, verify Enroot is installed:
If Enroot is not installed, contact your cluster administrator. Create the Enroot config directory if it does not exist:
2. Create and Add NGC Credentials
Create the credentials file so Enroot can pull images from NGC. Replace YOUR_NGC_API_KEY with your NGC API key:
3. Configure and Run the Slurm Job Script
Copy the script below to a file, such as boltz2_srun.sh. Set the variables at the top for your cluster and paths:
- ACCOUNT: Slurm account name
- PARTITION: Slurm partition (for example,
interactiveorgpu) - ROOT_DIR: Your working directory on the cluster (for example, Lustre or NFS path)
- NGC_API_KEY: Must be exported in your environment before running the script (for example,
export NGC_API_KEY=<your_key>)
Use a shared filesystem path for ROOT_DIR and CACHE_PATH so that the SQSH image and cache are visible from the node where the job runs.
Save the following as boltz2_srun.sh and run it with bash boltz2_srun.sh:
4. Call the API From Your Machine
After the container is running on a compute node:
-
Create an SSH tunnel from your machine or the login node:
-
In another terminal (with the tunnel open), send an inference request:
If the request succeeds, you will get a JSON response containing the prediction result.
Next Steps
- Refer to Inferencing with the NIM for the full API reference and usage examples.
- Refer to Optimization for settings related to optimizing performance of the NIM on your hardware and software stack.