-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile_CUDA
58 lines (42 loc) · 1.69 KB
/
Dockerfile_CUDA
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
# first build step: build frontend
FROM node:12-alpine as builder
WORKDIR /
COPY ./sentiment-frontend/ .
RUN npm install && npm run build
# second build step: copy frontend and build backend
# special base image for CUDA use: version has to match NVIDIA drivers of machine!
FROM nvidia/cuda:10.0-base
WORKDIR /
COPY sentiment-backend/sentiment /sentiment
COPY sentiment-backend/requirements-cuda.txt /requirements.txt
COPY sentiment-backend/requirements-base.txt /requirements-base.txt
RUN mkdir /sentiment/static
COPY --from=builder /dist/ /sentiment/static/
# CUDA image does not come with Python3: manual installation of Python3.8
RUN apt-get update
RUN apt-get install -y --no-install-recommends git locales python3.8 python3-pip
RUN : DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
software-properties-common \
&& add-apt-repository -y ppa:deadsnakes \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3.8-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& :
RUN python3.8 -m venv /venv
ENV PATH=/venv/bin:$PATH
# set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# load libraries
RUN pip3 install --upgrade pip
# torch version has to be compatible with CUDA version: here CUDA10.0 + torch1.4.0
RUN pip3 install -r /requirements.txt \
&& rm -rf /root/.cache/pip3
# load model into image
COPY sentiment-backend/trigger_download.py /trigger_download.py
RUN python trigger_download.py
# start server of sentiment service listening on (container-) port 8000
CMD ["uvicorn", "sentiment.main:app", "--host", "0.0.0.0", "--port", "8000"]