Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docker/build_cpu_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Current directory should be the root of the repository

# You may need to pass
# - VLLM_VERSION
# - MACA_VERSION
# to build a specific version

RHSM_SECRET_FILE=${RHSM_SECRET_FILE:-rhsm.env}
if [ ! -f "$RHSM_SECRET_FILE" ] && [ -f docker/rhsm.env ]; then
RHSM_SECRET_FILE=docker/rhsm.env
fi

Comment thread
ILikeIneine marked this conversation as resolved.
DOCKER_BUILDKIT=1 docker build \
--network host \
Comment thread
ILikeIneine marked this conversation as resolved.
--secret id=rhsm,src=${RHSM_SECRET_FILE} \
-f docker/vllm-cpu.Dockerfile \
-t vllm_cpu:new_base_img \
--build-arg VLLM_VERSION=v0.18.0 \
Comment thread
ILikeIneine marked this conversation as resolved.
Comment thread
ILikeIneine marked this conversation as resolved.
.

# debug dockerfile and run into shell with buildx:
# ddocker () {
# BUILDX_EXPERIMENTAL=1 docker buildx debug --invoke /bin/bash --on=error $@
# }

2 changes: 2 additions & 0 deletions docker/rhsm.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RHSM_USER=''
RHSM_PASS=''
140 changes: 140 additions & 0 deletions docker/vllm-cpu.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
ARG BUILD_BASE_IMAGE=registry.redhat.io/rhai/base-image-cpu-rhel9:3.4.0-1777399554
ARG PYTHON_VERSION=3.12
# ARG UV_EXTRA_INDEX_URL=https://console.redhat.com/api/pypi/public-rhai/rhoai/3.4/cpu-ubi9/simple
ARG UV_INDEX_URL=https://console.redhat.com/api/pypi/public-rhai/rhoai/3.4/cpu-ubi9/simple
# may need passing a particular vllm version during build
ARG VLLM_VERSION

ARG RHSM_USER
ARG RHSM_PASS

#################### BASE IMAGE ####################
FROM ${BUILD_BASE_IMAGE} AS base


# # TODO: we most likely do not need all of the dnf installs below: they're already in the base image
# RUN --mount=type=secret,id=rhsm \
# --mount=type=cache,target=/var/cache/dnf,sharing=locked \
# bash -euo pipefail -c '\
# source /run/secrets/rhsm; \
# cleanup() { \
# subscription-manager unregister >/dev/null 2>&1 || true; \
# subscription-manager clean >/dev/null 2>&1 || true; \
# }; \
# trap cleanup EXIT; \
# subscription-manager register \
# --username "$RHSM_USER" \
# --password "$RHSM_PASS" \
# --auto-attach; \
# subscription-manager repos \
# --enable codeready-builder-for-rhel-9-x86_64-rpms; \
# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm; \
# /usr/bin/crb enable; \
# yum makecache; \
# yum install -y --setopt=install_weak_deps=False \
# python3 \
# python3-devel \
# zeromq \
# bzip2 \
# cpio \
# elfutils-debuginfod-client \
# ffmpeg-free \
# fftw \
# file \
# freetype \
# gcc \
# gcc-c++ \
# gdal-libs \
# gdb \
# geos \
# git-core \
# glibc-langpack-en \
# glog \
# gmp \
# gzip \
# hdf5 \
# jemalloc \
# jq \
# krb5-libs \
# lcms2 \
# libaio \
# libev \
# libjpeg \
# libmpc \
# libomp \
# libpng \
# libpq \
# libqhull_r \
# libsndfile \
# libtiff \
# libunwind \
# libva \
# libwebp \
# libxml2 \
# libxslt \
# libzip \
# libzstd \
# loguru \
# lz4 \
# make \
# mariadb-connector-c \
# mpfr \
# netcdf \
# numactl \
# nvtop \
# openblas openblas-openmp openblas-openmp64 openblas-serial openblas-serial64 openblas-threads openblas-threads64 \
# openjpeg2 \
# openmpi \
# proj \
# protobuf \
# qpdf \
# re2 \
# snappy \
# spatialindex \
# tbb \
# tesseract \
# thrift \
# unixODBC \
# utf8proc \
# wget \
# xz \
# xz-libs \
# zlib \
# zstd; \
# yum clean all'

WORKDIR /workspace

RUN curl -LsSf https://astral.sh/uv/install.sh | sh
Comment thread
ILikeIneine marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv should be already available in the rhai base image, so we should also be able to remove this step


ENV CC=/usr/bin/gcc CXX=/usr/bin/g++

ENV PATH="/root/.local/bin:$PATH"
ENV VIRTUAL_ENV="/opt/app-root/"
ENV UV_PYTHON_INSTALL_DIR=/opt/app-root/python
ARG PYTHON_VERSION
# RUN uv venv ${VIRTUAL_ENV} --python ${PYTHON_VERSION} --seed
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

ENV UV_HTTP_TIMEOUT=500

ENV LD_PRELOAD="/opt/app-root/lib/libiomp5.so"

RUN echo 'ulimit -c 0' >> ~/.bashrc

###################### BUILD IMAGE ####################
FROM base AS vllm-cpu-build


# Install Python dependencies
ARG UV_EXTRA_INDEX_URL
ARG UV_INDEX_URL
ENV UV_EXTRA_INDEX_URL=${UV_EXTRA_INDEX_URL}
ENV UV_INDEX_URL=${UV_INDEX_URL}
ENV UV_INDEX_STRATEGY="unsafe-best-match"
ENV UV_LINK_MODE="copy"

ENV VLLM_LOGGING_LEVEL=DEBUG

ARG VLLM_VERSION
RUN uv pip install --torch-backend=cpu vllm==${VLLM_VERSION}
Comment thread
ILikeIneine marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN uv pip install --torch-backend=cpu vllm==${VLLM_VERSION}
RUN uv pip install vllm==${VLLM_VERSION}

shouldn't need to set the torch backend when using the rhai index

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix!

Loading
Loading