Skip to content

Commit 0df6ac3

Browse files
Boltz (#46)
* added boltz
1 parent 34c3b45 commit 0df6ac3

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed

applications/boltz/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Use the official Ubuntu image as a base
2+
ARG FROM_IMAGE=ubuntu:24.04
3+
4+
# Stage 1: Set up Conda environment
5+
ARG BASE_IMAGE=condaforge/miniforge3:24.3.0-0
6+
FROM ${BASE_IMAGE} as conda_setup
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
# Stage 2: Set up the main build environment
10+
FROM ${FROM_IMAGE} as builder
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
# Install necessary build tools and clean up
14+
RUN apt-get update && apt-get install -y --no-install-recommends \
15+
git build-essential wget vim ca-certificates numactl autoconf automake make && \
16+
rm -rf /var/lib/apt/lists/* && \
17+
apt-get autoremove -y && \
18+
apt-get clean
19+
20+
# Build arguments for host UID/GID
21+
ARG USER_ID=2000
22+
ARG GROUP_ID=2000
23+
24+
ENV SERVICE_NAME="boltz-service"
25+
26+
# Create a user and group with same UID and GID as host
27+
RUN groupadd --gid ${GROUP_ID} $SERVICE_NAME && \
28+
useradd -m -g $SERVICE_NAME --shell /bin/false --uid ${USER_ID} $SERVICE_NAME
29+
30+
# Copy Conda installation from the conda_setup stage
31+
COPY --from=conda_setup /opt/conda /opt/conda
32+
ENV PATH="/opt/conda/bin:$PATH"
33+
ENV LD_LIBRARY_PATH="/opt/conda/lib:${LD_LIBRARY_PATH:-}"
34+
RUN echo "source activate" >> ~/.bashrc
35+
36+
RUN git clone --branch 5.3.0 https://github.com/jemalloc/jemalloc.git
37+
WORKDIR /jemalloc
38+
RUN bash autogen.sh --prefix=/opt/conda/ && make install
39+
WORKDIR /
40+
RUN rm -rf jemalloc
41+
42+
WORKDIR /app
43+
RUN chown -R $SERVICE_NAME:$SERVICE_NAME /app
44+
RUN git clone --branch v0.4.1 https://github.com/jwohlwend/boltz.git
45+
46+
WORKDIR /app/boltz
47+
RUN pip install -e .
48+
49+
# Switch to non-root user
50+
RUN chown -R $SERVICE_NAME:$SERVICE_NAME /app/boltz
51+
COPY ./entrypoint.sh entrypoint.sh
52+
RUN chmod +x entrypoint.sh
53+
54+
USER $SERVICE_NAME
55+
56+
# bin bash
57+
# Clone Boltz 1 repository (replace with the actual repo URL)
58+
ENTRYPOINT ["/app/boltz/entrypoint.sh"]
59+
60+
# Default command
61+
CMD ["default"]

applications/boltz/README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
## 🔍 Running Inference with Boltz Docker
2+
3+
Follow the steps below to run inference using the Boltz Docker container:
4+
5+
---
6+
7+
### 🐳 1. Build the Docker Image
8+
9+
From the root of the project directory, build the Docker image:
10+
11+
```bash
12+
docker build -t boltz1 .
13+
```
14+
15+
---
16+
17+
### 📁 2. Create and Set Output Directory Permissions
18+
19+
Create an output folder and give it proper write permissions:
20+
21+
```bash
22+
mkdir -p <output_folder_location> <model_folder_location>
23+
chmod a+w <output_folder_location> <model_folder_location>
24+
25+
export OUTPUT=$PWD/<output_folder_location>
26+
export MODELS=$PWD/<model_folder_location>
27+
export INPUT=$PWD/<input_folder_location>
28+
```
29+
30+
> ⚠️ Docker needs write permissions in the `<output_folder_location>` and `<model_folder_location>` folder. `<input_folder_location>` is the folder contaning the input `.yaml` or `.fasta` file
31+
32+
Example
33+
34+
```bash
35+
mkdir -p ./output ./model
36+
chmod a+w ./output ./model
37+
38+
export OUTPUT=$PWD/output
39+
export MODELS=$PWD/model
40+
export INPUT=$PWD/examples/
41+
```
42+
43+
---
44+
45+
### 🚀 3. Run Inference
46+
47+
In order to do inferencing few things needs to be done
48+
Mount the volumes for input folder and output folder. Pass the mounted volumes to boltz as arguments. So the docker run command looks like
49+
50+
```bash
51+
docker run -it \
52+
--shm-size=100g \
53+
-v $INPUT:/app/boltz/input \
54+
-v $MODELS:/home/boltz-service/.boltz/ \
55+
-v $OUTPUT:/app/boltz/output \
56+
boltz1
57+
```
58+
59+
> 📝 The `--shm-size=100g` flag avoids shared memory issues during data loading with PyTorch.
60+
61+
---
62+
63+
### ✅ Output
64+
65+
Results will be written to the <output_folder_location> folder.
66+
67+
Boltz currently accepts three input formats:
68+
69+
1. Fasta file, for most use cases
70+
71+
2. A comprehensive YAML schema, for more complex use cases
72+
73+
3. A directory containing files of the above formats, for batched processing
74+
75+
## For more information checkout [boltz](https://github.com/jwohlwend/boltz)
76+
77+
## License
78+
79+
Our model and code are released under MIT License, and can be freely used for both academic and commercial purposes.
80+
81+
82+
## Cite
83+
84+
If you use this code or the models in your research, please cite the following paper:
85+
86+
```bibtex
87+
@article{wohlwend2024boltz1,
88+
author = {Wohlwend, Jeremy and Corso, Gabriele and Passaro, Saro and Reveiz, Mateo and Leidal, Ken and Swiderski, Wojtek and Portnoi, Tally and Chinn, Itamar and Silterra, Jacob and Jaakkola, Tommi and Barzilay, Regina},
89+
title = {Boltz-1: Democratizing Biomolecular Interaction Modeling},
90+
year = {2024},
91+
doi = {10.1101/2024.11.19.624167},
92+
journal = {bioRxiv}
93+
}
94+
```
95+
96+
In addition if you use the automatic MSA generation, please cite:
97+
98+
```bibtex
99+
@article{mirdita2022colabfold,
100+
title={ColabFold: making protein folding accessible to all},
101+
author={Mirdita, Milot and Sch{\"u}tze, Konstantin and Moriwaki, Yoshitaka and Heo, Lim and Ovchinnikov, Sergey and Steinegger, Martin},
102+
journal={Nature methods},
103+
year={2022},
104+
}
105+
```

applications/boltz/entrypoint.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
INPUT_DIR="/app/boltz/input"
4+
OUTPUT_DIR="/app/boltz/output"
5+
CUDA_VISIBLE_DEVICES=""
6+
7+
FOUND=0
8+
9+
for INPUT_FILE in "$INPUT_DIR"/*; do
10+
# Only process .yaml or .fasta files
11+
if [[ "$INPUT_FILE" == *.yaml || "$INPUT_FILE" == *.fasta ]]; then
12+
echo "📂 Processing: $INPUT_FILE"
13+
LD_PRELOAD=/opt/conda/lib/libjemalloc.so:$LD_PRELOAD \
14+
MALLOC_CONF="oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:-1,muzzy_decay_ms:-1" \
15+
boltz predict "$INPUT_FILE" --out_dir "$OUTPUT_DIR" --accelerator "cpu"
16+
FOUND=1
17+
fi
18+
done
19+
20+
if [[ $FOUND -eq 0 ]]; then
21+
echo "❌ No .yaml or .fasta files found in $INPUT_DIR"
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)