Dockerfile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ARG PYTORCH="1.9.0"
  2. ARG CUDA="11.1"
  3. ARG CUDNN="8"
  4. FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
  5. ARG MMCV="2.0.0rc4"
  6. ARG MMDET="3.0.0"
  7. ENV PYTHONUNBUFFERED TRUE
  8. # Avoid Public GPG key error
  9. # https://github.com/NVIDIA/nvidia-docker/issues/1631
  10. RUN rm /etc/apt/sources.list.d/cuda.list \
  11. && rm /etc/apt/sources.list.d/nvidia-ml.list \
  12. && apt-key del 7fa2af80 \
  13. && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub \
  14. && apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
  15. # (Optional, use Mirror to speed up downloads)
  16. # RUN sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu\//http:\/\/mirrors.aliyun.com\/ubuntu\//g' /etc/apt/sources.list
  17. # Install the required packages
  18. RUN apt-get update && \
  19. DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
  20. ca-certificates \
  21. g++ \
  22. openjdk-11-jre-headless \
  23. # MMDet Requirements
  24. ffmpeg libsm6 libxext6 git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \
  25. && rm -rf /var/lib/apt/lists/*
  26. ENV PATH="/opt/conda/bin:$PATH" \
  27. FORCE_CUDA="1"
  28. # TORCHSEVER
  29. RUN pip install torchserve torch-model-archiver
  30. # MMLAB
  31. ARG PYTORCH
  32. ARG CUDA
  33. RUN pip install mmengine
  34. RUN ["/bin/bash", "-c", "pip install mmcv==${MMCV} -f https://download.openmmlab.com/mmcv/dist/cu${CUDA//./}/torch${PYTORCH}/index.html"]
  35. RUN pip install mmdet==${MMDET}
  36. RUN useradd -m model-server \
  37. && mkdir -p /home/model-server/tmp
  38. COPY entrypoint.sh /usr/local/bin/entrypoint.sh
  39. RUN chmod +x /usr/local/bin/entrypoint.sh \
  40. && chown -R model-server /home/model-server
  41. COPY config.properties /home/model-server/config.properties
  42. RUN mkdir /home/model-server/model-store && chown -R model-server /home/model-server/model-store
  43. EXPOSE 8080 8081 8082
  44. USER model-server
  45. WORKDIR /home/model-server
  46. ENV TEMP=/home/model-server/tmp
  47. ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
  48. CMD ["serve"]