提交 ff867ec3 编写于 作者: E Enric Moreu 提交者: Adam Geitgey

Dockerfile.gpu alongside CPU based Dockerfile

上级 63c59779
# This is a sample Dockerfile you can modify to deploy your own app based on face_recognition
# In order to run Docker in the GPU you will need to install nvidia-docker: https://github.com/NVIDIA/nvidia-docker
FROM nvidia/cuda:9.0-cudnn7-devel
# Install face recognition dependencies
RUN apt update -y; apt install -y \
git \
cmake \
libsm6 \
libxext6 \
libxrender-dev \
python3 \
python3-pip
RUN pip3 install scikit-build
# Install compilers
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt update -y; apt install -y gcc-6 g++-6
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50
#Install dlib
RUN git clone https://github.com/davisking/dlib.git
RUN mkdir -p /dlib/build
RUN cmake -H/dlib -B/dlib/build -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
RUN cmake --build /dlib/build
RUN cd /dlib; python3 /dlib/setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
# Install the face recognition package
RUN pip3 install face_recognition
FROM python:3.6-slim-stretch
RUN apt-get -y update
RUN apt-get install -y --fix-missing \
build-essential \
cmake \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-dev \
libavcodec-dev \
libavformat-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
software-properties-common \
zip \
&& apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN cd ~ && \
mkdir -p dlib && \
git clone -b 'v19.9' --single-branch https://github.com/davisking/dlib.git dlib/ && \
cd dlib/ && \
python3 setup.py install --yes USE_AVX_INSTRUCTIONS
# The rest of this file just runs an example script.
# If you wanted to use this Dockerfile to run your own app instead, maybe you would do this:
# COPY . /root/your_app_or_whatever
# RUN cd /root/your_app_or_whatever && \
# pip3 install -r requirements.txt
# RUN whatever_command_you_run_to_start_your_app
COPY . /root/face_recognition
RUN cd /root/face_recognition && \
pip3 install -r requirements.txt && \
python3 setup.py install
CMD cd /root/face_recognition/examples && \
python3 recognize_faces_in_pictures.py
\ No newline at end of file
# This is a sample Dockerfile you can modify to deploy your own app based on face_recognition on the GPU
# In order to run Docker in the GPU you will need to install Nvidia-Docker: https://github.com/NVIDIA/nvidia-docker
FROM nvidia/cuda:9.0-cudnn7-devel
# Install face recognition dependencies
RUN apt update -y; apt install -y \
git \
cmake \
libsm6 \
libxext6 \
libxrender-dev \
python3 \
python3-pip
RUN pip3 install scikit-build
# Install compilers
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt update -y; apt install -y gcc-6 g++-6
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50
#Install dlib
RUN git clone https://github.com/davisking/dlib.git
RUN mkdir -p /dlib/build
RUN cmake -H/dlib -B/dlib/build -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
RUN cmake --build /dlib/build
RUN cd /dlib; python3 /dlib/setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
# Install the face recognition package
RUN pip3 install face_recognition
......@@ -371,7 +371,7 @@ to any service that supports Docker images.
You can try the Docker image locally by running: `docker-compose up`
If you don't have nvidia-docker installed or a GPU, remove the last line in the [docker-compose.yml](docker-compose.yml) file (`runtime: nvidia`).
Linux users with a GPU and [Nvidia-Docker](https://github.com/NVIDIA/nvidia-docker) installed can run the example on the GPU: Open the [docker-compose.yml](docker-compose.yml) file and uncomment the `dockerfile: Dockerfile.gpu` and `runtime: nvidia` lines.
## Having problems?
......
......@@ -7,7 +7,10 @@ services:
working_dir: /face_recognition/examples
build:
context: .
#Uncomment this line to run the example on the GPU (requires Nvidia-Docker)
# dockerfile: Dockerfile.gpu
command: python3 -u find_faces_in_picture_cnn.py
volumes:
- ./:/face_recognition
runtime: nvidia #Comment this line if you don't have nvidia-docker installed (requires GPU)
\ No newline at end of file
#Uncomment this line to run the example on the GPU (requires Nvidia-Docker)
# runtime: nvidia
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册