-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.gpu
67 lines (49 loc) · 1.67 KB
/
Dockerfile.gpu
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
###########
# BUILDER #
###########
# pull official base image
FROM nvidia/cuda:11.8.0-base-ubuntu22.04 as builder
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Asia/Seoul
# set work directory
WORKDIR /usr/src/app
# Install necessary system dependencies
RUN apt-get update -y && apt-get install -y build-essential libglib2.0-0 libgl1-mesa-glx ffmpeg libsm6 libxext6
RUN apt-get install -y nvidia-driver-530
# Install Python
RUN apt-get install -y python3.10 python3-pip
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
COPY ./requirements-gpu.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements-gpu.txt
#########
# FINAL #
#########
# pull official base image
FROM nvidia/cuda:11.8.0-base-ubuntu22.04
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Asia/Seoul
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# create necessary directories
RUN mkdir -p /home/app
RUN adduser --system --group app
ENV HOME=/home/app
ENV APP_HOME=/home/app/ai
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# Install necessary system dependencies
RUN apt-get update -y && apt-get install -y build-essential libglib2.0-0 libgl1-mesa-glx ffmpeg libsm6 libxext6
RUN apt-get install -y nvidia-driver-530
# Install Python
RUN apt-get install -y python3.10 python3-pip
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements-gpu.txt .
RUN pip install --upgrade pip
RUN pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118
RUN pip install --no-cache /wheels/*
# Copy the application code
COPY . $APP_HOME
RUN chown -R app:app $APP_HOME
USER app