ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.04k stars 13.45k forks source link

Docker-compose build doesn't work #1242

Open ruanchaves opened 3 years ago

ruanchaves commented 3 years ago

Description

If you clone this repository and run docker-compose up --build, the image fails to build.

To be more precise, it fails with a Python SyntaxError: invalid syntax while trying to install Pillow from requirements.txt.

As you can see below, these are the contents of the requirements.txt file:

face_recognition_models
Click>=6.0
dlib>=19.3.0
numpy
Pillow
scipy>=0.17.0

I highly suspect that this is happening because the right version of Pillow for this Docker container has not been annotated on the requirements.txt file, so it is pulling the latest version of Pillow, which is incompatible.

Does anyone know the right versions of Pillow and numpy for this Docker container? Maybe pinpointing those versions would solve the problem.

What I Did

Just followed the documentation. I uncommented the nvidia-related lines on docker-compose.yml and ran docker-compose up --build.

This is my docker-compose.yml.

version: '2.3'

services:
  face_recognition:
    image: face_recognition
    container_name: face_recognition
    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
    #Uncomment this line to run the example on the GPU (requires Nvidia-Docker)
    runtime: nvidia

This is the traceback.

VitalyVen commented 3 years ago

Can be solved with next steps:

  1. Build image from https://github.com/tobycheese/9.0-cudnn7-devel-ubuntu18.04 (ubuntu 18.04, python3.6).

git clone https://github.com/tobycheese/9.0-cudnn7-devel-ubuntu18.04.git cd 9.0-cudnn7-devel-ubuntu18.04/docker/ docker build -t 9.0-cudnn7-devel-ubuntu18.04 .

  1. Use this image instead of nvidia/cuda:9.0-cudnn7-devel (ubuntu 16, python 3.5)

Result docker file:


#FROM nvidia/cuda:9.0-cudnn7-devel
FROM 9.0-cudnn7-devel-ubuntu18.04
# Install face recognition dependencies

RUN apt update -y; apt install -y \
git \
cmake \
libsm6 \
libxext6 \
libxrender-dev \
libopenblas-dev \
liblapack-dev \
python3 \
python3-pip
...