Skip to navigation

OpenFold2 Prerequisites

View as MarkdownOpen in Claude

To get started with the OpenFold2 NIM, you must complete the necessary prerequisites.

Hardware

Refer to the Support Matrix for the supported NVIDIA GPUs and system hardware requirements.

Software

Install the following software dependencies:

docker run --rm --gpus all ubuntu nvidia-smi

Example output:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 590.44.01 Driver Version: 590.44.01 CUDA Version: 13.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | N/A |
| 41% 30C P8 1W / 260W | 2244MiB / 11264MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
  • The CUDA Version reported by nvidia-smi is the CUDA version bundled with the installed driver, not the one used by the container. The OpenFold2 container ships with a CUDA 13.2 runtime and can run on systems that meet the documented minimum driver requirement for OpenFold2, through CUDA minor version compatibility.
  • For more information on enumerating multi-GPU systems, refer to the NVIDIA Container Toolkit’s GPU Enumeration Docs.

NIM Cache

The NIM cache stores previously downloaded models so you do not need to download them again on later runs. The container runs as UID 1000 (user nvs). That user owns /opt/nim and /output, and model initialization creates /opt/nim/workspace under /opt/nim. The cache directory must be owned by UID 1000 and writable by that owner only.

Create the directory, restrict it to the owner, and assign it to the container user:

mkdir -p ~/.cache/nim
chmod 700 ~/.cache/nim
sudo chown 1000:1000 ~/.cache/nim

chown needs sudo when your host account is not UID 1000. Start the container as this default user. It can then write the bind-mounted cache and create /opt/nim/workspace. On a shared system, chmod 750 with a controlled group is an alternative to 700; the owner must still be UID 1000.

Running as another UID requires a cache that UID owns, plus a writable mount for every other path that UID must write. /opt/nim and /output stay owned by UID 1000, so a different non-root UID cannot create /opt/nim/workspace and initialization fails with PermissionError.

If the cache was already created for the default container user, assign it to this account before starting. chmod does not change an existing owner.

mkdir -p ~/.cache/nim ~/nim-workspace ~/nim-output
sudo chown "$(id -u):$(id -g)" ~/.cache/nim ~/nim-workspace ~/nim-output
chmod 700 ~/.cache/nim ~/nim-workspace ~/nim-output
docker run --rm --name openfold2 \
--runtime=nvidia \
--gpus 'device=0' \
--user "$(id -u):$(id -g)" \
-e HOME=/tmp \
-p 8000:8000 \
-v ~/.cache/nim:/opt/nim/.cache \
-v ~/nim-workspace:/opt/nim/workspace \
-v ~/nim-output:/output \
nvcr.io/nim/openfold/openfold2:latest

~/nim-workspace is mounted at /opt/nim/workspace, which nimlib creates during initialization. ~/nim-output is mounted at /output (NIM_OUTPUT_PATH), where the server writes result JSON. HOME=/tmp gives the custom user a writable home directory inside the container.

Running on Slurm With Enroot

This section describes how to run the OpenFold2 NIM on a Slurm-based HPC cluster using Enroot to run the NGC container. Enroot version 3.4.1 or newer is supported.

