From f687c35e156080d1daa0afdd7678768be3505eae Mon Sep 17 00:00:00 2001 From: plucky Date: Thu, 27 Dec 2018 17:59:22 +0800 Subject: [PATCH] support run cpu mode in docker --- .gitignore | 1 + DockerCPU.md | 16 +++++---- DockerGPU.md | 10 +++++- Dockerfile.cpu | 4 ++- cpu.sh | 69 +++++++++++++++++++++++++++++++++++++ cuda_9.0_cudnn_7.0_linux.sh | 30 ++++++++++++++++ 6 files changed, 121 insertions(+), 9 deletions(-) create mode 100755 cpu.sh create mode 100755 cuda_9.0_cudnn_7.0_linux.sh diff --git a/.gitignore b/.gitignore index 24d0e66..a1fb9f7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ !nnlib !utils !Dockerfile* +!*.sh diff --git a/DockerCPU.md b/DockerCPU.md index d66cdfd..da79d59 100644 --- a/DockerCPU.md +++ b/DockerCPU.md @@ -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 [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/ -$ chmod +x main.sh -$ ./main.sh +$ chmod +x cpu.sh +$ ./cpu.sh ``` -### some error - -#### localization.py system_locale is NoneType +#### some error ``` +1. localization.py system_locale is NoneType # system_locale may be nil 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) [安装N卡驱动](https://linuxstory.org/how-to-install-latest-nvidia-drivers-in-linux/) diff --git a/DockerGPU.md b/DockerGPU.md index f37271d..c563ecc 100644 --- a/DockerGPU.md +++ b/DockerGPU.md @@ -1,5 +1,13 @@ ### NO GPU Machine 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 + +### 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 +``` diff --git a/Dockerfile.cpu b/Dockerfile.cpu index b73218f..dc1b8d1 100644 --- a/Dockerfile.cpu +++ b/Dockerfile.cpu @@ -1,8 +1,10 @@ -FROM tensorflow/tensorflow:latest-gpu-py3 +FROM tensorflow/tensorflow:latest-py3 RUN apt-get update -qq -y \ && apt-get install -y libsm6 libxrender1 libxext-dev python3-tk\ && apt-get install -y ffmpeg \ + && apt-get install -y wget \ + && apt-get install -y vim \ && apt-get install -y git \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/cpu.sh b/cpu.sh new file mode 100755 index 0000000..6b96ff2 --- /dev/null +++ b/cpu.sh @@ -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 diff --git a/cuda_9.0_cudnn_7.0_linux.sh b/cuda_9.0_cudnn_7.0_linux.sh new file mode 100755 index 0000000..80be312 --- /dev/null +++ b/cuda_9.0_cudnn_7.0_linux.sh @@ -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