mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-19 13:09:58 -07:00
fix docker build
This commit is contained in:
parent
c0aee1f74b
commit
d5832b0073
3 changed files with 136 additions and 25 deletions
|
@ -1,19 +1,113 @@
|
|||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04
|
||||
WORKDIR /app
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
ARG NV_VER
|
||||
RUN apt update
|
||||
RUN apt -y install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 curl ffmpeg git nano gnupg2 libsm6 wget unzip libxcb-icccm4 libxkbcommon-x11-0 libxcb-keysyms1 libxcb-icccm4 libxcb-render0 libxcb-render-util0 libxcb-image0
|
||||
RUN apt install -y python3 python3-pip
|
||||
ARG LIVE_GID="100"
|
||||
ARG LIVE_UID="1000"
|
||||
ARG LIVE_USER="live"
|
||||
|
||||
USER root
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||||
ENV DEEPFACELIVE_PATH=/usr/local/deepfacelive
|
||||
ENV DEEPFACELIVE_DATA=/usr/local/deepfacelive_data
|
||||
|
||||
|
||||
RUN apt-get update --fix-missing
|
||||
RUN apt-get -y install --no-install-recommends \
|
||||
libgl1-mesa-glx \
|
||||
libegl1-mesa \
|
||||
libxrandr2 \
|
||||
libxrandr2 \
|
||||
libxss1 \
|
||||
libxcursor1 \
|
||||
libxcomposite1 \
|
||||
libasound2 \
|
||||
libxi6 \
|
||||
libxtst6 \
|
||||
locales \
|
||||
sudo \
|
||||
curl \
|
||||
ffmpeg \
|
||||
git \
|
||||
# nano \
|
||||
gnupg2 \
|
||||
libsm6 \
|
||||
wget \
|
||||
unzip \
|
||||
libxcb-icccm4 \
|
||||
libxkbcommon-x11-0 \
|
||||
libxcb-keysyms1 \
|
||||
libxcb-icccm4 \
|
||||
libxcb-render0 \
|
||||
libxcb-render-util0 \
|
||||
libxcb-image0 \
|
||||
libnvidia-compute-${NV_VER}
|
||||
|
||||
RUN apt-get install -y --no-install-recommends \
|
||||
python3 \
|
||||
python3-distutils \
|
||||
python3-pyqt5
|
||||
|
||||
RUN ln -s /usr/bin/python3 /usr/bin/python
|
||||
|
||||
RUN git clone https://github.com/iperov/DeepFaceLive.git
|
||||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
|
||||
&& locale-gen
|
||||
|
||||
RUN python -m pip install --upgrade pip
|
||||
RUN python -m pip install onnxruntime-gpu==1.12.1 numpy==1.21.6 h5py numexpr protobuf==3.20.1 opencv-python==4.7.0.68 opencv-contrib-python==4.7.0.68 pyqt6==6.4.0 onnx==1.13.0 torch==1.10.0 torchvision==0.11.1
|
||||
ENV LIVE_GID=${LIVE_GID} \
|
||||
LIVE_UID=${LIVE_UID} \
|
||||
LIVE_USER=${LIVE_USER} \
|
||||
HOME=/home/${LIVE_USER} \
|
||||
LANG=en_US.UTF-8 \
|
||||
LANGUAGE=en_US.UTF-8 \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
SHELL=/bin/bash
|
||||
|
||||
RUN apt install -y libnvidia-compute-$NV_VER
|
||||
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su \
|
||||
&& sed -i.bak -e 's/^%admin/#%admin/' /etc/sudoers \
|
||||
&& sed -i.bak -e 's/^%sudo/#%sudo/' /etc/sudoers \
|
||||
&& useradd -m -s /bin/bash -N -u ${LIVE_UID} ${LIVE_USER} \
|
||||
&& chmod g+w /etc/passwd
|
||||
|
||||
WORKDIR /app/DeepFaceLive
|
||||
COPY example.sh example.sh
|
||||
CMD ./example.sh
|
||||
RUN mkdir -p ${DEEPFACELIVE_PATH} \
|
||||
&& chown ${LIVE_UID}:${LIVE_GID} ${DEEPFACELIVE_PATH} \
|
||||
&& mkdir -p ${DEEPFACELIVE_DATA} \
|
||||
&& chown ${LIVE_UID}:${LIVE_GID} ${DEEPFACELIVE_DATA}
|
||||
|
||||
# Switch to user "live"
|
||||
USER ${LIVE_UID}
|
||||
WORKDIR ${HOME}
|
||||
|
||||
ENV PATH=${HOME}/.local/bin:$PATH
|
||||
|
||||
RUN python -c "from urllib.request import urlopen; \
|
||||
exec(urlopen('https://bootstrap.pypa.io/get-pip.py').read())"
|
||||
|
||||
RUN python -m pip install \
|
||||
onnxruntime-gpu==1.10 \
|
||||
numpy==1.20 \
|
||||
h5py \
|
||||
numexpr \
|
||||
protobuf==3.20.2 \
|
||||
opencv-python==4.7.0.68 \
|
||||
opencv-contrib-python==4.7.0.68 \
|
||||
pyqt6==6.4.0 \
|
||||
onnx==1.13.0 \
|
||||
torch==1.10.0 \
|
||||
torchvision==0.11.1
|
||||
|
||||
RUN git clone https://github.com/iperov/DeepFaceLive.git ${DEEPFACELIVE_PATH}
|
||||
|
||||
RUN ln -s ${DEEPFACELIVE_PATH} ${HOME}/deepfacelive \
|
||||
&& ln -s ${DEEPFACELIVE_DATA} ${HOME}/deepfacelive_data
|
||||
|
||||
USER root
|
||||
|
||||
RUN apt-get --purge -y remove wget curl git \
|
||||
&& apt-get --purge -y autoremove \
|
||||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
|
||||
|
||||
USER $LIVE_UID
|
||||
WORKDIR ${HOME}
|
||||
CMD [ "python", "/usr/local/deepfacelive/main.py", "run", "DeepFaceLive", "--userdata-dir", "/usr/local/deepfacelive_data" ]
|
||||
|
|
|
@ -2,19 +2,31 @@
|
|||
|
||||
### Requirements
|
||||
|
||||
* nvidia-driver-470 (current)
|
||||
* cuda 11.4 (current)
|
||||
* nvidia-driver>=470
|
||||
* cuda>=11.4
|
||||
|
||||
### Setup
|
||||
|
||||
1. Open console and clone git repo
|
||||
```
|
||||
git clone DeepFaceLive
|
||||
git clone https://github.com/iperov/DeepFaceLive.git
|
||||
cd DeepFaceLive/build/linux/
|
||||
# start.sh builds and runs container with proper options, then example.sh will start DeepFaceLive with example options
|
||||
./start.sh
|
||||
|
||||
Usage of ./start.sh
|
||||
# -d specify a folder for DeepFaceLive data (videos, models, etc)
|
||||
-d /home/user/DeepFaceLive_data
|
||||
# -c will pass through existing video devices such as /dev/video0 and /dev/video1, etc
|
||||
```
|
||||
1. `start.sh` builds and run container with proper options<br>
|
||||
2. Usage of `./start.sh`<br>
|
||||
-d specify a folder for DeepFaceLive data (videos, models, etc)<br>
|
||||
`-d /home/userJohn/DeepFaceLive_data`<br>
|
||||
**if data folder not specified - used data in build/linux/data<br>
|
||||
***create data folder in build/linux if launch first time and no matter where to place<br>
|
||||
-c will pass through existing video devices(webcam, fake webcam and other) such as /dev/video0 and /dev/video1, etc<br>
|
||||
`-c /dev/video0`<br>
|
||||
If no autodetect you video driver run in host(not have locate, modinfo)<br>
|
||||
`nvidia-smi | grep Driver`<br>
|
||||
and see output:
|
||||
|
||||
```
|
||||
NVIDIA-SMI 525.89.02 Driver Version: 525.89.02 CUDA Version: 12.0
|
||||
```
|
||||
|
||||
-r bruild and run with you driver version from nvidia-smi like this <br>
|
||||
`./start.sh -r 525 -d /home/userJohn/DeepFaceLive_data -c /dev/video0`<br>
|
||||
## ***DO NOT RUN `./start.sh ` from root(sudo)!
|
||||
|
|
|
@ -6,7 +6,7 @@ NV_VER=$(modinfo $NV_LIB | grep ^version |awk '{print $2}'|awk -F '.' '{print $1
|
|||
DATA_FOLDER=$(pwd)/data/
|
||||
declare CAM0 CAM1 CAM2 CAM3
|
||||
printf "\n"
|
||||
while getopts 'cd:h' opt; do
|
||||
while getopts 'cdr:h' opt; do
|
||||
case "$opt" in
|
||||
c)
|
||||
printf "Starting with camera devices\n"
|
||||
|
@ -20,9 +20,14 @@ while getopts 'cd:h' opt; do
|
|||
DATA_FOLDER="$OPTARG"
|
||||
printf "Starting with data folder: %s\n" "$DATA_FOLDER"
|
||||
;;
|
||||
r)
|
||||
NV_VER="$OPTARG"
|
||||
printf "Build with Nvidia Driver version: %s\n" "$NV_VER"
|
||||
;;
|
||||
|
||||
?|h)
|
||||
printf "Usage:\n$(basename $0) [-d] /path/to/your/data/folder\n"
|
||||
printf "$(basename $0) [-r] Build with you driver version from nvidia-smi\n"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -33,4 +38,4 @@ printf "\n"
|
|||
# Warning xhost + is overly permissive and will reduce system security. Edit as desired
|
||||
docker build . -t deepfacelive --build-arg NV_VER=$NV_VER
|
||||
xhost +
|
||||
docker run --ipc host --gpus all -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $DATA_FOLDER:/data/ $CAM0 $CAM1 $CAM2 $CAM3 --rm -it deepfacelive
|
||||
docker run --ipc host --gpus all -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $DATA_FOLDER:/usr/local/deepfacelive_data/ $CAM0 $CAM1 $CAM2 $CAM3 --rm -it deepfacelive
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue