Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions clair3-gpu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# syntax=docker/dockerfile:1.4
# ---------------------------------------------------------------------------
# Clair3 GPU Dockerfile
#
# Requires: NVIDIA Container Toolkit on the host
# Run with: docker run --gpus all hkubal/clair3:gpu ...
#
# CUDA 12.1 requires NVIDIA driver >= 530.30.02
# To use a different CUDA version, change the base image tag and the
# --index-url in the PyTorch install step (e.g. cu124 for CUDA 12.4).
# ---------------------------------------------------------------------------
FROM nvidia/cuda:11.6.2-runtime-ubuntu20.04

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /opt/bin

# Ensure the NVIDIA runtime exposes GPUs inside the container.
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility

# Install system dependencies and Miniforge (mamba).
RUN apt-get update && apt-get install -y --no-install-recommends \
wget bzip2 ca-certificates && \
rm -rf /var/lib/apt/lists/* && \
wget -qO /tmp/miniforge.sh \
"https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" && \
bash /tmp/miniforge.sh -b -p /opt/conda && \
rm /tmp/miniforge.sh

ENV PATH=/opt/conda/bin:${PATH}

# Step 1 in README: create a conda env with bioinformatics/build dependencies.
RUN mamba create -n clair3_v2 \
-c conda-forge \
-c bioconda \
python=3.11 \
samtools \
whatshap \
parallel \
zstd \
xz \
zlib \
bzip2 \
automake \
make \
gcc \
gxx \
binutils \
curl \
pigz \
boost-cpp \
-y && \
mamba clean --all -y

ENV CONDA_PREFIX=/opt/conda/envs/clair3_v2
ENV CONDA_DEFAULT_ENV=clair3_v2
ENV PATH=${CONDA_PREFIX}/bin:/opt/bin:/opt/conda/bin:${PATH}

# Step 2 & Step 4 in README: install uv, PyTorch (CUDA 12.1), and Python dependencies.
RUN pip install --no-cache-dir uv && \
uv pip install --python ${CONDA_PREFIX}/bin/python \
torch torchvision \
--index-url https://download.pytorch.org/whl/cu116 && \
uv pip install --python ${CONDA_PREFIX}/bin/python \
numpy \
h5py \
hdf5plugin \
numexpr \
tqdm \
cffi \
torchmetrics

# Clair3 source tree
WORKDIR /
RUN wget https://github.com/HKU-BAL/Clair3/archive/refs/tags/v2.0.0.tar.gz \
&& tar -xvzf v2.0.0.tar.gz \
&& mv Clair3-2.0.0/* /opt/bin
WORKDIR /opt/bin

# Build Clair3 native components.
RUN make PREFIX=${CONDA_PREFIX} PYTHON=${CONDA_PREFIX}/bin/python && \
cd /opt/bin/preprocess/realign && \
g++ -std=c++14 -O1 -shared -fPIC -o realigner ssw_cpp.cpp ssw.c realigner.cpp && \
g++ -std=c++11 -shared -fPIC -o debruijn_graph -O3 debruijn_graph.cpp && \
rm -rf /opt/bin/samtools-* /opt/bin/longphase-*

# Step 5 in README: install pypy3.11 and mpmath for pypy.
RUN wget -q https://downloads.python.org/pypy/pypy3.11-v7.3.20-linux64.tar.bz2 && \
tar -xjf pypy3.11-v7.3.20-linux64.tar.bz2 && \
rm pypy3.11-v7.3.20-linux64.tar.bz2 && \
ln -sf /opt/bin/pypy3.11-v7.3.20-linux64/bin/pypy3 ${CONDA_PREFIX}/bin/pypy3 && \
ln -sf /opt/bin/pypy3.11-v7.3.20-linux64/bin/pypy3 ${CONDA_PREFIX}/bin/pypy && \
pypy3 -m ensurepip && \
pypy3 -m pip install --no-cache-dir mpmath==1.2.1

# Step 6 in README: recursively download pre-trained PyTorch models from a directory URL.
# Pass --build-arg MODEL_CACHE_BUST=$(date +%s) to force a re-download without --no-cache.
ARG CLAIR3_MODELS_URL=https://www.bio8.cs.hku.hk/clair3/clair3_models_pytorch/
ARG MODEL_CACHE_BUST=0
RUN set -eux; \
echo "MODEL_CACHE_BUST=${MODEL_CACHE_BUST}"; \
mkdir -p /opt/models /tmp/clair3-models; \
base_url="${CLAIR3_MODELS_URL%/}"; \
wget -r -np -nH --cut-dirs=2 -R "index.html*" -P /tmp/clair3-models "${base_url}/"; \
if [ -d /tmp/clair3-models/clair3_models_pytorch ]; then \
cp -a /tmp/clair3-models/clair3_models_pytorch/. /opt/models/; \
else \
cp -a /tmp/clair3-models/. /opt/models/; \
fi; \
rm -rf /tmp/clair3-models
4 changes: 4 additions & 0 deletions clair3-gpu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Clair3-gpu

This image contains the [Clair3](https://github.com/hkubal/Clair3) tool compiled against a specific Cuda runtime version.

2 changes: 2 additions & 0 deletions clair3-gpu/image.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IMAGE_NAME=clair3-gpu
IMAGE_TAG=2.0.0-cuda11.6
Loading