Deployment Guide#

This section provides additional details for the deployment of the MolMIM NIM container.

View NIM Container Information#

Container image tags can be seen with the command below, similar to other container images on NGC.

ngc registry image info nvcr.io/nim/nvidia/molmim:1.0.0

Pull the Container Image#

Pull the container image using one of the following commands:

Docker#

docker pull nvcr.io/nim/nvidia/molmim:1.0.0

NGC#

ngc registry image pull nvcr.io/nim/nvidia/molmim:1.0.0

Run the Container#

As in the Quickstart Guide, you can run the following command to start the MolMIM NIM.

docker run --rm -it --name molmim --runtime=nvidia \
    -e CUDA_VISIBLE_DEVICES=0 \
    -e NGC_CLI_API_KEY \
    -p 8000:8000 \
    nvcr.io/nim/nvidia/molmim:1.0.0

We can break down the command into the following components. Some can be modified in a production setting to better suit the user’s desired application.

  • docker run: This is the command to run a new container from a Docker image.

  • --rm: This flag tells Docker to remove the container automatically when it exits. This property is useful for one-off runs or testing, as it prevents the container from being left behind.

  • -it: These flags combine to create an interactive terminal session within the container. -i keeps the standard input open, and -t allocates a pseudo-TTY.

  • --name molmim: This flag gives the container the name ‘molmim’.

  • --runtime=nvidia: This flag specifies the runtime to use for the container. In this case, it is set to ‘nvidia’, which is used for GPU acceleration.

  • -e CUDA_VISIBLE_DEVICES=0: This flag sets an environment variable CUDA_VISIBLE_DEVICES to the value ‘0’. This variable controls which GPU devices are visible to the container. In this case, it is set to 0, which means the container will only use the first GPU (if available).

  • -e NGC_CLI_API_KEY: This flag sets an environment variable NGC_CLI_API_KEY used for authentication with NVIDIA’s NGC (NVIDIA GPU Cloud) service.

  • -p 8000:8000: This flag maps port 8000 on the host machine to port 8000 in the container. This allows you to access the container’s services from the host machine.

  • nvcr.io/nim/nvidia/molmim:1.0.0: This is the Docker image name and tag. The image is hosted on NVIDIA’s container registry (nvcr.io) and is named molmim_nim. The tag 1.0.0 specifies a specific version of the image.

Model Checkpoint Caching#

On initial startup, the container will download the MolMIM checkpoint from NGC. You can skip this download step on future runs by caching the model weights locally using a cache directory as in the example below.

# Create the cache directory on the host machine
export LOCAL_NIM_CACHE=~/.cache/nim
mkdir -p "$LOCAL_NIM_CACHE"

# Run the container with the cache directory mounted in the appropriate location
docker run --rm -it --name molmim --runtime=nvidia \
    -e CUDA_VISIBLE_DEVICES=0 \
    -e NGC_CLI_API_KEY \
    -v "$LOCAL_NIM_CACHE:/home/nvs/.cache/nim" \
    -p 8000:8000 \
    nvcr.io/nim/nvidia/molmim:1.0.0

Note

Caching the model checkpoint can save a considerable amount of time on subsequent container runs.