Skip to navigation

Quickstart Guide

View as Markdown

This page assumes you have installed and set up Prerequisite Software (Docker, NGC CLI, NGC registry access).

  1. Pull the NIM container with the following command.
docker pull nvcr.io/nim/deepmind/alphafold2:2.1.0
  1. Run the NIM container with the following command.
export LOCAL_NIM_CACHE=~/.cache/nim
export NGC_API_KEY=<Your NGC API Key>
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).

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

  2. In the new terminal, wait until the health check end point returns {"status":"ready"} before proceeding. This may take a couple of minutes. You can use the following command to query the health check.

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

If you would rather check the NIM’s status with Python, you can use the requests module (after pip install requests):

import requests
url = "http://localhost:8000/v1/health/ready" # Replace with the actual URL
headers = {
"content-type": "application/json"
}
try:
response = requests.get(url, headers=headers)
# Check if the request was successful
if response.ok:
print("Request succeeded:", response.json())
else:
print("Request failed:", response.status_code, response.text)
except Exception as E:
print("Request failed:", E)
  1. Run inference to get a predicted protein structure for an amino acid sequence using the following command.
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

In python:

import requests
import json
url = "http://localhost:8000/protein-structure/alphafold2/predict-structure-from-sequence" # Replace with the actual URL
sequence = "MNVIDIAIAMAI" # Replace with the actual sequence value
headers = {
"content-type": "application/json"
}
data = {
"sequence": sequence,
"databases": ["uniref90", "small_bfd"]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
# Check if the request was successful
if response.ok:
print("Request succeeded:", response.json())
else:
print("Request failed:", response.status_code, response.text)

To use the MMSeqs2 GPU-accelerated MSA tool, send 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
  1. View the outputs. You can use cat to print the outputs to the command line with the following command.
cat output.json

Install jq to format the JSON. You can use jq to visualize the output from the file (you must install jq and on Linux this can be done using apt-get install jq):

jq . output.json

or you can pipe the output directly to jq as in the following command:

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