|
| 1 | +ARG BASE_ROCM_IMAGE="docker.io/mixa3607/vllm-gfx906:latest" |
| 2 | +ARG ROCM_ARCH="gfx906" |
| 3 | +ARG PYTORCH_REPO="https://github.com/pytorch/pytorch.git" |
| 4 | +ARG PYTORCH_BRANCH="v2.7.1" |
| 5 | +ARG PYTORCH_VISION_REPO="https://github.com/pytorch/vision.git" |
| 6 | +ARG PYTORCH_VISION_BRANCH="v0.21.0" |
| 7 | + |
| 8 | +############# Base image ############# |
| 9 | +FROM ${BASE_ROCM_IMAGE} AS rocm_base |
| 10 | +# Install basic utilities and Python 3.12 |
| 11 | +RUN apt-get update && apt-get install -y software-properties-common git python3-pip && \ |
| 12 | + add-apt-repository ppa:deadsnakes/ppa && \ |
| 13 | + apt-get update -y && \ |
| 14 | + apt-get install -y python3.12 python3.12-dev python3.12-venv \ |
| 15 | + python3.12-lib2to3 python-is-python3 python3.12-full && \ |
| 16 | + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \ |
| 17 | + update-alternatives --set python3 /usr/bin/python3.12 && \ |
| 18 | + ln -sf /usr/bin/python3.12-config /usr/bin/python3-config && \ |
| 19 | + python3 -m pip config set global.break-system-packages true && \ |
| 20 | + pip install amdsmi==$(cat /opt/ROCM_VERSION_FULL) && \ |
| 21 | + true |
| 22 | + |
| 23 | +# Set environment variables |
| 24 | +ARG ROCM_ARCH |
| 25 | +ENV ROCM_ARCH=$ROCM_ARCH |
| 26 | +ENV PYTORCH_ROCM_ARCH=$ROCM_ARCH |
| 27 | +ENV PATH=/opt/rocm/llvm/bin:$PATH |
| 28 | +ENV ROCM_PATH=/opt/rocm |
| 29 | +ENV LD_LIBRARY_PATH=/opt/rocm/lib:/usr/local/lib: |
| 30 | + |
| 31 | +############# Build torch + vision ############# |
| 32 | +FROM rocm_base AS build_torch |
| 33 | +RUN pip install setuptools wheel packaging cmake ninja setuptools_scm jinja2 |
| 34 | + |
| 35 | +ARG PYTORCH_REPO |
| 36 | +ARG PYTORCH_BRANCH |
| 37 | +RUN ls -la /opt/ |
| 38 | +RUN git clone --depth 1 --recurse-submodules --shallow-submodules --jobs 4 --branch ${PYTORCH_BRANCH} ${PYTORCH_REPO} pytorch |
| 39 | +RUN cd pytorch && pip install -r requirements.txt |
| 40 | +RUN cd pytorch && \ |
| 41 | + python3 tools/amd_build/build_amd.py && \ |
| 42 | + CMAKE_PREFIX_PATH=$(python3 -c 'import sys; print(sys.prefix)') python3 setup.py bdist_wheel --dist-dir=/dist && \ |
| 43 | + pip install /dist/*.whl |
| 44 | + |
| 45 | +ARG PYTORCH_VISION_REPO |
| 46 | +ARG PYTORCH_VISION_BRANCH |
| 47 | +RUN git clone --depth 1 --recurse-submodules --shallow-submodules --jobs 4 --branch ${PYTORCH_VISION_BRANCH} ${PYTORCH_VISION_REPO} vision |
| 48 | +RUN cd vision && python3 setup.py bdist_wheel --dist-dir=/dist \ |
| 49 | + && pip install /dist/*.whl |
| 50 | + |
| 51 | +############# Install all ############# |
| 52 | +FROM rocm_base AS final |
| 53 | +RUN --mount=type=bind,from=build_torch,src=/dist/,target=/dist_torch \ |
| 54 | + pip install /dist_torch/*.whl && \ |
| 55 | + true |
| 56 | + |
| 57 | +CMD ["/bin/bash"] |
0 commit comments