-
Notifications
You must be signed in to change notification settings - Fork 882
More ROCm support #3401
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
base: master
Are you sure you want to change the base?
More ROCm support #3401
Changes from all commits
c8141c3
1f041e8
d7f76f8
cd10eec
70ab027
3023f53
1a06283
1f00b02
3012668
b8876b5
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 | ||
---|---|---|---|---|
|
@@ -37,12 +37,12 @@ ARG BRANCH_NAME | |||
ARG REPO_URL=https://github.com/pytorch/serve.git | ||||
ENV PYTHONUNBUFFERED TRUE | ||||
|
||||
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ | ||||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||||
apt-get update && \ | ||||
apt-get upgrade -y && \ | ||||
apt-get install software-properties-common -y && \ | ||||
add-apt-repository -y ppa:deadsnakes/ppa && \ | ||||
apt remove python-pip python3-pip && \ | ||||
apt remove -y python-pip python3-pip && \ | ||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||||
ca-certificates \ | ||||
g++ \ | ||||
|
@@ -55,6 +55,13 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ | |||
git \ | ||||
&& rm -rf /var/lib/apt/lists/* | ||||
|
||||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
apt-get update && \ | ||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y rocm-dev amd-smi-lib \ | ||||
&& rm -rf /var/lib/apt/lists/* ; \ | ||||
fi | ||||
|
||||
# Make the virtual environment and "activating" it by adding it first to the path. | ||||
# From here on the python$PYTHON_VERSION interpreter is used and the packages | ||||
# are installed in /home/venv which is what we need for the "runtime-image" | ||||
|
@@ -67,6 +74,7 @@ RUN python -m pip install -U pip setuptools | |||
RUN export USE_CUDA=1 | ||||
|
||||
ARG USE_CUDA_VERSION="" | ||||
ARG USE_ROCM_VERSION="" | ||||
|
||||
COPY ./ serve | ||||
|
||||
|
@@ -90,6 +98,14 @@ RUN \ | |||
else \ | ||||
python ./ts_scripts/install_dependencies.py;\ | ||||
fi; \ | ||||
elif echo "${BASE_IMAGE}" | grep -q "rocm/"; then \ | ||||
# Install ROCm version specific binary when ROCm version is specified as a build arg | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
python ./ts_scripts/install_dependencies.py --rocm $USE_ROCM_VERSION;\ | ||||
# Install the binary with the latest CPU image on a ROCm base image | ||||
else \ | ||||
python ./ts_scripts/install_dependencies.py; \ | ||||
fi; \ | ||||
# Install the CPU binary | ||||
else \ | ||||
python ./ts_scripts/install_dependencies.py; \ | ||||
|
@@ -111,13 +127,14 @@ FROM ${BASE_IMAGE} AS production-image | |||
# Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top) | ||||
ARG PYTHON_VERSION | ||||
ENV PYTHONUNBUFFERED TRUE | ||||
ARG USE_ROCM_VERSION | ||||
|
||||
RUN --mount=type=cache,target=/var/cache/apt \ | ||||
apt-get update && \ | ||||
apt-get upgrade -y && \ | ||||
apt-get install software-properties-common -y && \ | ||||
add-apt-repository ppa:deadsnakes/ppa -y && \ | ||||
apt remove python-pip python3-pip && \ | ||||
apt remove -y python-pip python3-pip && \ | ||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||||
python$PYTHON_VERSION \ | ||||
python3-distutils \ | ||||
|
@@ -130,13 +147,25 @@ RUN --mount=type=cache,target=/var/cache/apt \ | |||
&& rm -rf /var/lib/apt/lists/* \ | ||||
&& cd /tmp | ||||
|
||||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
apt-get update && \ | ||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y rocm-dev amd-smi-lib \ | ||||
&& rm -rf /var/lib/apt/lists/* ; \ | ||||
fi | ||||
|
||||
RUN useradd -m model-server \ | ||||
&& mkdir -p /home/model-server/tmp | ||||
|
||||
COPY --chown=model-server --from=compile-image /home/venv /home/venv | ||||
COPY --from=compile-image /usr/local/bin/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh | ||||
ENV PATH="/home/venv/bin:$PATH" | ||||
|
||||
RUN \ | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
python -m pip install /opt/rocm/share/amd_smi; \ | ||||
fi | ||||
|
||||
RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh \ | ||||
&& chown -R model-server /home/model-server | ||||
|
||||
|
@@ -157,13 +186,14 @@ FROM ${BASE_IMAGE} AS ci-image | |||
ARG PYTHON_VERSION | ||||
ARG BRANCH_NAME | ||||
ENV PYTHONUNBUFFERED TRUE | ||||
ARG USE_ROCM_VERSION | ||||
|
||||
RUN --mount=type=cache,target=/var/cache/apt \ | ||||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||||
apt-get update && \ | ||||
apt-get upgrade -y && \ | ||||
apt-get install software-properties-common -y && \ | ||||
add-apt-repository -y ppa:deadsnakes/ppa && \ | ||||
apt remove python-pip python3-pip && \ | ||||
apt remove -y python-pip python3-pip && \ | ||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||||
python$PYTHON_VERSION \ | ||||
python3-distutils \ | ||||
|
@@ -183,13 +213,24 @@ RUN --mount=type=cache,target=/var/cache/apt \ | |||
&& rm -rf /var/lib/apt/lists/* \ | ||||
&& cd /tmp | ||||
|
||||
RUN --mount=type=cache,sharing=locked,id=apt-dev,target=/var/cache/apt \ | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
apt-get update && \ | ||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y rocm-dev amd-smi-lib \ | ||||
&& rm -rf /var/lib/apt/lists/* ; \ | ||||
fi | ||||
|
||||
COPY --from=compile-image /home/venv /home/venv | ||||
|
||||
ENV PATH="/home/venv/bin:$PATH" | ||||
|
||||
RUN python -m pip install --no-cache-dir -r https://raw.githubusercontent.com/pytorch/serve/$BRANCH_NAME/requirements/developer.txt | ||||
|
||||
RUN \ | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
python -m pip install /opt/rocm/share/amd_smi; \ | ||||
fi | ||||
|
||||
RUN mkdir /home/serve | ||||
ENV TS_RUN_IN_DOCKER True | ||||
|
||||
|
@@ -203,11 +244,12 @@ ARG PYTHON_VERSION | |||
ARG BRANCH_NAME | ||||
ARG BUILD_FROM_SRC | ||||
ARG LOCAL_CHANGES | ||||
ARG USE_ROCM_VERSION | ||||
ARG BUILD_WITH_IPEX | ||||
ARG IPEX_VERSION=1.11.0 | ||||
ARG IPEX_URL=https://software.intel.com/ipex-whl-stable | ||||
ENV PYTHONUNBUFFERED TRUE | ||||
RUN --mount=type=cache,target=/var/cache/apt \ | ||||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||||
apt-get update && \ | ||||
apt-get upgrade -y && \ | ||||
apt-get install software-properties-common -y && \ | ||||
|
@@ -243,10 +285,16 @@ RUN \ | |||
|
||||
COPY --from=compile-image /home/venv /home/venv | ||||
ENV PATH="/home/venv/bin:$PATH" | ||||
|
||||
RUN \ | ||||
if [ "$USE_ROCM_VERSION" ]; then \ | ||||
python -m pip install /opt/rocm/share/amd_smi; \ | ||||
fi | ||||
|
||||
WORKDIR "serve" | ||||
RUN python -m pip install -U pip setuptools \ | ||||
&& python -m pip install --no-cache-dir -r requirements/developer.txt \ | ||||
&& python ts_scripts/install_from_src.py \ | ||||
&& python ts_scripts/install_from_src.py --environment=dev \ | ||||
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. Whats the motivation for this change? 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. @jakki-amd - can you please explain the change here? Besides, I just found the default serve/ts_scripts/install_from_src.py Line 29 in 62c4d6a
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. Regarding motivation (did this work long time ago so apologies if I don't remember all the details), I think the motivation was that as the target of this image in the last section is to build development image and thus I think in Docker we should then have all the dependencies installed that developing requires. Therefore I added environment flag We do get part of the development dependencies from the line 296 Regarding |
||||
&& useradd -m model-server \ | ||||
&& mkdir -p /home/model-server/tmp \ | ||||
&& cp docker/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh \ | ||||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: I think it would be more consistent to follow the same naming convention as with CUDA flag naming, meaning using
rocm61
instead ofrocm6.1
as CUDA flags are also given likecu111
, notcu11.1
.Uh oh!
There was an error while loading. Please reload this page.
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 specifically checked the naming convention of both CUDA and ROCm and confirmed internally with some AMDers, then decided to use something like
rocm6.3
instead ofrocm63
.