Skip to content
Merged
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
88 changes: 0 additions & 88 deletions .cd/Dockerfile.rhel.tenc.pytorch.vllm

This file was deleted.

106 changes: 71 additions & 35 deletions .cd/Dockerfile.rhel.ubi.vllm
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
# Global build arguments - declared before first FROM to be available in all stages
ARG ARTIFACTORY_URL="vault.habana.ai"
ARG SYNAPSE_VERSION=1.23.0
# Use an exact revision (e.g. 695) or "latest" to auto-detect the newest available revision.
# If you do not want metadata to show "latest", pass an exact SYNAPSE_REVISION.
ARG SYNAPSE_REVISION=695
ARG BASE_NAME=rhel9.6
ARG OS_VERSION=9.6
ARG OS_STRING=rhel96
ARG PT_VERSION=2.9.0
ARG PT_MODULES_REPO_NAME=gaudi-pt-modules
# for internal use - to support a different package name for RHEL 9.4 with Python 3.12
ARG PT_PACKAGE_NAME_NON_DEFAULT_PYTHON_SUBSTRING=
ARG PYPI_INDEX_URL="https://pypi.org/simple/"
ARG HABANA_RPM_REPO_PATH="rhel/9/${OS_VERSION}"
# can be upstream or fork
ARG TORCH_TYPE=upstream
ARG VLLM_GAUDI_COMMIT=v0.15.1
Expand All @@ -15,24 +24,29 @@ ARG VLLM_PROJECT_COMMIT=v0.15.1
# ============================================================================
# Stage 1: gaudi-base - Base system setup with Habana drivers
# ============================================================================
FROM registry.access.redhat.com/ubi9/ubi:9.6 AS gaudi-base
FROM registry.access.redhat.com/ubi9/ubi:${OS_VERSION} AS gaudi-base

# Re-declare global ARGs to use them in this stage
ARG ARTIFACTORY_URL
ARG SYNAPSE_VERSION
ARG SYNAPSE_REVISION
ARG BASE_NAME
ARG OS_VERSION
ARG OS_STRING
ARG PT_VERSION
ARG PYPI_INDEX_URL
ARG HABANA_RPM_REPO_PATH
ARG TORCH_TYPE

# Labels for RHEL certification
# Labels for RHEL certification.
# Note: when SYNAPSE_REVISION=latest, this metadata intentionally records "latest"
# (the requested input), not the detected numeric revision.
LABEL vendor="Habanalabs Ltd." \
release="${SYNAPSE_VERSION}-${SYNAPSE_REVISION}"

# Environment variables - Habana-specific paths and configurations
ENV TORCH_TYPE=${TORCH_TYPE} \
PT_VERSION=${PT_VERSION} \
OS_STRING="rhel96" \
OS_STRING="${OS_STRING}" \
VLLM_TARGET_DEVICE="hpu" \
GC_KERNEL_PATH=/usr/lib/habanalabs/libtpc_kernels.so \
HABANA_LOGS=/var/log/habana_logs/ \
Expand All @@ -43,10 +57,12 @@ ENV TORCH_TYPE=${TORCH_TYPE} \
COPY LICENSE /licenses/

# System setup - Remove FIPS provider and add EPEL
RUN dnf install -y python3-dnf-plugin-versionlock && \
RUN dnf install -y --allowerasing python3-dnf-plugin-versionlock && \
dnf versionlock add redhat-release* && \
rpm -e --nodeps openssl-fips-provider-so && \
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf -y update && \
# '|| true' is added to support RHEL 9.4 in which openssl-fips-provider-so is not installed
rpm -e --nodeps openssl-fips-provider-so || true && \
dnf install -y --allowerasing https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
dnf clean all

# Add CentOS repositories for additional packages
Expand All @@ -55,10 +71,12 @@ RUN printf "[BaseOS]\\nname=CentOS Linux 9 - BaseOS\\nbaseurl=https://mirror.str
printf "[CRB]\\nname=CentOS Linux 9 - CRB\\nbaseurl=https://mirror.stream.centos.org/9-stream/CRB/x86_64/os\\ngpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256\\ngpgcheck=1\\n" > /etc/yum.repos.d/CentOS-Linux-CRB.repo

# Install system dependencies
RUN dnf install -y \
wget git jq \
RUN dnf install -y --allowerasing \
wget git jq libomp \
# Image processing dependencies (needed for pillow-simd -> habana-media-loader)
zlib-devel libjpeg-devel \
zlib-devel libjpeg-turbo-devel \
# habanalabs-thunk dependency
libfdt-devel \
# Python development
python3-devel python3.12 python3.12-devel python3.12-pip \
# NUMA support
Expand All @@ -72,11 +90,11 @@ RUN alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 && \
ln -s /usr/bin/python3 /usr/bin/python

