-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[CI/Build] Dockerfile build for ARM64 / GH200 #10499
Changes from 3 commits
d2cbe42
29ed358
f2635a4
ccef455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,14 @@ ARG CUDA_VERSION=12.4.1 | |
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04 AS base | ||
ARG CUDA_VERSION=12.4.1 | ||
ARG PYTHON_VERSION=3.12 | ||
ARG TARGETPLATFORM | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Install Python and other dependencies | ||
RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \ | ||
&& echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \ | ||
&& apt-get update -y \ | ||
&& apt-get install -y ccache software-properties-common git curl sudo \ | ||
&& apt-get install -y ccache software-properties-common git curl sudo kmod \ | ||
&& add-apt-repository ppa:deadsnakes/ppa \ | ||
&& apt-get update -y \ | ||
&& apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv \ | ||
|
@@ -46,9 +47,14 @@ WORKDIR /workspace | |
# install build and runtime dependencies | ||
COPY requirements-common.txt requirements-common.txt | ||
COPY requirements-cuda.txt requirements-cuda.txt | ||
COPY requirements-cuda-arm64.txt requirements-cuda-arm64.txt | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
python3 -m pip install -r requirements-cuda.txt | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
python3 -m pip install -r requirements-cuda-arm64.txt; \ | ||
fi | ||
|
||
# cuda arch list used by torch | ||
# can be useful for both `dev` and `test` | ||
|
@@ -63,13 +69,19 @@ ENV VLLM_FA_CMAKE_GPU_ARCHES=${vllm_fa_cmake_gpu_arches} | |
|
||
#################### WHEEL BUILD IMAGE #################### | ||
FROM base AS build | ||
ARG TARGETPLATFORM | ||
|
||
# install build dependencies | ||
COPY requirements-build.txt requirements-build.txt | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
python3 -m pip install -r requirements-build.txt | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
python3 -m pip install -r requirements-cuda-arm64.txt; \ | ||
fi | ||
|
||
COPY . . | ||
ARG GIT_REPO_CHECK=0 | ||
RUN --mount=type=bind,source=.git,target=.git \ | ||
|
@@ -113,6 +125,53 @@ RUN --mount=type=cache,target=/root/.cache/ccache \ | |
python3 setup.py bdist_wheel --dist-dir=dist --py-limited-api=cp38; \ | ||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=.git,target=.git \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
apt-get update && apt-get install zlib1g-dev && \ | ||
python3 -m pip install packaging pybind11 && \ | ||
git clone https://github.com/openai/triton && \ | ||
cd triton/python && \ | ||
git submodule update --init --recursive && \ | ||
pip --verbose wheel --use-pep517 --no-deps -w /workspace/dist --no-build-isolation --no-cache-dir . ; \ | ||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=.git,target=.git \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
pip --verbose wheel --use-pep517 --no-deps -w /workspace/dist --no-build-isolation git+https://github.com/vllm-project/flash-attention.git ; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the vllm build already includes vllm-flash-attention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe torch version should be unpinned from the source in CMakeList.txx, setup.py and pyproject.toml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, good point. I'll remove that and test. |
||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=.git,target=.git \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
CAUSAL_CONV1D_FORCE_BUILD=TRUE CAUSAL_CONV1D_SKIP_CUDA_BUILD=FALSE pip --verbose wheel --use-pep517 --no-deps -w /workspace/dist --no-build-isolation --no-cache-dir git+https://github.com/Dao-AILab/causal-conv1d.git ; \ | ||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=.git,target=.git \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
MAMBA_FORCE_BUILD=TRUE pip --verbose wheel --use-pep517 --no-deps -w /workspace/dist --no-build-isolation --no-cache-dir git+https://github.com/state-spaces/mamba.git ; \ | ||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=.git,target=.git \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
apt-get update && apt-get install -y cuda-toolkit-12-4 && \ | ||
git clone -b v0.1.6 https://github.com/flashinfer-ai/flashinfer.git --recursive && \ | ||
cd flashinfer/python && \ | ||
pip --verbose wheel --use-pep517 --no-deps -w /workspace/dist --no-build-isolation --no-cache-dir . ; \ | ||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=.git,target=.git \ | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
git clone -b 0.44.1 https://github.com/bitsandbytes-foundation/bitsandbytes.git && \ | ||
cd bitsandbytes && \ | ||
pip --verbose wheel --use-pep517 --no-deps -w /workspace/dist --no-build-isolation --no-cache-dir . ; \ | ||
fi | ||
|
||
|
||
# Check the size of the wheel if RUN_WHEEL_CHECK is true | ||
COPY .buildkite/check-wheel-size.py check-wheel-size.py | ||
# Default max size of the wheel is 250MB | ||
|
@@ -124,6 +183,7 @@ RUN if [ "$RUN_WHEEL_CHECK" = "true" ]; then \ | |
else \ | ||
echo "Skipping wheel size check."; \ | ||
fi | ||
|
||
#################### EXTENSION Build IMAGE #################### | ||
|
||
#################### DEV IMAGE #################### | ||
|
@@ -143,6 +203,9 @@ ARG CUDA_VERSION=12.4.1 | |
ARG PYTHON_VERSION=3.12 | ||
WORKDIR /vllm-workspace | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ARG TARGETPLATFORM | ||
|
||
COPY requirements-cuda-arm64.txt requirements-cuda-arm64.txt | ||
|
||
RUN PYTHON_VERSION_STR=$(echo ${PYTHON_VERSION} | sed 's/\.//g') && \ | ||
echo "export PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> /etc/environment | ||
|
@@ -168,14 +231,23 @@ RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \ | |
# or future versions of triton. | ||
RUN ldconfig /usr/local/cuda-$(echo $CUDA_VERSION | cut -d. -f1,2)/compat/ | ||
|
||
# install vllm wheel first, so that torch etc will be installed | ||
# Install vllm wheel first, so that torch etc will be installed. | ||
# On Arm64 platforms, all newly compiled wheels will also be installed (flashinfer, triton, mamba, etc.) | ||
RUN --mount=type=bind,from=build,src=/workspace/dist,target=/vllm-workspace/dist \ | ||
--mount=type=cache,target=/root/.cache/pip \ | ||
python3 -m pip install dist/*.whl --verbose | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
. /etc/environment && \ | ||
python3 -m pip install https://github.com/flashinfer-ai/flashinfer/releases/download/v0.1.6/flashinfer-0.1.6+cu121torch2.4-cp${PYTHON_VERSION_STR}-cp${PYTHON_VERSION_STR}-linux_x86_64.whl | ||
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
pip uninstall -y torch && \ | ||
python3 -m pip install -r requirements-cuda-arm64.txt; \ | ||
fi | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
. /etc/environment && \ | ||
if [ "$TARGETPLATFORM" != "linux/arm64" ]; then \ | ||
python3 -m pip install https://github.com/flashinfer-ai/flashinfer/releases/download/v0.1.6/flashinfer-0.1.6+cu121torch2.4-cp${PYTHON_VERSION_STR}-cp${PYTHON_VERSION_STR}-linux_x86_64.whl; \ | ||
fi | ||
COPY examples examples | ||
#################### vLLM installation IMAGE #################### | ||
|
||
|
@@ -214,7 +286,7 @@ FROM vllm-base AS vllm-openai | |
|
||
# install additional dependencies for openai api server | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
pip install accelerate hf_transfer 'modelscope!=1.15.0' 'bitsandbytes>=0.44.0' timm==0.9.10 | ||
pip install accelerate hf_transfer 'modelscope!=1.15.0' 'bitsandbytes>=0.44.0' 'timm==0.9.10' | ||
|
||
ENV VLLM_USAGE_SOURCE production-docker-image | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--index-url https://download.pytorch.org/whl/nightly/cu124 | ||
torchvision; platform_machine == 'aarch64' | ||
torch; platform_machine == 'aarch64' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can add xformers for aarch64 to the /vllm-project directory similar to flash-attention for the aarch64 build until the upstream pip package is available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we directly use pytorch nightly as base image so that we don't need to build triton, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. Triton doesn't provide aarch64 whl files, so we'll always need to compile it if we want to use the latest version: https://pypi.org/project/triton/#files
It probably is a good idea to pin to the latest release tag of triton, instead of the main though. I'll update that.
My goal on this was to keep it as close as possible to the x86_64 implementation of VLLM, so I didn't want to use the nvidia pytorch container. That's what I was doing in the previous repo. Although it worked, it doubled the size of the final image (9.74GB vs 4.89GB).