Installing OpenFold Locally on O2

Set Up for Install

First, start an interactive session that uses GPU resources (https://harvardmed.atlassian.net/wiki/spaces/O2/pages/1629290761) :

$ srun --pty -p gpu --gres=gpu:1 -t 0-05:00 --mem 24G -c 4 bash

Load modules needed for later steps:

$ module load gcc/9.2.0 miniconda3/4.10.3 cuda/11.7 git/2.35.3 cmake/3.22.2

Navigate to the directory you would like to install OpenFold in and clone the repository:

$ git clone https://github.com/aqlaboratory/openfold.git $ cd openfold $ openfold_dir=$PWD

Install Main OpenFold Conda Package

While inside the OpenFold directory, create a Conda (https://harvardmed.atlassian.net/wiki/spaces/O2/pages/1594263516) environment. In this example the name of the environment we will create is openfold_test. This can be changed here, but it will carry over to other options in some later steps.

$ sed -i '4i\ - nvidia' environment.yml $ sed -i 's/conda-forge::cudatoolkit==11.3/conda-forge::cudatoolkit==11.6/g' environment.yml $ conda env create --name=openfold_test -f environment.yml

Activate this new environment using the command

$ source activate openfold_test

The prompt inside the terminal should change to contain the Conda environment name in parenthesis, in this case (openfold_test). We will add additional python modules and set up CUDA kernels using the commands below

# - This next command is optional, at this time if there are any errors from installing # - flash-attention, skip the step. (openfold_test)$ python3 -m pip install git+https://github.com/HazyResearch/flash-attention.git@5b838a8bef78186196244a4156ec35bbb58c337d (openfold_test)$ python3 -m pip install nvidia-pyindex (openfold_test)$ conda install -c conda-forge openmm=7.5.1 (openfold_test)$ wget -qnc https://raw.githubusercontent.com/deepmind/alphafold/main/docker/openmm.patch --no-check-certificate (openfold_test)$ (cd ${openfold_dir}/openfold-conda/lib/python3.7/site-packages; patch -s -p0 < openmm.patch) (openfold_test)$ python3 setup.py install

Download Parameters and Other Components

Here, we will open another terminal and ssh into transfer.rc.hms.harvard.edu. This node is configured to efficiently download data to O2. For more information, please visit https://harvardmed.atlassian.net/wiki/spaces/O2/pages/1588662157 .

$ ssh <HMS_ID>@transfer.rc.hms.harvard.edu $ cd /path/to/openfold/directory

Download dependent files. These files are put into the correct directory automatically as long as we are in the OpenFold directory cloned earlier.

#Download Folding Resources $ wget -q -P openfold/resources \ https://git.scicore.unibas.ch/schwede/openstructure/-/raw/7102c63615b64735c4941278d92b554ec94415f8/modules/mol/alg/src/stereo_chemical_props.txt #Needed For Certian Tests $ mkdir -p tests/test_data/alphafold/common $ ln -rs openfold/resources/stereo_chemical_props.txt tests/test_data/alphafold/common #Download OpenFold Parameters $ bash scripts/download_openfold_params.sh openfold/resources #Download Alphafold Parameters $ wget https://storage.googleapis.com/alphafold/alphafold_params_2022-01-19.tar $ mkdir -p openfold/resources/params $ tar -xvf alphafold_params_2022-01-19.tar -C openfold/resources/params #Decompress test data $ gunzip tests/test_data/sample_feats.pickle.gz

Export Paths

Afterwards, we will export the path to this directory. If you would like to have this program featured every time you log in , add the export line to your .bashrc file.

(openfold_test)$ export PATH=$openfold_dir:$PATH

Note: When OpenFold is running it will require HH-Suite, which is now installed as a module on O2. Run module load hh-suite/3.3.0 to enable to enable the module during runs.