Skip to content
NAISS Logo Allocations Support Training Software naiss.se

Alphafold

Arrhenius

How to create an AlphaFold3 image

Start an interactive session on a GPU node:

interactive -A naiss202t-u-xyz-gpu --partition gpu --gpus=1  -t 02:00:00

Fetch the definition file and build the image

wget https://gitlab.naiss.se/vikren/containers/-/raw/main/AlphaFold3/AlphaFold3-3.0.3.def
apptainer build  AlphaFold3-3.0.3.sif AlphaFold3-3.0.3.def

After building the image, you can exit the interactive session. Then, obtain model parameters from Google Deepmind: https://github.com/google-deepmind/alphafold3 and transfer them to Arrhenius in a folder consistent with the template below.

How to use the AlphaFold3

Example job script for a GPU run on 1 GPU card:

#!/bin/bash
#SBATCH -A XXXX-XX-XX     # Project ID   
#SBATCH -J job            # Job name                             
#SBATCH -t 01:50:00       # Wall time               
#SBATCH -p gpu            # GPU partition
#SBATCH --gpus=1          # Nr. of GPU cards 

# Environment variables for apptainer
export APPTAINERENV_XLA_FLAGS="--xla_disable_hlo_passes=custom-kernel-fusion-rewriter --xla_gpu_enable_triton_gemm=false"
export APPTAINERENV_XLA_PYTHON_CLIENT_PREALLOCATE=true
export APPTAINERENV_XLA_CLIENT_MEM_FRACTION=0.95

# Load the databases
ml hpc_sysenv/.1 AlphaFold3-data/3.0

# Directories on the host, note that in this example the AF3 image is located in the current
# directory as well as the input, output and modelparameters directories
AF3_HOME="$PWD"                                  # current directory
AF3_IMAGE="$AF3_HOME/AlphaFold3-3.0.3.sif"       # AF3 image
AF3_INPUT="$AF3_HOME/input"                      # input directory containing .json files
AF3_OUTPUT="$AF3_HOME/output"                    # directory where AF3 will save results 
AF3_MODELS="$AF3_HOME/modelparameters"           # directory where the af3.bin  af3.bin.zst files from Deepmind are saved
AF3_DB="$ALPHAFOLD3_DATA_DIR"                    # variable for the databases

# create an output directory if it doesn't exist
mkdir -p "$AF3_OUTPUT"

# Run AlphaFold3
apptainer run --nv \
    --bind "$AF3_INPUT:/mnt/af3_input:ro" \
    --bind "$AF3_OUTPUT:/mnt/af3_output" \
    --bind "$AF3_MODELS:/mnt/af3_models:ro" \
    --bind "$AF3_DB:/mnt/af3_db:ro" \
    "$AF3_IMAGE" \
    --model_dir=/mnt/af3_models \
    --db_dir=/mnt/af3_db \
    --output_dir=/mnt/af3_output \
    --json_path=/mnt/af3_input/my-input.json