> This page is for MolMIM, version 1.0.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 1.0.0 (Latest) (default): https://docs.nvidia.com/nim/bionemo/molmim/1.0.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/bionemo/llms.txt.

# Deploy the MolMIM NIM

> Pull, run, and cache the MolMIM NIM container, with a detailed walkthrough of the run command and its options.

This guide provides a detailed walkthrough for deploying the MolMIM NIM container, including viewing the available container image tags, pulling the image, running it with the recommended options, and caching the model. For a fast first run, refer to the [Quickstart Guide](/nim/bionemo/molmim/get-started/quickstart-guide).

## Prerequisites

Before you start, complete the following prerequisites:

1. Install Docker, the NVIDIA Container Toolkit, and the NVIDIA drivers, and set up NGC registry access.

   Refer to [Prerequisites](/nim/bionemo/molmim/get-started/prerequisites).

2. Generate an NGC API key and log in to `nvcr.io`.

## Deploy the NIM

To deploy the MolMIM NIM, complete the following steps:

1. View the available container image tags.

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

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

2. Pull the container image using one of the following commands.

   Using Docker:

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

   Using NGC:

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

3. Run the container.

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

   ```bash
   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.

4. (Optional) Cache the model checkpoint.

   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.

   ```bash
   # 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.
   </Note>

## Next Steps

Now that the MolMIM NIM is deployed, explore the following resources:

<CardGroup cols={2}>
  <Card title="Endpoints" href="/molmim/endpoints">
    Explore the MolMIM NIM API endpoints and worked examples.
  </Card>
  <Card title="Advanced Usage" href="/molmim/advanced-usage">
    Benchmark the NIM locally and control its logging levels.
  </Card>
  <Card title="Quickstart Guide" href="/molmim/get-started/quickstart-guide">
    Pull the NIM, launch the service, and run your first inference request.
  </Card>
  <Card title="Support Matrix" href="/molmim/get-started/support-matrix">
    Hardware, software, and verified GPU configurations for the NIM.
  </Card>
</CardGroup>