-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.gpu
68 lines (54 loc) · 2.83 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
68
FROM nvidia/cuda:10.1-cudnn7-devel
WORKDIR /usr/src/app
ENV LANG="C.UTF-8" LC_ALL="C.UTF-8" PATH="/opt/venv/bin:$PATH" PIP_NO_CACHE_DIR="false" CFLAGS="-mavx2" CXXFLAGS="-mavx2"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3 python3-pip python3-venv \
wget make g++ ffmpeg python3-dev libblas-dev liblapack-dev swig \
cmake yasm zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN python3 -m venv /opt/venv && \
python3 -m pip install pip==19.2.3 pip-tools==4.0.0
# For pytorch and torchvision we need platform specific (cpu vs. gpu) wheels from
# https://download.pytorch.org/whl/cu100/torch_stable.html
# To generate hashes run: python3 -m pip hash *.whl
RUN echo "https://download.pytorch.org/whl/cu100/torch-1.2.0-cp36-cp36m-manylinux1_x86_64.whl \
--hash=sha256:a13bf6f78a49d844b85c142b8cd62d2e1833a11ed21ea0bc6b1ac73d24c76415 \
\n \
https://download.pytorch.org/whl/cu100/torchvision-0.4.0-cp36-cp36m-manylinux1_x86_64.whl \
--hash=sha256:2f67efdf6edd9ea7f9cd9a3917ae5c63d5684e3bdb5cc9c2b364c15bdfe4456b \
\n" >> requirements.txt
RUN python3 -m piptools sync
RUN python3 -c "from torchvision.models import resnet50; resnet50(pretrained=True, progress=False)" && \
python3 -c "from torchvision.models.video import r2plus1d_18; r2plus1d_18(pretrained=True, progress=False)"
RUN wget -q https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.3.tar.gz -O libjpeg-turbo.tar.gz && \
echo "a69598bf079463b34d45ca7268462a18b6507fdaa62bb1dfd212f02041499b5d libjpeg-turbo.tar.gz" | sha256sum -c && \
tar xf libjpeg-turbo.tar.gz && \
rm libjpeg-turbo.tar.gz && \
cd libjpeg-turbo* && \
mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DREQUIRE_SIMD=On -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j $(nproc) && \
make install && \
ldconfig && \
cd ../../ && \
rm -rf libjpeg-turbo*
RUN python3 -m pip uninstall -y pillow && \
python3 -m pip install --no-binary :all: --compile pillow-simd==6.0.0.post0
RUN wget -q https://github.com/facebookresearch/faiss/archive/v1.5.3.tar.gz -O faiss.tar.gz && \
echo "b24d347b0285d01c2ed663ccc7596cd0ea95071f3dd5ebb573ccfc28f15f043b faiss.tar.gz" | sha256sum -c && \
tar xf faiss.tar.gz && \
rm faiss.tar.gz && \
cd faiss* && \
./configure --with-cuda-arch="-gencode=arch=compute_37,code=compute_37 -gencode=arch=compute_70,code=compute_70" --with-cuda="/usr/local/cuda" && \
make -j $(nproc) && \
make -j $(nproc) -C python && \
make install && \
make -C python install && \
cd .. && \
rm -rf faiss*
COPY . .
EXPOSE 5000
ENTRYPOINT ["/usr/src/app/bin/sfi"]
CMD ["-h"]