提交 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 # 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 FROM python:3.6-slim-stretch
# Install face recognition dependencies RUN apt-get -y update
RUN apt-get install -y --fix-missing \
RUN apt update -y; apt install -y \ build-essential \
git \ cmake \
cmake \ gfortran \
libsm6 \ git \
libxext6 \ wget \
libxrender-dev \ curl \
python3 \ graphicsmagick \
python3-pip libgraphicsmagick1-dev \
libatlas-dev \
RUN pip3 install scikit-build libavcodec-dev \
libavformat-dev \
# Install compilers libgtk2.0-dev \
libjpeg-dev \
RUN apt install -y software-properties-common liblapack-dev \
RUN add-apt-repository ppa:ubuntu-toolchain-r/test libswscale-dev \
RUN apt update -y; apt install -y gcc-6 g++-6 pkg-config \
python3-dev \
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50 python3-numpy \
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50 software-properties-common \
zip \
#Install dlib && apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN git clone https://github.com/davisking/dlib.git RUN cd ~ && \
RUN mkdir -p /dlib/build mkdir -p dlib && \
git clone -b 'v19.9' --single-branch https://github.com/davisking/dlib.git dlib/ && \
RUN cmake -H/dlib -B/dlib/build -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 cd dlib/ && \
RUN cmake --build /dlib/build python3 setup.py install --yes USE_AVX_INSTRUCTIONS
RUN cd /dlib; python3 /dlib/setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
# The rest of this file just runs an example script.
# Install the face recognition package
# If you wanted to use this Dockerfile to run your own app instead, maybe you would do this:
RUN pip3 install face_recognition # 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. ...@@ -371,7 +371,7 @@ to any service that supports Docker images.
You can try the Docker image locally by running: `docker-compose up` 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? ## Having problems?
......
...@@ -7,7 +7,10 @@ services: ...@@ -7,7 +7,10 @@ services:
working_dir: /face_recognition/examples working_dir: /face_recognition/examples
build: build:
context: . 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 command: python3 -u find_faces_in_picture_cnn.py
volumes: volumes:
- ./:/face_recognition - ./:/face_recognition
runtime: nvidia #Comment this line if you don't have nvidia-docker installed (requires GPU) #Uncomment this line to run the example on the GPU (requires Nvidia-Docker)
\ No newline at end of file # 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.
先完成此消息的编辑!
想要评论请 注册