Skip to content

Commit 9cddb1e

Browse files
committed
feat: immich uv
1 parent 73fa0aa commit 9cddb1e

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

Diff for: Dockerfile

+27-22
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,25 @@ ENV \
1818
IMMICH_PORT="8080" \
1919
MACHINE_LEARNING_CACHE_FOLDER="/config/machine-learning/models" \
2020
NVIDIA_DRIVER_CAPABILITIES="compute,video,utility" \
21-
TRANSFORMERS_CACHE="/config/machine-learning/models"
21+
TRANSFORMERS_CACHE="/config/machine-learning/models" \
22+
UV_PYTHON_INSTALL_DIR="/usr/local/bin"
2223

2324
RUN \
2425
echo "**** install build packages ****" && \
26+
echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/ /" >>/etc/apt/sources.list.d/cuda.list && \
27+
curl -s "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub" | gpg --dearmor | tee /usr/share/keyrings/cuda-archive-keyring.gpg >/dev/null && \
28+
printf "Package: *\nPin: release l=NVIDIA CUDA\nPin-Priority: 600" > /etc/apt/preferences.d/cuda && \
2529
apt-get update && \
2630
apt-get install --no-install-recommends -y \
27-
build-essential \
28-
python3-dev && \
31+
build-essential && \
2932
echo "**** install runtime packages ****" && \
3033
apt-get install --no-install-recommends -y \
3134
libcublas12 \
3235
libcublaslt12 \
3336
libcudart12 \
37+
libcudnn9-cuda-12 \
3438
libcufft11 \
35-
libcurand10 \
36-
python3 \
37-
python3-pip \
38-
python3-venv && \
39-
echo "**** download libcudnn ****" && \
40-
curl -o "/tmp/libcudnn9.deb" -L \
41-
"https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/libcudnn9-cuda-12_9.2.1.18-1_amd64.deb" && \
42-
dpkg -i "/tmp/libcudnn9.deb" && \
39+
libcurand10 && \
4340
echo "**** download immich ****" && \
4441
mkdir -p \
4542
/tmp/immich && \
@@ -115,17 +112,23 @@ RUN \
115112
mkdir -p \
116113
/app/immich/machine-learning/ann && \
117114
cd /tmp/immich/machine-learning && \
118-
pip install --break-system-packages -U --no-cache-dir \
119-
poetry && \
120-
python3 -m venv /lsiopy && \
121-
poetry config installer.max-workers 10 && \
122-
poetry config virtualenvs.create false && \
123-
poetry install --sync --no-interaction --no-ansi --no-root --with cuda --without dev && \
115+
if [ -z ${UV_VERSION} ]; then \
116+
UV_VERSION=$(curl -sL https://api.github.com/repos/astral-sh/uv/releases/latest | \
117+
jq -r '.tag_name'); \
118+
fi && \
119+
curl -o \
120+
/tmp/uv.tar.gz -L \
121+
"https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-x86_64-unknown-linux-gnu.tar.gz" && \
122+
tar xf \
123+
/tmp/uv.tar.gz -C \
124+
/tmp --strip-components=1 && \
125+
/tmp/uv python install --default --preview 3.11 && \
126+
/tmp/uv sync --active --frozen --extra openvino --no-dev --no-editable --no-install-project --compile-bytecode --no-progress && \
124127
cp -a \
125128
pyproject.toml \
126-
poetry.lock \
127129
app \
128130
log_conf.json \
131+
uv.lock \
129132
/app/immich/machine-learning && \
130133
cp -a \
131134
ann/ann.py \
@@ -135,16 +138,18 @@ RUN \
135138
find /usr/local/lib/python3.* /usr/lib/python3.* /lsiopy/lib/python3.* -name "${cleanfiles}" -delete; \
136139
done && \
137140
apt-get remove -y --purge \
138-
build-essential \
139-
python3-dev && \
141+
build-essential && \
140142
apt-get autoremove -y --purge && \
141143
apt-get clean && \
142144
rm -rf \
145+
/etc/apt/preferences.d/cuda \
146+
/etc/apt/sources.list.d/cuda.list \
147+
/root/.cache \
148+
/root/.npm
143149
/tmp/* \
150+
/usr/share/keyrings/cuda-archive-keyring.gpg \
144151
/var/tmp/* \
145152
/var/lib/apt/lists/* \
146-
/root/.cache \
147-
/root/.npm
148153

149154
# copy local files
150155
COPY root/ /

0 commit comments

Comments
 (0)