Skip to navigation

Getting Started

View as Markdown

This section describes how to launch GenMol NIM v2.0.0 and submit your first request.

Prerequisites

Review the Prerequisites and Support Matrix before launching the container.

Launch GenMol NIM

  1. Authenticate with the NGC container registry.
docker login nvcr.io --username '$oauthtoken' --password $NGC_API_KEY
  1. Pull the NIM container.
export LOCAL_NIM_CACHE=~/.cache/nim/genmol
mkdir -p "$LOCAL_NIM_CACHE"
  1. Run the container with a persistent cache mount.

Set NGC_API_KEY in your shell before launching the container. For more information, refer to the NGC personal API key guide.

export LOCAL_NIM_CACHE=~/.cache/nim/genmol
mkdir -p "$LOCAL_NIM_CACHE"
chmod 777 "$LOCAL_NIM_CACHE"
docker run --rm -it --name genmol-nim \
--runtime=nvidia --gpus=all \
-e NVIDIA_VISIBLE_DEVICES=0 \
--shm-size=2G \
--ulimit memlock=-1 \
--ulimit stack=67108864 \
-e NGC_API_KEY=$NGC_API_KEY \
-e NIM_HTTP_API_PORT=8000 \
-v "$LOCAL_NIM_CACHE:/opt/nim/.cache" \
-p 8000:8000 \
nvcr.io/nim/nvidia/genmol:2.0.0
  1. Open a new terminal and wait for the service to become ready.
curl localhost:8000/v1/health/ready

Example output:

true

Run Inference in Linux Shell

curl --silent --request POST \
--url 'http://127.0.0.1:8000/generate' \
--header 'Content-Type: application/json' \
--output output.json \
--data '{
"smiles": "CCS2(=O)(=O).C134CN2C1.C3C#N.[*{15-15}]",
"num_molecules": 10,
"temperature": 1.0,
"noise": 1.0,
"scoring": "QED"
}'

Example response:

{
"status": "success",
"molecules": [
{
"smiles": "CCS(=O)(=O)N1CC(CC#N)(c2ccc(Cl)c(F)c2)C1",
"score": 0.856
}
]
}

Run Inference With Python

import json
import requests
session = requests.Session()
response = session.post(
"http://127.0.0.1:8000/generate",
headers={"Accept": "application/json"},
json={
"smiles": "CCS2(=O)(=O).C134CN2C1.C3C#N.[*{15-15}]",
"num_molecules": 5,
"temperature": 1.0,
"noise": 1.0,
"scoring": "QED",
},
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2))

Input and Output Format

The input is a SAFE text sequence with masked fragments as a template for molecular generation. SAFE extends SMILES with explicit fragment and attachment-point structure. The masked fragment placeholder uses the form [*{min_len-max_len}], where min_len and max_len specify the number of tokens to generate for that region.

If an empty template is provided, the model performs de novo generation. If a partial SAFE or SMILES template is provided, the model performs conditioned generation such as motif extension, scaffold decoration, or linker design.

Stop the Container

When you are done, stop the container:

docker stop genmol-nim