forked from IGNF/myria3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
114 lines (90 loc) · 4.27 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#####################################################
# Build
#####################################################
FROM nvidia/cuda:10.2-devel-ubuntu18.04 AS build
# An nvidia image seems to be necessary for torch-points-kernel.
# Also, a "devel" image seems required for the same library
# set the IGN proxy, otherwise apt-get and other applications don't work
# Should be commented out outside of IGN
ENV http_proxy 'http://192.168.4.9:3128/'
ENV https_proxy 'http://192.168.4.9:3128/'
# set the timezone, otherwise it asks for it... and freezes
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Needed to use apt-get afterwards due to CUDA changes described here since April 27, 2022:
# https://forums.developer.nvidia.com/t/notice-cuda-linux-repository-key-rotation/212772
# Not the recommpended method, but else we need wget installed afterwards.
# We changed to 10.2-devel-ubuntu18.04 so that might not be needed.
RUN apt-get update && apt-get install -y wget && apt-get clean -y
RUN apt-key del 7fa2af80
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
# all the apt-get installs
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
software-properties-common \
wget \
git \
libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 \
&& apt-get clean -y
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \
&& /bin/bash ~/miniconda.sh -b -p /opt/conda \
&& rm ~/miniconda.sh
ENV PATH /opt/conda/bin:$PATH
# Only copy necessary files to set up the environment,
# to use docker caching if requirements files were not updated.
WORKDIR /setup_env
COPY ./setup_env/ .
# install mamba to setup the env faster
RUN conda install -y mamba -n base -c conda-forge
# Build the environment
RUN mamba env create -f requirements.yml
# On installe conda-pack
RUN mamba install -c conda-forge conda-pack
# On utilise conda-pack pour créer un environement "standalone" dans /venv
RUN conda-pack -n myria3d -o /tmp/env.tar && \
mkdir /venv && cd /venv && tar xf /tmp/env.tar && \
rm /tmp/env.tar
# Cleanup prefixes from in the active environment
RUN /venv/bin/conda-unpack
#####################################################
# Runtime
#####################################################
# FROM nvidia/cuda:10.2-devel-ubuntu18.04 AS runtime
FROM nvidia/cuda:10.2-runtime-ubuntu18.04 AS runtime
# set the IGN proxy, otherwise apt-get and other applications don't work
# Should be commented out outside of IGN
ENV http_proxy 'http://192.168.4.9:3128/'
ENV https_proxy 'http://192.168.4.9:3128/'
# set the timezone, otherwise it asks for it... and freezes
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# all the apt-get installs
RUN apt-get update -y && apt-get install -y \
software-properties-common \
libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
# Copy Python env
COPY --from=build /venv /venv
# Copy the repository content in /myria3d
WORKDIR /myria3d
COPY . .
# Make RUN commands use the new environment:
SHELL ["/bin/bash", "-c"]
# the entrypoint garanty that all command will be runned in the conda environment
COPY entrypoint.sh /usr/local/bin/
RUN chmod u+x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
# Example usage
CMD ["python", \
"-m", \
"myria3d.predict", \
"--config-path", \
"/CICD_github_assets/parametres_etape1/.hydra", \
"--config-name", \
"predict_config_V1.6.3.yaml", \
"predict.src_las=/CICD_github_assets/parametres_etape1/test/792000_6272000_subset_buildings.las", \
"predict.output_dir=/CICD_github_assets/output_etape1", \
"predict.ckpt_path=/CICD_github_assets/parametres_etape1/checkpoints/epoch_033.ckpt", \
"predict.gpus=0", \
"datamodule.batch_size=10", \
"datamodule.subtile_overlap=0", \
"hydra.run.dir=/myria3d"]