Skip to navigation

Quickstart for AlphaFold2

View as MarkdownOpen in Claude

This Quickstart Guide walks you through pulling the AlphaFold2 NIM container, starting the service, and running your first structure-prediction request. For comprehensive system requirements and verified configurations, refer to Prerequisites.

Prerequisites

Before you start, complete the following prerequisites:

  1. Install Docker, the NVIDIA Container Toolkit, and the NVIDIA drivers.
  2. Set up the NGC CLI and NGC registry access.
  3. Confirm that your system meets the minimum hardware requirements.

For comprehensive system prerequisites and verified configurations, refer to Prerequisites.

Quickstart Steps

To get started with the AlphaFold2 NIM quickly, complete the following steps:

  1. Pull the NIM container.

    docker pull nvcr.io/nim/deepmind/alphafold2:2.1.0
  2. Set the required environment variables.

    export LOCAL_NIM_CACHE=~/.cache/nim
    export NGC_API_KEY=<Your NGC API Key>
  3. Run the NIM container.

    docker run --rm --name alphafold2 --runtime=nvidia \
    -e NGC_API_KEY \
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    nvcr.io/nim/deepmind/alphafold2:2.1.0

    This command starts the NIM container and exposes port 8000 so you can interact with the NIM. It pulls the model to the cache at $LOCAL_NIM_CACHE on the local filesystem.

    This download can take a very long time (4 to 10 hours on a connection of 100 Mbps or faster).

  4. Open a new terminal, leaving the current terminal open with the launched service.

  5. Wait until the health check endpoint returns {"status":"ready"} before proceeding.

    This can take a couple of minutes. In the new terminal, use the following command to query the health check.

    curl -X 'GET' \
    'http://localhost:8000/v1/health/ready' \
    -H 'accept: application/json'

    Success Check: When the service is ready, the health check returns {"status":"ready"}.

  6. Run inference to get a predicted protein structure for an amino acid sequence.

    curl -X 'POST' \
    'http://localhost:8000/protein-structure/alphafold2/predict-structure-from-sequence' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"sequence": "MNVIDIAIAMAI"}' > output.json

    To use the MMSeqs2 GPU-accelerated MSA tool, send the algorithm=mmseqs2 parameter to the API endpoint:

    curl -X 'POST' \
    'http://localhost:8000/protein-structure/alphafold2/predict-structure-from-sequence' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"sequence": "MNVIDIAIAMAI", "algorithm": "mmseqs2"}' > output.json
  7. View the outputs.

    Use cat to print the outputs to the command line.

    cat output.json
  8. Format the outputs.

    Install jq to format the JSON (on Linux, apt-get install jq), then visualize the output from the file:

    jq . output.json

    Alternatively, pipe the output directly to jq:

    curl -X 'POST' \
    'http://localhost:8000/protein-structure/alphafold2/predict-structure-from-sequence' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"sequence": "MNVIDIAIAMAI"}' | jq

Minimal Code Example

If you prefer to drive the NIM from Python, use this self-contained example to check service health and run an inference request. Install the requests module first with pip install requests.

import requests
import json
base_url = "http://localhost:8000"
headers = {"content-type": "application/json"}
# 1. Wait until the NIM reports ready.
health = requests.get(f"{base_url}/v1/health/ready", headers=headers)
if health.ok:
print("Service ready:", health.json())
else:
print("Service not ready:", health.status_code, health.text)
# 2. Run inference to predict a structure from a sequence.
url = f"{base_url}/protein-structure/alphafold2/predict-structure-from-sequence"
sequence = "MNVIDIAIAMAI" # Replace with the actual sequence value
data = {
"sequence": sequence,
"databases": ["uniref90", "small_bfd"]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.ok:
print("Request succeeded:", response.json())
else:
print("Request failed:", response.status_code, response.text)

Next Steps

Now that you have a working setup, explore the following resources in greater detail: