Dockerfile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # 创建一个基础镜像
  2. FROM nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04
  3. RUN apt-key del 7fa2af80
  4. RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
  5. RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
  6. # 重置apt-get
  7. RUN rm -rf /etc/apt/sources.list
  8. RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
  9. RUN apt-get update
  10. RUN apt-get install -y default-jre
  11. RUN apt-get install -y cmake
  12. # 安装conda
  13. # yhyu13 : install additional packages
  14. # 设置apt的源为tsinghua镜像源
  15. RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
  16. RUN apt-get update && apt-get install -y curl wget
  17. # 安装conda
  18. RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
  19. && bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
  20. && rm Miniconda3-latest-Linux-x86_64.sh
  21. RUN /opt/conda/bin/conda init bash
  22. RUN mkdir env
  23. # 解压env中的mxnet tensorflow lemon
  24. COPY env/mxnet.tar.gz env/mxnet.tar.gz
  25. RUN mkdir /opt/conda/envs/mxnet
  26. RUN tar -zxvf env/mxnet.tar.gz -C /opt/conda/envs/mxnet
  27. COPY env/tensorflow.tar.gz env/tensorflow.tar.gz
  28. RUN mkdir /opt/conda/envs/tensorflow
  29. RUN tar -zxvf env/tensorflow.tar.gz -C /opt/conda/envs/tensorflow
  30. COPY env/lemon.tar.gz env/lemon.tar.gz
  31. RUN mkdir /opt/conda/envs/lemon
  32. RUN tar -zxvf env/lemon.tar.gz -C /opt/conda/envs/lemon
  33. RUN rm -rf env
  34. # 复制项目文件
  35. # COPY lemon_master /app/lemon_master
  36. COPY app.py /app/app.py
  37. COPY tool.py /app/tool.py
  38. # COPY config.yml /app/config.yml
  39. COPY cifar-10-batches-py.tar.gz /root/.keras/datasets/cifar-10-batches-py.tar.gz
  40. COPY mnist.npz /root/.keras/datasets/mnist.npz
  41. RUN echo "conda activate lemon" >> ~/.bashrc
  42. ENV TZ=Asia/Shanghai
  43. RUN echo "${TZ}" > /etc/timezone \
  44. && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
  45. && apt update \
  46. && apt install -y tzdata \
  47. && rm -rf /var/lib/apt/lists/*
  48. WORKDIR /app
  49. # 随便启动一个进程空转
  50. ENTRYPOINT ["/bin/bash", "-c", "source ~/.bashrc && /opt/conda/envs/lemon/bin/python app.py"]
  51. # CMD ["/bin/bash"]
  52. # CMD ["tail", "-f", "/dev/null"]