support run cpu mode in docker

This commit is contained in:
plucky 2018-12-27 17:59:22 +08:00
commit f687c35e15
6 changed files with 121 additions and 9 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@
!nnlib !nnlib
!utils !utils
!Dockerfile* !Dockerfile*
!*.sh

View file

@ -1,3 +1,6 @@
# For Mac Users
if you just have a MacBook.deepfacelab gpu mode does not works. however,it can also works with cpu mode.
### 1. Install Docker ### 1. Install Docker
[Docker Desktop for Mac] (https://hub.docker.com/editions/community/docker-ce-desktop-mac) [Docker Desktop for Mac] (https://hub.docker.com/editions/community/docker-ce-desktop-mac)
@ -54,20 +57,19 @@ $ docker exec -it deepfacelab-cpu bash
``` ```
$ cd ../srv/ $ cd ../srv/
$ chmod +x main.sh $ chmod +x cpu.sh
$ ./main.sh $ ./cpu.sh
``` ```
### some error #### some error
#### localization.py system_locale is NoneType
``` ```
1. localization.py system_locale is NoneType
# system_locale may be nil # system_locale may be nil
system_language = system_locale[0:2] if system_locale is not None else "en" system_language = system_locale[0:2] if system_locale is not None else "en"
```
#### NVML Shared Library Not Found
```
[Install NVIDIA Driver](http://www.linuxandubuntu.com/home/how-to-install-latest-nvidia-drivers-in-linux) [Install NVIDIA Driver](http://www.linuxandubuntu.com/home/how-to-install-latest-nvidia-drivers-in-linux)
[安装N卡驱动](https://linuxstory.org/how-to-install-latest-nvidia-drivers-in-linux/) [安装N卡驱动](https://linuxstory.org/how-to-install-latest-nvidia-drivers-in-linux/)

View file

@ -1,5 +1,13 @@
### NO GPU Machine YET ### NO GPU Machine YET
Mac Pro or Mac Mini GPU not support yet Mac Pro or Mac Mini GPU not support yet
1. Install Nvidia-Docker & Restart Docker Service ### 1. Install Nvidia-Docker & Restart Docker Service
https://github.com/NVIDIA/nvidia-docker https://github.com/NVIDIA/nvidia-docker
### 8. **IMPORTANT** install cudatoolkit && cudnn
```
$ cd ../srv/
$ chmod +x cuda_9.0_cudnn_7.0_linux.sh
$ ./cuda_9.0_cudnn_7.0_linux.sh
```

View file

@ -1,8 +1,10 @@
FROM tensorflow/tensorflow:latest-gpu-py3 FROM tensorflow/tensorflow:latest-py3
RUN apt-get update -qq -y \ RUN apt-get update -qq -y \
&& apt-get install -y libsm6 libxrender1 libxext-dev python3-tk\ && apt-get install -y libsm6 libxrender1 libxext-dev python3-tk\
&& apt-get install -y ffmpeg \ && apt-get install -y ffmpeg \
&& apt-get install -y wget \
&& apt-get install -y vim \
&& apt-get install -y git \ && apt-get install -y git \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*

69
cpu.sh Executable file
View file

@ -0,0 +1,69 @@
#!/bin/bash
INTERNAL_DIR=`pwd`
WORKSPACE=$INTERNAL_DIR/workspace
PYTHON=`which python`
PS3="Please enter your choice: "
options=("clear workspace" "extract PNG from video data_src" "data_src extract faces" "data_src sort" "extract PNG from video data_dst" "data_dst extract faces" "data_dst sort by hist" "train" "convert" "converted to mp4" "quit")
select opt in "${options[@]}"
do
case $opt in
"clear workspace" )
echo -n "Clean up workspace? [Y/n] "; read workspace_ans
if [ "$workspace_ans" == "Y" ] || [ "$workspace_ans" == "y" ]; then
rm -rf $WORKSPACE
mkdir -p $WORKSPACE/data_src/aligned
mkdir -p $WORKSPACE/data_dst/aligned
mkdir -p $WORKSPACE/model
echo "Workspace has been successfully cleaned!"
fi
;;
"extract PNG from video data_src" )
echo -n "File name: "; read filename
echo -n "FPS: "; read fps
if [ -z "$fps" ]; then fps="25"; fi
ffmpeg -i $WORKSPACE/$filename -r $fps $WORKSPACE/data_src/%04d.png -loglevel error
;;
"data_src extract faces" )
echo -n "Detector? [mt | manual] "; read detector
$PYTHON $INTERNAL_DIR/main.py extract --input-dir $WORKSPACE/data_src --output-dir $WORKSPACE/data_src/aligned --detector $detector --debug --cpu-only
;;
"data_src sort" )
echo -n "Sort by? [blur | brightness | face-yaw | hue | hist | hist-blur | hist-dissim] "; read sort_method
$PYTHON $INTERNAL_DIR/main.py sort --input-dir $WORKSPACE/data_src/aligned --by $sort_method
;;
"extract PNG from video data_dst" )
echo -n "File name: "; read filename
echo -n "FPS: "; read fps
if [ -z "$fps" ]; then fps="25"; fi
ffmpeg -i $WORKSPACE/$filename -r $fps $WORKSPACE/data_dst/%04d.png -loglevel error
;;
"data_dst extract faces" )
echo -n "Detector? [mt | manual] "; read detector
$PYTHON $INTERNAL_DIR/main.py extract --input-dir $WORKSPACE/data_dst --output-dir $WORKSPACE/data_dst/aligned --detector $detector --debug --cpu-only
;;
"data_dst sort by hist" )
$PYTHON $INTERNAL_DIR/main.py sort --input-dir $WORKSPACE/data_dst/aligned --by hist
;;
"train" )
echo -n "Model? [ H64 (2GB+) | H128 (3GB+) | DF (5GB+) | LIAEF128 (5GB+) | LIAEF128YAW (5GB+) | MIAEF128 (5GB+) | AVATAR (4GB+) ] "; read model
$PYTHON $INTERNAL_DIR/main.py train --training-data-src-dir $WORKSPACE/data_src/aligned --training-data-dst-dir $WORKSPACE/data_dst/aligned --model-dir $WORKSPACE/model --model $model --debug --cpu-only
;;
"convert" )
echo -n "Model? [ H64 (2GB+) | H128 (3GB+) | DF (5GB+) | LIAEF128 (5GB+) | LIAEF128YAW (5GB+) | MIAEF128 (5GB+) | AVATAR(4GB+) ] "; read model
$PYTHON $INTERNAL_DIR/main.py convert --input-dir $WORKSPACE/data_dst --output-dir $WORKSPACE/data_dst/merged --aligned-dir $WORKSPACE/data_dst/aligned --model-dir $WORKSPACE/model --model $model --ask-for-params --debug --cpu-only
;;
"converted to mp4" )
echo -n "File name of destination video: "; read filename
echo -n "FPS: "; read fps
if [ -z "$fps" ]; then fps="25"; fi
ffmpeg -y -i $WORKSPACE/$filename -r $fps -i "$WORKSPACE/data_dst/merged/%04d.png" -map 0:a? -map 1:v -r $fps -c:v libx264 -b:v 8M -pix_fmt yuv420p -c:a aac -b:a 192k -ar 48000 "$WORKSPACE/result.mp4" -loglevel error
;;
"quit" )
break
;;
*)
echo "Invalid choice!"
;;
esac
done

30
cuda_9.0_cudnn_7.0_linux.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
# install CUDA Toolkit v9.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb)
CUDA_REPO_PKG="cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb"
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/${CUDA_REPO_PKG}
dpkg -i ${CUDA_REPO_PKG}
apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
apt-get update
apt-get -y install cuda-9-0
CUDA_PATCH1="cuda-repo-ubuntu1604-9-0-local-cublas-performance-update_1.0-1_amd64-deb"
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/${CUDA_PATCH1}
dpkg -i ${CUDA_PATCH1}
apt-get update
# install cuDNN v7.0
CUDNN_PKG="libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb"
wget https://github.com/ashokpant/cudnn_archive/raw/master/v7.0/${CUDNN_PKG}
dpkg -i ${CUDNN_PKG}
apt-get update
# install NVIDIA CUDA Profile Tools Interface ( libcupti-dev v9.0)
apt-get install cuda-command-line-tools-9-0
# set environment variables
export PATH=${PATH}:/usr/local/cuda-9.0/bin
export CUDA_HOME=${CUDA_HOME}:/usr/local/cuda:/usr/local/cuda-9.0
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda-9.0/lib64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64