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:
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.
Next Steps
- Refer to the Deployment section in the Inference Guide for more detailed instructions on how to deploy the NIM.
- Refer to Optimization for settings related to optimizing performance of the NIM on your hardware and software stack.