Skip to content

Commit c62a442

Browse files
authored
refactor ascend Dockerfile (#3926)
* refactor ascend Dockerfile * simplify Dockerfile * update code * update code * update code * update code
1 parent 3a0d0f8 commit c62a442

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

docker/Dockerfile.ascend

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
ARG CANN_TAG=8.2.rc1-a3-ubuntu22.04-py3.11
1+
# Run the following command in the root directory of lmdeploy to build the image:
2+
# DOCKER_BUILDKIT=1 docker build --network=host -t lmdeploy_dlinfer:a2 -f docker/Dockerfile.ascend .
3+
ARG ASCEND_DEVICE=ascend_a2
4+
ARG ASCEND_HUB=swr.cn-south-1.myhuaweicloud.com/ascendhub
25

3-
FROM ascendai/cann:${CANN_TAG} AS builder
4-
ARG PYTHON_VERSION=3.10
6+
FROM ${ASCEND_HUB}/cann:8.1.rc1-910b-ubuntu22.04-py3.10 AS ascend_a2_base
57

6-
RUN --mount=type=cache,target=/root/.cache \
7-
pip install -v uv && \
8-
uv venv -v -p python${PYTHON_VERSION} --seed /opt/py3
8+
FROM ${ASCEND_HUB}/cann:8.1.rc1-310p-ubuntu22.04-py3.10 AS ascend_300i_base
99

10-
ENV PATH=/opt/py3/bin:$PATH
10+
FROM ${ASCEND_DEVICE}_base AS builder
1111
ENV LMDEPLOY_TARGET_DEVICE=ascend
12-
13-
COPY . /opt/lmdeploy
1412
WORKDIR /opt/lmdeploy
15-
13+
COPY . .
1614
RUN --mount=type=cache,target=/root/.cache \
17-
pip install --upgrade pip build && \
15+
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
16+
pip config set global.trusted-host mirrors.aliyun.com && \
17+
pip install --no-cache-dir -U pip build && \
1818
python -m build -w -o /wheels -v .
1919

20-
FROM ascendai/cann:${CANN_TAG} AS final
21-
COPY --from=builder /root/.local /root/.local
22-
COPY --from=builder /opt/py3 /opt/py3
23-
ENV PATH=/opt/py3/bin:$PATH
20+
FROM ${ASCEND_DEVICE}_base AS final
2421

2522
RUN --mount=type=cache,target=/root/.cache \
26-
--mount=type=cache,target=/wheels,from=builder,source=/wheels \
27-
pip install /wheels/*.whl
23+
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
24+
pip config set global.trusted-host mirrors.aliyun.com && \
25+
pip install --no-cache-dir torch==2.3.1 torch-npu==2.3.1 torchvision==0.18.1
26+
27+
RUN --mount=type=cache,target=/wheels,from=builder,source=/wheels \
28+
pip install --no-cache-dir /wheels/*.whl

0 commit comments

Comments
 (0)