Skip to content

AlphaFold3/en

This page discusses how to use AlphaFold v3.0.

Source code and documentation for AlphaFold3 can be found at their GitHub page. Any publication that discloses findings arising from use of this source code or the model parameters should cite the AlphaFold3 paper.

Available versions

AlphaFold3 is available on our clusters as prebuilt Python packages (wheels). You can list available versions with avail_wheels.

avail_wheels alphafold3

AlphaFold2 is still available. Documentation is here.

Creating a requirements file for AlphaFold3

  1. Load AlphaFold3 dependencies.
module load StdEnv/2023 hmmer-alphafold3/3.4 rdkit/2025.09.4 python/3.12

Warning

Different versions of AlphaFold3 require different versions of RDKit. If you encounter an error message while installing the alphafold3 Python package (see below), reload the rdkit module with the version mentioned in the error message.

  1. Download run script.

You can download the run_alphafold.py script for your desired AlphaFold3 version:

  • For v3.0.4:
    wget https://raw.githubusercontent.com/google-deepmind/alphafold3/refs/tags/v3.0.4/run_alphafold.py
    
  • For v3.0.2:
    wget https://raw.githubusercontent.com/google-deepmind/alphafold3/refs/tags/v3.0.2/run_alphafold.py
    
  • For v3.0.1:
    wget https://raw.githubusercontent.com/google-deepmind/alphafold3/refs/tags/v3.0.1/run_alphafold.py
    
  • For v3.0.0:

    wget https://raw.githubusercontent.com/google-deepmind/alphafold3/23e3d46d4ca126e8731e8c0cbb5673e9a848ceb5/run_alphafold.py
    

  • Create and activate a Python virtual environment.

virtualenv --no-download ~/alphafold3_env
source ~/alphafold3_env/bin/activate
  1. Install a specific version of AlphaFold3 and its Python dependencies.

(alphafold3_env) [name@server ~]$ pip install --no-index --upgrade pip
(alphafold3_env) [name@server ~]$ pip install --no-index alphafold3==X.Y.Z
where X.Y.Z is the exact desired version, for instance 3.0.4. You can omit to specify the version in order to install the latest one available from the wheelhouse.

  1. Build data.

(alphafold3_env) [name@server ~]$ build_data
This will create data files inside your virtual environment.

  1. Validate it.
(alphafold3_env) [name@server ~]$ python run_alphafold.py --help
  1. Freeze the environment and requirements set.
(alphafold3_env) [name@server ~]$ pip freeze > ~/alphafold3-requirements.txt
  1. Deactivate the environment.
(alphafold3_env) [name@server ~]$ deactivate
  1. Clean up and remove the virtual environment.
rm -r ~/alphafold3_env

The virtual environment will be created in your job instead.

Model

AlphaFold3 uses model parameters for inference. Before downloading the model, you must accept these terms of use.

Important

Model parameters must be stored in your $SCRATCH directory.

Download the model with:

mkdir -p $SCRATCH/alphafold/models
wget https://storage.googleapis.com/alphafold3/af3.bin.zst -P $SCRATCH/alphafold/models/

Databases

AlphaFold3 uses a set of databases for its data pipeline.

Important

The databases must be stored in your $SCRATCH directory.

  1. Download the fetch script:
wget https://raw.githubusercontent.com/google-deepmind/alphafold3/refs/heads/main/fetch_databases.sh
  1. Download the databases:
mkdir -p $SCRATCH/alphafold/dbs
bash fetch_databases.sh $SCRATCH/alphafold/dbs

Running AlphaFold3 in stages

Alphafold3 must be run in stages, that is: 1. Splitting the CPU-only data pipeline from model inference (which requires a GPU), to optimise cost and resource usage. 2. Caching the results of MSA/template search, then reusing the augmented JSON for multiple different inferences across seeds or across variations of other features (e.g., a ligand).

For reference on Alphafold3: * see inputs * see outputs * see performance

The following example shows how to fold a 70 kDa homodimer protein (PDB ID 2PV7). This is the same example provided in the AlphaFold3 documentation, but adapted for our clusters and split in two stages.

Input file

Create a directory for the input file.

mkdir -p $SCRATCH/alphafold/input

Add the following input file to the new directory.

fold_input.json
{
  "name": "2PV7",
  "sequences": [
    {
      "protein": {
        "id": ["A", "B"],
        "sequence": "GMRESYANENQFGFKTINSDIHKIVIVGGYGKLGGLFARYLRASGYPISILDREDWAVAESILANADVVIVSVPINLTLETIERLKPYLTENMLLADLTSVKREPLAKMLEVHTGAVLGLHPMFGADIASMAKQVVVRCDGRFPERYEWLLEQIQIWGAKIYQTNATEHDHNMTYIQALRHFSTFANGLHLSKQPINLANLLALSSPIYRLELAMIGRLFAQDAELYADIIMDKSENLAVIETLKQTYDEALTFFENNDRQGFIDAFHKVRDWFGDYSEQFLKESRQLLQQANDLKQG"
      }
    }
  ],
  "modelSeeds": [1],
  "dialect": "alphafold3",
  "version": 1
}

Data pipeline (CPU)

Edit the following job script according to your needs.

alphafold3-data.sh
#!/bin/bash