To run the OpenFold2 NIM on Slurm, complete the following steps:

  1. Check that Enroot is available.

    On the login node, verify Enroot is installed:

    enroot version
    which enroot

    If Enroot is not installed, contact your cluster administrator. Typical path: /usr/bin/enroot. Create the Enroot config directory if it does not exist:

    mkdir -p ~/.config/enroot
  2. Configure and run the Slurm job script.

    Copy the following script to a file, such as openfold2_srun.sh. Set the variables at the top for your cluster and paths:

    • ACCOUNT: Slurm account name
    • PARTITION: Slurm partition (for example, interactive or gpu)
    • ROOT_DIR: Your working directory on the cluster (for example, Lustre or NFS path)
    • NGC_IMAGE: NGC image with tag; use # between registry and image path for Enroot (refer to the following example)

    Use a shared filesystem path for ROOT_DIR and CACHE_PATH so that the SQSH image and cache are visible from the node where the job runs. Use a node-local or large-quota path for TMP_PATH if /tmp has strict quotas (for example, Lustre scratch).

    Save the following as openfold2_srun.sh and run it with bash openfold2_srun.sh:

    #!/bin/bash
    # --- Slurm job configuration (customize for your cluster) ---
    ACCOUNT="your_slurm_account"
    PARTITION="interactive"
    GPUS_PER_NODE=1
    MEMORY="32G"
    TIME="04:00:00"
    # --- Paths (customize for your cluster) ---
    # Root directory on shared storage (for example, Lustre/NFS)
    ROOT_DIR="/path/to/your/workspace"
    # NIM cache on shared storage
    CACHE_PATH="${ROOT_DIR}/.nim_cache"
    WORKING_CACHE_DIR="/opt/nim/.cache"
    # Project/data mount inside container
    WORKING_PATH="${ROOT_DIR}"
    MOUNT_PATH="/workspace/data"
    # Temp directory (use shared storage if node /tmp has quota limits)
    TMP_PATH="${ROOT_DIR}/tmp"
    MOUNT_TMP_PATH="${MOUNT_PATH}/tmp"
    # --- NGC image (use # between registry and image path for Enroot) ---
    NGC_IMAGE="docker://nvcr.io#nim/openfold/openfold2:2.7.0"
    CONTAINER_NAME="openfold2"
    ACTIVE_SQSH_PATH="${ROOT_DIR}/openfold2.sqsh"
    # --- Helpers ---
    handle_error() {
    echo "Error: $1"
    exit 1
    }
    mkdir -p "$(dirname "${ACTIVE_SQSH_PATH}")" || handle_error "Failed to create directory for SQSH file"
    mkdir -p "${CACHE_PATH}" || handle_error "Failed to create cache directory"
    chmod 700 "${CACHE_PATH}" || handle_error "Failed to set cache directory permissions"
    mkdir -p "${TMP_PATH}" || handle_error "Failed to create tmp directory"
    echo "Step 1: Requesting interactive resources..."
    srun --account="${ACCOUNT}" \
    --partition="${PARTITION}" \
    --gpus-per-node="${GPUS_PER_NODE}" \
    --mem="${MEMORY}" \
    --time="${TIME}" \
    --export=ALL \
    -o /dev/tty -e /dev/tty \
    bash -c "
    echo \"Loading environment...\"
    # Step 2: Import Docker image (if not present)
    echo \"Step 2: Importing Docker image\"
    if [ ! -f \"${ACTIVE_SQSH_PATH}\" ]; then
    echo \"Importing from NGC...\"
    mkdir -p \"\$(dirname \"${ACTIVE_SQSH_PATH}\")\" || { echo \"Failed to create directory\"; exit 1; }
    enroot import -o \"${ACTIVE_SQSH_PATH}\" ${NGC_IMAGE} || { echo \"Failed to import Docker image\"; exit 1; }
    else
    echo \"Docker image already exists, skipping import.\"
    fi
    # Step 3: Create Enroot container
    echo \"Step 3: Creating Enroot container...\"
    if enroot list 2>/dev/null | grep -q \"${CONTAINER_NAME}\"; then
    echo \"Removing existing container...\"
    enroot remove -f ${CONTAINER_NAME} || true
    fi
    enroot create --name ${CONTAINER_NAME} \"${ACTIVE_SQSH_PATH}\" || { echo \"Failed to create container\"; exit 1; }
    # Step 4: Start container and NIM server
    NODE=\$(hostname)
    echo \"\$NODE\" > \"${WORKING_PATH}/.openfold2_node\"
    echo \"Step 4: OpenFold2 container ready.\"
    echo \"=====================================\"
    echo \"Working directory in container: ${MOUNT_PATH}\"
    echo \"\"
    echo \"From another terminal (login node or your machine), run:\"
    echo \" ssh -L 8000:localhost:8000 \$NODE\"
    echo \"Then keep that SSH session open and call the API (see Step 3 in docs).\"
    echo \"Node name saved to: ${WORKING_PATH}/.openfold2_node\"
    echo \"Type exit to leave the container.\"
    echo \"=====================================\"
    cat > \"\${TMPDIR:-/tmp}/rc.local\" << RCEOF
    #!/bin/sh
    export TMPDIR=${MOUNT_TMP_PATH}
    export TEMP=${MOUNT_TMP_PATH}
    export TMP=${MOUNT_TMP_PATH}
    export HOME=${MOUNT_PATH}
    export XDG_CACHE_HOME=${WORKING_CACHE_DIR}
    export XDG_DATA_HOME=${MOUNT_PATH}/.local/share
    mkdir -p ${MOUNT_TMP_PATH} ${MOUNT_PATH}/.local/share
    /opt/nim/start_server.sh &
    exec /bin/bash
    RCEOF
    chmod +x \"\${TMPDIR:-/tmp}/rc.local\"
    enroot start \\
    --mount ${CACHE_PATH}:${WORKING_CACHE_DIR} \\
    --mount ${WORKING_PATH}:${MOUNT_PATH} \\
    --mount \"\${TMPDIR:-/tmp}/rc.local:/etc/rc.local\" \\
    -e TMPDIR=${MOUNT_TMP_PATH} \\
    -e TEMP=${MOUNT_TMP_PATH} \\
    -e TMP=${MOUNT_TMP_PATH} \\
    -e HOME=${MOUNT_PATH} \\
    -e XDG_CACHE_HOME=${WORKING_CACHE_DIR} \\
    -e XDG_DATA_HOME=${MOUNT_PATH}/.local/share \\
    ${CONTAINER_NAME} || { echo \"Failed to start container\"; exit 1; }
    echo \"=====================================\"
    echo \"Workflow completed.\"
    "

    Submit the job (interactive):

    bash openfold2_srun.sh

    Alternatively, for a batch job, wrap the same script body in an sbatch script and set ACCOUNT, PARTITION, and other Slurm directives as needed.

  3. Call the API from your machine.

    After the container is running on a compute node, the script prints the node name and saves it to ROOT_DIR/.openfold2_node.

    First, from your laptop or the login node, create an SSH tunnel to that node:

    ssh -L 8000:localhost:8000 $(cat /path/to/your/workspace/.openfold2_node)

    Or use the node name directly if you know it:

    ssh -L 8000:localhost:8000 <compute-node-name>

    Then, in another terminal (with the tunnel still open), run a test request:

    curl -s -X POST 'http://localhost:8000/biology/openfold/openfold2/predict-structure-from-msa-and-template' \
    -H "content-type: application/json" \
    -H "NVCF-POLL-SECONDS: 300" \
    -d '{"sequence":"GGSKENEISHHAKEIERLQKEIERHKQSIKKLKQSEQSNPPPNPEGTRQARRNRRRRWRERQRQKENEISHHAKEIERLQKEIERHKQSIKKLKQSEC","selected_models":[1,2]}' \
    --max-time 300

    If the request succeeds, you get a JSON response containing the prediction result.