Skip to content

Commit fd8006c

Browse files
committed
Add vllm to cpu inferencing Containerfile
To be built upon "ramalama" image Signed-off-by: Eric Curtin <[email protected]>
1 parent 53e38de commit fd8006c

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
FROM quay.io/ramalama/ramalama
2+
3+
WORKDIR /workspace/
4+
5+
ENV PATH="/root/.local/bin:$PATH"
6+
ENV VIRTUAL_ENV="/opt/venv"
7+
ENV UV_PYTHON_INSTALL_DIR="/opt/uv/python"
8+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
9+
10+
ENV UV_HTTP_TIMEOUT=500
11+
12+
ENV UV_INDEX_STRATEGY="unsafe-best-match"
13+
ENV UV_LINK_MODE="copy"
14+
15+
RUN <<EOF
16+
#!/bin/bash
17+
18+
available() {
19+
command -v "$1" >/dev/null
20+
}
21+
22+
main() {
23+
set -eux -o pipefail
24+
25+
if available dnf; then
26+
dnf install -y git curl wget ca-certificates gcc gcc-c++ \
27+
gperftools-libs numactl-devel ffmpeg libSM libXext mesa-libGL jq lsof \
28+
vim numactl
29+
dnf -y clean all
30+
rm -rf /var/cache/*dnf*
31+
elif available apt-get; then
32+
apt-get update -y
33+
apt-get install -y --no-install-recommends git curl wget ca-certificates \
34+
gcc g++ libtcmalloc-minimal4 libnuma-dev ffmpeg libsm6 libxext6 libgl1 \
35+
jq lsof vim numactl
36+
rm -rf /var/lib/apt/lists/*
37+
fi
38+
39+
curl -LsSf https://astral.sh/uv/0.7.21/install.sh | bash
40+
}
41+
42+
main "$@"
43+
EOF
44+
45+
RUN <<EOF
46+
#!/bin/bash
47+
48+
preload_and_ulimit() {
49+
local ld_preload_file="libtcmalloc_minimal.so.4"
50+
local ld_preload_file_1="/usr/lib/$arch-linux-gnu/$ld_preload_file"
51+
local ld_preload_file_2="/usr/lib64/$ld_preload_file"
52+
if [ -e "$ld_preload_file1" ]; then
53+
ld_preload_file="$ld_preload_file1"
54+
elif [ -e "$ld_preload_file2" ]; then
55+
ld_preload_file="$ld_preload_file2"
56+
fi
57+
58+
if [ -e "$ld_preload_file" ]; then
59+
echo "LD_PRELOAD=$ld_preload_file" >> /etc/environment
60+
fi
61+
62+
echo 'ulimit -c 0' >> ~/.bashrc
63+
}
64+
65+
pip_install() {
66+
local url="https://download.pytorch.org/whl/cpu"
67+
uv pip install -v -r $1 --extra-index-url $url
68+
}
69+
70+
main() {
71+
set -eux -o pipefail
72+
73+
local arch=$(uname -m)
74+
preload_and_ulimit
75+
76+
uv venv --python 3.12 --seed ${VIRTUAL_ENV}
77+
uv pip install --upgrade pip
78+
79+
local v_vn="0.9.2"
80+
local vllm_url="https://github.com/vllm-project/vllm"
81+
curl -LsSf $vllm_url/releases/download/v$v_vn/vllm-$v_vn.tar.gz | tar xz
82+
cd vllm-$v_vn
83+
if [ "$arch" == "x86_64" ]; then
84+
export VLLM_CPU_DISABLE_AVX512="0"
85+
export VLLM_CPU_AVX512BF16="0"
86+
export VLLM_CPU_AVX512VNNI="0"
87+
elif [ "$arch" == "aarch64" ]; then
88+
export VLLM_CPU_DISABLE_AVX512="true"
89+
fi
90+
91+
pip_install requirements/cpu-build.txt
92+
pip_install requirements/cpu.txt
93+
94+
MAX_JOBS=2 VLLM_TARGET_DEVICE=cpu python3 setup.py install
95+
cd -
96+
rm -rf vllm-$v_vn /root/.cache
97+
}
98+
99+
main "$@"
100+
EOF
101+

0 commit comments

Comments
 (0)