#SBATCH --job-name=alphafold3-data
#SBATCH --account=def-someprof  # set the accounting group you use to submit jobs
#SBATCH --time=08:00:00         # set the time limit for your job
#SBATCH --cpus-per-task=8       # MAXIMUM 8 cores, AlphaFold3 does not benefit from more
#SBATCH --mem=64G               # set the memory needed for your job

# Load modules dependencies.
module load StdEnv/2023 hmmer-alphafold3/3.4 rdkit/2025.09.4 python/3.12

DB_DIR=$SCRATCH/alphafold/dbs              # downloaded database directory
INPUT_DIR=$SCRATCH/alphafold/input         # input data directory
OUTPUT_DIR=$SCRATCH/alphafold/data-output  # intermediate output directory for data pipeline
mkdir -p $OUTPUT_DIR

# Generate your virtual environment in $SLURM_TMPDIR.
virtualenv --no-download $SLURM_TMPDIR/env
source $SLURM_TMPDIR/env/bin/activate

# Install AlphaFold and its dependencies.
pip install --no-index --upgrade pip
pip install --no-index --requirement ~/alphafold3-requirements.txt

# build data in $VIRTUAL_ENV
build_data

# https://github.com/google-deepmind/alphafold3/blob/main/docs/performance.md#compilation-time-workaround-with-xla-flags
export XLA_FLAGS="--xla_gpu_enable_triton_gemm=false"

# Edit with the proper arguments and run your commands.
# run_alphafold.py --help
python run_alphafold.py \
    --db_dir=$DB_DIR \
    --input_dir=$INPUT_DIR \
    --output_dir=$OUTPUT_DIR \
    --jax_compilation_cache_dir=$HOME/.cache \
    --nhmmer_n_cpu=$SLURM_CPUS_PER_TASK \
    --jackhmmer_n_cpu=$SLURM_CPUS_PER_TASK \
    --norun_inference  # Run data stage

The data pipeline writes to a subdirectory in $OUTPUT_DIR, named according to the name tag in the input file, here 2PV7.

Model inference (GPU)

Edit the following job script according to your needs.

alphafold3-inference.sh
#!/bin/bash

#SBATCH --job-name=alphafold3-inference
#SBATCH --account=def-someprof  # set the accounting group you use to submit jobs
#SBATCH --time=08:00:00         # set the time limit for your job
#SBATCH --cpus-per-task=1       # AlphaFold3 inference uses a single core
#SBATCH --gpus=a100:1           # Alphafold3 inference uses a single (A100 or more recent) GPU
#SBATCH --mem=20G               # set the memory needed for your job

# Load modules dependencies.
module load StdEnv/2023 hmmer-alphafold3/3.4 rdkit/2025.09.4 python/3.12 cuda/12.2 cudnn/9.2

MODEL_DIR=$SCRATCH/alphafold/models             # downloaded model parameters
INPUT_DIR=$SCRATCH/alphafold/data-output/2PV7   # intermediate directory created by the data pipeline
OUTPUT_DIR=$SCRATCH/alphafold/inference-output  # final output directory for inference
mkdir -p $OUTPUT_DIR

# Generate your virtual environment in $SLURM_TMPDIR.
virtualenv --no-download $SLURM_TMPDIR/env
source $SLURM_TMPDIR/env/bin/activate

# Install AlphaFold and its dependencies.
pip install --no-index --upgrade pip
pip install --no-index --requirement ~/alphafold3-requirements.txt

# build data in $VIRTUAL_ENV
build_data

# https://github.com/google-deepmind/alphafold3/blob/main/docs/performance.md#compilation-time-workaround-with-xla-flags
export XLA_FLAGS="--xla_gpu_enable_triton_gemm=false"

# https://github.com/google-deepmind/alphafold3/blob/main/docs/performance.md#gpu-memory
export XLA_PYTHON_CLIENT_PREALLOCATE=true
export XLA_CLIENT_MEM_FRACTION=0.95

# Edit with the proper arguments and run your commands.
# run_alphafold.py --help
python run_alphafold.py \
    --model_dir=$MODEL_DIR \
    --input_dir=$INPUT_DIR \
    --output_dir=$OUTPUT_DIR \
    --jax_compilation_cache_dir=$HOME/.cache \
    --norun_data_pipeline  # Run inference stage

Job submission

Then, submit the jobs to the scheduler.

Independent jobs

sbatch alphafold3-data.sh

Wait until it completes, then submit the second stage:

sbatch alphafold3-inference.sh

Dependent jobs

jid1=$(sbatch alphafold3-data.sh)
jid2=$(sbatch --dependency=afterok:$jid1 alphafold3-inference.sh)
sq
If the first stage fails, you will have to manually cancel the second stage:
scancel -u $USER -n alphafold3-inference

Troubleshooting

Out of memory (GPU)

If you would like to run AlphaFold3 on inputs larger than 5,120 tokens, or on a GPU with less memory (an A100 with 40 GB of memory, for instance), you can enable unified memory

In your submission script for the inference stage, add these environment variables:

export XLA_PYTHON_CLIENT_PREALLOCATE=false
export TF_FORCE_UNIFIED_MEMORY=true
export XLA_CLIENT_MEM_FRACTION=2.0  # 2 x 40GB = 80 GB

and adjust the amount of memory allocated to your job accordingly, for instance: #SBATCH --mem=80G