# Install base Python packages
RUN pip install setuptools==79.0.1 wheel setuptools_scm && \
pip install --upgrade Jinja2 protobuf urllib3 requests
RUN pip install --no-cache-dir setuptools==79.0.1 wheel setuptools_scm && \
pip install --no-cache-dir --upgrade Jinja2 protobuf urllib3 requests

# Setup Habana repository and install Habana packages
RUN printf "[habanalabs]\\nname=Habana RH9 Linux repo\\nbaseurl=https://${ARTIFACTORY_URL}/artifactory/rhel/9/9.6\\ngpgkey=https://${ARTIFACTORY_URL}/artifactory/rhel/9/9.6/repodata/repomd.xml.key\\ngpgcheck=1\\n" > /etc/yum.repos.d/habanalabs.repo && \
RUN printf "[habanalabs]\\nname=Habana RH9 Linux repo\\nbaseurl=https://${ARTIFACTORY_URL}/artifactory/${HABANA_RPM_REPO_PATH}\\ngpgkey=https://${ARTIFACTORY_URL}/artifactory/${HABANA_RPM_REPO_PATH}/repodata/repomd.xml.key\\ngpgcheck=1\\n" > /etc/yum.repos.d/habanalabs.repo && \
echo "=== Content of habanalabs.repo ===" && \
cat /etc/yum.repos.d/habanalabs.repo && \
echo "=== End of habanalabs.repo ===" && \
Expand All @@ -85,17 +103,30 @@ RUN printf "[habanalabs]\\nname=Habana RH9 Linux repo\\nbaseurl=https://${ARTIFA
rpm --import "${_GPG_TEMP}/habana_pubkey" && \
rm -rf "${_GPG_TEMP}" && \
dnf makecache && \
if [ "${SYNAPSE_REVISION}" = "latest" ]; then \
dnf install -y \
habanalabs-rdma-core-"$SYNAPSE_VERSION"* \
habanalabs-thunk-"$SYNAPSE_VERSION"* \
habanalabs-firmware-tools-"$SYNAPSE_VERSION"* \
habanalabs-graph-"$SYNAPSE_VERSION"*; \
else \
dnf install -y \
habanalabs-rdma-core-"$SYNAPSE_VERSION"-"$SYNAPSE_REVISION"* \
habanalabs-thunk-"$SYNAPSE_VERSION"-"$SYNAPSE_REVISION"* \
habanalabs-firmware-tools-"$SYNAPSE_VERSION"-"$SYNAPSE_REVISION"* \
habanalabs-graph-"$SYNAPSE_VERSION"-"$SYNAPSE_REVISION"* && \
habanalabs-graph-"$SYNAPSE_VERSION"-"$SYNAPSE_REVISION"*; \
fi && \
DETECTED_SYNAPSE_REVISION=$(rpm -q --qf '%{RELEASE}\n' habanalabs-rdma-core | head -n1 | sed 's/\..*$//') && \
mkdir -p /etc/habanalabs && \
echo "${DETECTED_SYNAPSE_REVISION}" > /etc/habanalabs/synapse_revision && \
echo "Detected Synapse revision: ${DETECTED_SYNAPSE_REVISION}" && \
dnf clean all && \
chmod +t /var/log/habana_logs && \
rm -f /etc/yum.repos.d/habanalabs.repo

# Install Habana media loader and configure Python path
RUN pip install habana-media-loader=="${SYNAPSE_VERSION}"."${SYNAPSE_REVISION}" && \
RUN SYNAPSE_REVISION_RUNTIME=$(cat /etc/habanalabs/synapse_revision) && \
pip install --no-cache-dir habana-media-loader=="${SYNAPSE_VERSION}"."${SYNAPSE_REVISION_RUNTIME}" --extra-index-url ${PYPI_INDEX_URL} && \
echo "/usr/lib/habanalabs" > $(python3 -c "import sysconfig; print(sysconfig.get_path('platlib'))")/habanalabs-graph.pth

# ============================================================================
Expand All @@ -105,36 +136,38 @@ FROM gaudi-base AS gaudi-pytorch

# Re-declare global ARGs needed in this stage
ARG ARTIFACTORY_URL
ARG OS_STRING
ARG PT_VERSION
ARG PT_MODULES_REPO_NAME
ARG PT_PACKAGE_NAME_NON_DEFAULT_PYTHON_SUBSTRING
ARG PYPI_INDEX_URL
ARG SYNAPSE_VERSION
ARG SYNAPSE_REVISION
ARG TORCH_TYPE

# Environment variables inherited from base, OS_STRING needed for PyTorch install
ENV OS_STRING="rhel96"
ENV OS_STRING="${OS_STRING}"

