Skip to content

Commit a032f2b

Browse files
authored
fix py313 env creation failed when building lmdeploy-builder image (InternLM#3739)
1 parent eb4cefd commit a032f2b

File tree

5 files changed

+87
-68
lines changed

5 files changed

+87
-68
lines changed

builder/manywheel/Dockerfile_2014

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,37 @@ RUN yum install -y \
1212
devtoolset-${DEVTOOLSET_VERSION}-gcc \
1313
devtoolset-${DEVTOOLSET_VERSION}-gcc-c++ \
1414
devtoolset-${DEVTOOLSET_VERSION}-gcc-gfortran \
15-
devtoolset-${DEVTOOLSET_VERSION}-binutils
15+
devtoolset-${DEVTOOLSET_VERSION}-binutils \
16+
wget \
17+
rapidjson-devel \
18+
glog-devel && \
19+
yum clean all
20+
1621
ENV PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/bin:$PATH
1722
ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib64:/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib:$LD_LIBRARY_PATH
1823

19-
RUN yum install -y wget rapidjson-devel glog-devel
20-
2124
FROM base as cuda
22-
ADD manywheel/scripts/install_cuda.sh install_cuda.sh
23-
RUN bash ./install_cuda.sh ${BASE_CUDA_VERSION} && rm install_cuda.sh
25+
COPY manywheel/scripts/install_cuda.sh /tmp/install_cuda.sh
26+
RUN bash /tmp/install_cuda.sh ${BASE_CUDA_VERSION} && rm /tmp/install_cuda.sh
2427

2528
FROM base as conda
26-
ADD manywheel/scripts/install_conda.sh install_conda.sh
27-
RUN bash ./install_conda.sh && rm install_conda.sh
28-
29-
RUN /opt/conda/bin/conda create -n py39 python=3.9 -yq && \
30-
/opt/conda/envs/py39/bin/pip install pybind11 && \
31-
/opt/conda/bin/conda create -n py310 python=3.10 -yq && \
32-
/opt/conda/envs/py310/bin/pip install pybind11 && \
33-
/opt/conda/bin/conda create -n py311 python=3.11 -yq && \
34-
/opt/conda/envs/py311/bin/pip install pybind11 && \
35-
/opt/conda/bin/conda create -n py312 python=3.12 -yq && \
36-
/opt/conda/envs/py312/bin/pip install pybind11
37-
/opt/conda/bin/conda create -n py313 python=3.13 -yq && \
38-
/opt/conda/envs/py313/bin/pip install pybind11
29+
COPY manywheel/scripts/install_conda.sh /tmp/install_conda.sh
30+
RUN bash /tmp/install_conda.sh && rm /tmp/install_conda.sh
31+
32+
# Accept Anaconda's Terms of Service to avoid `CondaToSNonInteractiveError`
33+
RUN /opt/conda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
34+
/opt/conda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
35+
36+
RUN PY_VERSIONS=(3.9 3.10 3.11 3.12 3.13) && \
37+
for pyver in "${PY_VERSIONS[@]}"; do \
38+
/opt/conda/bin/conda create -n py${pyver//./} python=${pyver} -yq && \
39+
/opt/conda/envs/py${pyver//./}/bin/pip install --no-cache-dir pybind11; \
40+
done && \
41+
/opt/conda/bin/conda clean -ya
3942

4043
FROM base as cuda_final
41-
COPY --from=cuda /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda-${BASE_CUDA_VERSION}
44+
COPY --from=cuda /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda-${BASE_CUDA_VERSION}
4245
RUN ln -sf /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda
4346
ENV PATH=/usr/local/cuda/bin:$PATH
44-
COPY --from=conda /opt/conda /opt/conda
47+
COPY --from=conda /opt/conda /opt/conda
4548
RUN /opt/conda/bin/conda init bash

builder/manywheel/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
# Build lmdeploy manylinux wheel
1+
# LMDeploy Build System
22

3-
## Prepare docker image
3+
## Building lmdeploy builder images
44

5-
To build all docker images you can use the convenient script:
5+
To build all lmdeploy builder images, such as "lmdeploy-builder:cuda11.8", ""lmdeploy-builder:cuda12.4", execute:
66

77
```bash
8-
./build_all_docker.sh
9-
# Build with pushing
10-
WITH_PUSH=true ./build_all_docker.sh
8+
./build_all_lmdeploy_builders.sh
9+
10+
# Build and push images (for CI/CD)
11+
WITH_PUSH=true ./build_all_lmdeploy_builders.sh
1112
```
1213

13-
To build a docker image with specific cuda version or manylinux-docker version, you may use:
14+
For custom builds with specific versions:
1415

1516
```bash
16-
MANY_LINUX_VERSION=2014 GPU_ARCH_VERSION=12.4 ./build_docker.sh
17+
MANY_LINUX_VERSION=2014 GPU_ARCH_VERSION=12.4 ./build_lmdeploy_builder.sh
1718
```
1819

19-
## Build lmdeploy wheel
20+
## Build lmdeploy wheels
21+
22+
Compile all wheel packages:
2023

2124
```bash
2225
./build_all_wheel.sh

builder/manywheel/build_all_docker.sh renamed to builder/manywheel/build_all_lmdeploy_builders.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ set -eou pipefail
44

55
TOPDIR=$(git rev-parse --show-toplevel)/builder
66

7-
for cuda_version in 12.4; do
8-
MANY_LINUX_VERSION=2014 GPU_ARCH_VERSION="${cuda_version}" "${TOPDIR}/manywheel/build_docker.sh"
7+
for cuda_version in 11.8 12.4; do
8+
MANY_LINUX_VERSION=2014 GPU_ARCH_VERSION="${cuda_version}" "${TOPDIR}/manywheel/build_lmdeploy_builder.sh"
99
done

builder/manywheel/build_docker.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
TOPDIR=$(git rev-parse --show-toplevel)/builder
6+
GPU_ARCH_VERSION=${GPU_ARCH_VERSION}
7+
WITH_PUSH=${WITH_PUSH:-}
8+
9+
TARGET=cuda_final
10+
DOCKER_TAG=cuda${GPU_ARCH_VERSION}
11+
12+
DOCKER_IMAGE=openmmlab/lmdeploy-builder:${DOCKER_TAG}
13+
DOCKERFILE_SUFFIX=$([[ -n ${MANY_LINUX_VERSION} ]] && echo "_${MANY_LINUX_VERSION}" || echo "")
14+
15+
# List of all build arguments (format: KEY=VALUE)
16+
# Empty values will be automatically filtered out later
17+
BUILD_ARGS=(
18+
"BASE_CUDA_VERSION=${GPU_ARCH_VERSION}"
19+
"DEVTOOLSET_VERSION=9"
20+
"HTTPS_PROXY=${HTTPS_PROXY:-}"
21+
"HTTP_PROXY=${HTTP_PROXY:-}"
22+
# Add more parameters here if needed
23+
)
24+
25+
# Base Docker build command arguments
26+
docker_build_args=(
27+
-t "${DOCKER_IMAGE}"
28+
--target "${TARGET}"
29+
-f "${TOPDIR}/manywheel/Dockerfile${DOCKERFILE_SUFFIX}"
30+
)
31+
32+
# Process build arguments: filter empty values and format as --build-arg
33+
for arg in "${BUILD_ARGS[@]}"; do
34+
IFS='=' read -r key value <<< "$arg" # Split KEY=VALUE
35+
if [[ -n "$value" ]]; then # Only add non-empty values
36+
docker_build_args+=(--build-arg "$arg")
37+
fi
38+
done
39+
40+
(
41+
set -x
42+
DOCKER_BUILDKIT=1 docker build "${docker_build_args[@]}" "${TOPDIR}"
43+
)
44+
45+
if [[ "${WITH_PUSH}" == true ]]; then
46+
(
47+
set -x
48+
docker push "${DOCKER_IMAGE}"
49+
)
50+
fi

0 commit comments

Comments
 (0)