-
Notifications
You must be signed in to change notification settings - Fork 249
Add vllm to cpu inferencing Containerfile #1677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM quay.io/ramalama/ramalama | ||
|
||
ENV PATH="/root/.local/bin:$PATH" | ||
ENV VIRTUAL_ENV="/opt/venv" | ||
ENV UV_PYTHON_INSTALL_DIR="/opt/uv/python" | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
ENV UV_HTTP_TIMEOUT=500 | ||
|
||
ENV UV_INDEX_STRATEGY="unsafe-best-match" | ||
ENV UV_LINK_MODE="copy" | ||
|
||
COPY . /src/ramalama | ||
WORKDIR /src/ramalama | ||
RUN container-images/scripts/build-vllm.sh | ||
WORKDIR / | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/bash | ||
|
||
available() { | ||
command -v "$1" >/dev/null | ||
} | ||
|
||
install_deps() { | ||
set -eux -o pipefail | ||
|
||
if available dnf; then | ||
dnf install -y git curl wget ca-certificates gcc gcc-c++ \ | ||
gperftools-libs numactl-devel ffmpeg libSM libXext mesa-libGL jq lsof \ | ||
vim numactl | ||
dnf -y clean all | ||
rm -rf /var/cache/*dnf* | ||
elif available apt-get; then | ||
apt-get update -y | ||
apt-get install -y --no-install-recommends git curl wget ca-certificates \ | ||
gcc g++ libtcmalloc-minimal4 libnuma-dev ffmpeg libsm6 libxext6 libgl1 \ | ||
jq lsof vim numactl | ||
rm -rf /var/lib/apt/lists/* | ||
fi | ||
|
||
curl -LsSf https://astral.sh/uv/0.7.21/install.sh | bash | ||
} | ||
|
||
preload_and_ulimit() { | ||
local ld_preload_file="libtcmalloc_minimal.so.4" | ||
local ld_preload_file_1="/usr/lib/$arch-linux-gnu/$ld_preload_file" | ||
local ld_preload_file_2="/usr/lib64/$ld_preload_file" | ||
if [ -e "$ld_preload_file_1" ]; then | ||
ld_preload_file="$ld_preload_file_1" | ||
elif [ -e "$ld_preload_file_2" ]; then | ||
ld_preload_file="$ld_preload_file_2" | ||
fi | ||
|
||
if [ -e "$ld_preload_file" ]; then | ||
echo "LD_PRELOAD=$ld_preload_file" >> /etc/environment | ||
fi | ||
|
||
echo 'ulimit -c 0' >> ~/.bashrc | ||
} | ||
|
||
pip_install() { | ||
local url="https://download.pytorch.org/whl/cpu" | ||
uv pip install -v -r "$1" --extra-index-url $url | ||
} | ||
|
||
git_clone_specific_commit() { | ||
local repo="${vllm_url##*/}" | ||
git init "$repo" | ||
cd "$repo" | ||
git remote add origin "$vllm_url" | ||
git fetch --depth 1 origin $commit | ||
git reset --hard $commit | ||
} | ||
|
||
main() { | ||
set -eux -o pipefail | ||
|
||
install_deps | ||
|
||
local arch | ||
arch=$(uname -m) | ||
preload_and_ulimit | ||
|
||
uv venv --python 3.12 --seed "$VIRTUAL_ENV" | ||
uv pip install --upgrade pip | ||
|
||
local vllm_url="https://github.com/vllm-project/vllm" | ||
local commit="ac9fb732a5c0b8e671f8c91be8b40148282bb14a" | ||
git_clone_specific_commit | ||
if [ "$arch" == "x86_64" ]; then | ||
export VLLM_CPU_DISABLE_AVX512="0" | ||
export VLLM_CPU_AVX512BF16="0" | ||
export VLLM_CPU_AVX512VNNI="0" | ||
elif [ "$arch" == "aarch64" ]; then | ||
export VLLM_CPU_DISABLE_AVX512="true" | ||
fi | ||
|
||
pip_install requirements/cpu-build.txt | ||
pip_install requirements/cpu.txt | ||
|
||
MAX_JOBS=2 VLLM_TARGET_DEVICE=cpu python3 setup.py install | ||
cd - | ||
rm -rf vllm /root/.cache | ||
} | ||
|
||
main "$@" | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.