# Use installer script from Habana to install Pytorch
RUN PT_PACKAGE_NAME="pytorch_modules-v${PT_VERSION}_${SYNAPSE_VERSION}_${SYNAPSE_REVISION}.tgz" && \
PT_ARTIFACT_PATH="https://${ARTIFACTORY_URL}/artifactory/gaudi-pt-modules/${SYNAPSE_VERSION}/${SYNAPSE_REVISION}/pytorch/${OS_STRING}" && \
RUN SYNAPSE_REVISION_RUNTIME=$(cat /etc/habanalabs/synapse_revision) && \
PT_PACKAGE_NAME="pytorch_modules${PT_PACKAGE_NAME_NON_DEFAULT_PYTHON_SUBSTRING}-v${PT_VERSION}_${SYNAPSE_VERSION}_${SYNAPSE_REVISION_RUNTIME}.tgz" && \
PT_ARTIFACT_PATH="https://${ARTIFACTORY_URL}/artifactory/${PT_MODULES_REPO_NAME}/${SYNAPSE_VERSION}/${SYNAPSE_REVISION_RUNTIME}/pytorch/${OS_STRING}" && \
TMP_PATH=$(mktemp --directory) && \
wget --no-verbose "${PT_ARTIFACT_PATH}/${PT_PACKAGE_NAME}" && \
tar -zxf "${PT_PACKAGE_NAME}" -C "${TMP_PATH}" && \
cd "${TMP_PATH}" && \
export SKIP_INSTALL_DEPENDENCIES=1 && \
./install.sh $SYNAPSE_VERSION $SYNAPSE_REVISION $TORCH_TYPE && \
PYTHON_INDEX_URL="--extra-index-url ${PYPI_INDEX_URL}" ./install.sh $SYNAPSE_VERSION $SYNAPSE_REVISION_RUNTIME $TORCH_TYPE && \
cd / && \
rm -rf "${TMP_PATH}" "${PT_PACKAGE_NAME}"

# System update
RUN dnf -y update --nobest --allowerasing --skip-broken && \
rm -rf "${TMP_PATH}" "${PT_PACKAGE_NAME}" && \
dnf clean all

WORKDIR /workspace

# ============================================================================
# Stage 3: vllm-final - Install vLLM and configure runtime
# ============================================================================
FROM gaudi-pytorch
FROM gaudi-pytorch AS vllm-openai

# Re-declare global ARGs needed in this stage
ARG VLLM_GAUDI_COMMIT
Expand All @@ -148,10 +181,9 @@ ENV BASE_NAME=${BASE_NAME} \
VLLM_PATH2=/workspace/vllm-gaudi

# Install additional system dependencies
RUN dnf update -y --nobest && \
dnf install -y gettext jq git --allowerasing && \
ln -sf /usr/bin/python3 /usr/bin/python && \
dnf clean all
RUN dnf install -y gettext jq git --allowerasing && \
dnf clean all && \
ln -sf /usr/bin/python3 /usr/bin/python

WORKDIR /root

Expand All @@ -173,11 +205,12 @@ RUN set -e && \
git remote add upstream https://github.com/vllm-project/vllm.git && \
git fetch upstream --tags && \
git checkout ${VLLM_PROJECT_COMMIT} && \
python use_existing_torch.py && \
VLLM_TARGET_DEVICE=empty pip install --no-build-isolation . && \
pip install --no-cache-dir -r <(sed '/^torch/d' requirements/build.txt) && \
VLLM_TARGET_DEVICE=empty pip install --no-cache-dir --no-build-isolation . && \
cd $VLLM_PATH2 && \
git checkout ${VLLM_GAUDI_COMMIT} && \
VLLM_TARGET_DEVICE=hpu pip install -v . --no-build-isolation
VLLM_TARGET_DEVICE=hpu pip install --no-cache-dir -v . --no-build-isolation && \
pip check

# The scripts below are used for benchmarks testing and autocalc:
# RUN pip3 install -v -e $VLLM_PATH/tests/vllm_test_utils
Expand All @@ -186,11 +219,13 @@ RUN set -e && \
#
## Copy utility scripts and configuration
#RUN mkdir -p /root/scripts/
#COPY templates /root/scripts/templates/
#COPY entrypoints /root/scripts/entrypoints/
#COPY server /root/scripts/server/
#COPY benchmark /root/scripts/benchmark/
#COPY .cd/templates /root/scripts/templates/
#COPY .cd/entrypoints /root/scripts/entrypoints/
#COPY .cd/server /root/scripts/server/
#COPY .cd/benchmark /root/scripts/benchmark/
#WORKDIR /root/scripts
# Set testing entrypoint script
#ENTRYPOINT ["python3", "-m", "entrypoints.entrypoint_main"]

# Setup non-root user for OpenShift compatibility
RUN umask 002 && \
Expand All @@ -203,3 +238,4 @@ COPY LICENSE /licenses/vllm.md

USER 2000
ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]

Loading
Loading