Skip to content

Commit

Permalink
add cache to speed up docker building (#2344)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunningLeon authored Aug 20, 2024
1 parent 0a1f65a commit f21b5a4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ RUN apt-get update -y && apt-get install -y software-properties-common wget vim

ENV PATH=/opt/py3/bin:$PATH

RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools==69.5.1 &&\
python3 -m pip install --no-cache-dir torch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION} --index-url https://download.pytorch.org/whl/${CUDA_VERSION_SHORT} &&\
python3 -m pip install --no-cache-dir cmake packaging wheel

# install openmpi
RUN wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.5.tar.gz &&\
tar xf openmpi-4.1.5.tar.gz && cd openmpi-4.1.5 && ./configure --prefix=/usr/local/openmpi &&\
Expand All @@ -33,22 +29,25 @@ RUN wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.5.tar.g
ENV PATH=$PATH:/usr/local/openmpi/bin
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openmpi/lib

RUN --mount=type=cache,target=/root/.cache/pip python3 -m pip install --upgrade pip setuptools==69.5.1 &&\
python3 -m pip install torch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION} --index-url https://download.pytorch.org/whl/${CUDA_VERSION_SHORT} &&\
python3 -m pip install cmake packaging wheel

ENV NCCL_LAUNCH_MODE=GROUP

# Should be in the lmdeploy root directory when building docker image
COPY . /opt/lmdeploy

WORKDIR /opt/lmdeploy

RUN cd /opt/lmdeploy &&\
python3 -m pip install --no-cache-dir -r requirements.txt &&\
RUN --mount=type=cache,target=/root/.cache/pip cd /opt/lmdeploy &&\
python3 -m pip install -r requirements.txt &&\
mkdir -p build && cd build &&\
sh ../generate.sh &&\
ninja -j$(nproc) && ninja install &&\
cd .. &&\
python3 -m pip install -e . &&\
rm -rf build &&\
rm -rf ~/.cache/*
rm -rf build

ENV LD_LIBRARY_PATH=/opt/lmdeploy/install/lib:$LD_LIBRARY_PATH
ENV PATH=/opt/lmdeploy/install/bin:$PATH
Expand Down

0 comments on commit f21b5a4

Please sign in to comment.