Skip to content

Commit 234134b

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 234134b

File tree

2 files changed

+107
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)