-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.gnina-bundle
More file actions
89 lines (85 loc) · 4.52 KB
/
Copy pathDockerfile.gnina-bundle
File metadata and controls
89 lines (85 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# syntax=docker/dockerfile:1
#
# Curated gnina runtime bundle.
#
# gnina v1.3.3+ ships a *statically linked* release binary that bakes in
# gnina's own deps (libtorch, libmolgrid, libopenbabel, boost, jsoncpp, ICU,
# numa, openblas, gfortran) — only the CUDA 12 runtime remains dynamic.
# That eliminates the ~40 lines of cross-distro SONAME extraction from the
# upstream Ubuntu 20.04 ``gnina/gnina`` image the old bundle relied on, and
# also lets us drop the libopenbabel-plugin shim that used to live in
# ``guild/docking/gnina.py`` (OB is now statically linked with plugins baked
# into the binary).
#
# The remaining ~7 CUDA libs (libcudart, libcudnn, libcublas{,Lt}, libcufft,
# libcusparse, libcusolver) come from nvidia's pip wheels — matches the
# CUDA-12 major version the binary is built against without inheriting
# whatever CUDA layout ``gnina/gnina:latest`` happens to ship.
#
# The final stage is ``FROM scratch`` so the published image is just the
# /export tree. Build it once and tag it (locally or in your own registry),
# then point the main Dockerfile's GNINA_BUNDLE_IMAGE build arg at that tag:
#
# docker build -f Dockerfile.gnina-bundle -t gnina-bundle:local .
# docker build --build-arg GNINA_BUNDLE_IMAGE=gnina-bundle:local -t guild .
#
# The main image then does:
#
# ARG GNINA_BUNDLE_IMAGE
# FROM ${GNINA_BUNDLE_IMAGE} AS gnina-source
# ...
# COPY --from=gnina-source /export /opt/gnina
#
# and invokes ``gnina`` with ``LD_LIBRARY_PATH=/opt/gnina/lib`` so the bundle's
# CUDA runtime doesn't clash with the main image's venv-managed one.
#
# --- Bumping gnina --------------------------------------------------------
# 1. Update the three ARGs below (GNINA_VERSION / GNINA_ASSET / GNINA_SHA256)
# from the GitHub release page: https://github.com/gnina/gnina/releases
# 2. Rebuild locally: ``docker build -f Dockerfile.gnina-bundle -t gnina-bundle:local .``
# 3. Verify no new dynamic deps appeared:
# docker run --rm -e LD_LIBRARY_PATH=/opt/gnina/lib \
# --entrypoint ldd guild:latest /opt/gnina/bin/gnina | grep 'not found'
# If any lib prints, add its matching ``nvidia-*-cu12`` wheel to the
# pip install below and rebuild.
# Debian slim base — glibc + libstdc++ compatible with dkoes' static build.
# We only need Python + curl for the fetch/install steps; the resulting
# /export tree is copied into a ``FROM scratch`` image at the end so none
# of this base's contents ship downstream.
FROM debian:bookworm-slim AS extract
ARG GNINA_VERSION=v1.3.3
ARG GNINA_ASSET=gnina.cuda12.8.static
ARG GNINA_SHA256=3340c1f49cd3c7c84d8699182a1c6af13c7fa2a22448d1204640446106f72172
RUN set -eux; \
apt-get update; \
# ``openbabel`` on Debian bookworm ships UFF.prm and the other data files
# gnina's static OpenBabel needs at runtime for --covalent_optimize_lig
# (the code was linked in but the data tree wasn't — without this, gnina
# prints "Cannot open UFF.prm" and skips the post-bond UFF minimisation).
apt-get install -y --no-install-recommends \
curl ca-certificates python3 python3-pip openbabel; \
rm -rf /var/lib/apt/lists/*; \
mkdir -p /export/bin /export/lib /export/share/openbabel; \
curl -fL -o /export/bin/gnina \
https://github.com/gnina/gnina/releases/download/${GNINA_VERSION}/${GNINA_ASSET}; \
echo "${GNINA_SHA256} /export/bin/gnina" | sha256sum -c -; \
chmod +x /export/bin/gnina; \
# Copy OB data files (UFF.prm etc.) into the bundle so
# ``BABEL_DATADIR=/opt/gnina/share/openbabel`` at runtime resolves them.
OB_DATA=$(find /usr/share/openbabel /usr/local/share/openbabel \
-maxdepth 3 -name "UFF.prm" -printf "%h\n" 2>/dev/null | head -1); \
if [ -z "${OB_DATA}" ]; then \
echo "!! UFF.prm not found in the openbabel Debian package"; exit 1; \
fi; \
cp -RL "${OB_DATA}"/* /export/share/openbabel/; \
# CUDA 12 runtime libs — see header for the diagnostic command to run
# after a version bump if any new ``not found`` lib appears.
pip3 install --no-cache-dir --break-system-packages \
nvidia-cudnn-cu12 nvidia-cuda-runtime-cu12 nvidia-cublas-cu12 \
nvidia-cufft-cu12 nvidia-cusparse-cu12 nvidia-cusolver-cu12; \
NVIDIA_ROOT=$(python3 -c "import nvidia; print(nvidia.__path__[0])"); \
find "${NVIDIA_ROOT}" -name "*.so*" -exec cp -L {} /export/lib/ \;
####################################################################################################
# Tiny published image: just /export, nothing else. ~2 GB on disk.
FROM scratch AS bundle
COPY --from=extract /export /export