Face plugin installer ask for GPU or CPU setup

build-default-monitor-config-from-definitions
Moe 2020-04-09 20:55:07 -07:00
parent b14cf34629
commit 4d819932b7
1 changed files with 55 additions and 32 deletions

View File

@ -1,33 +1,25 @@
#!/bin/bash #!/bin/bash
DIR=`dirname $0`
THE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" THE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
if [ -x "$(command -v apt)" ]; then
sudo apt update -y sudo apt update -y
fi
# Check if Cent OS
if [ -x "$(command -v yum)" ]; then
sudo yum update -y
fi
INSTALL_WITH_GPU="0"
echo "----------------------------------------" echo "----------------------------------------"
echo "-- Installing Face Plugin for Shinobi --" echo "-- Installing Face Plugin for Shinobi --"
echo "----------------------------------------" echo "----------------------------------------"
if ! [ -x "$(command -v nvidia-smi)" ]; then if [ -d "/usr/local/cuda" ]; then
echo "You need to install NVIDIA Drivers to use this." echo "Do you want to install the plugin with CUDA support?"
echo "inside the Shinobi directory run the following :" echo "Do this if you installed NVIDIA Drivers, CUDA Toolkit, and CuDNN"
echo "sh INSTALL/cuda.sh" echo "(y)es or (N)o"
exit 1 read usecuda
else if [ "$usecuda" = "y" ] || [ "$usecuda" = "Y" ]; then
echo "NVIDIA Drivers found..." INSTALL_WITH_GPU="1"
echo "$(nvidia-smi |grep 'Driver Version')"
fi fi
echo "-----------------------------------"
if [ ! -d "/usr/local/cuda-9.0" ]; then
echo "Tensorflow requires CUDA Toolkit 9.0"
echo "Installing CUDA Toolki 9.0..."
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64-deb -O cuda.deb
sudo dpkg -i cuda.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1704/x86_64/7fa2af80.pub
sudo apt update -y
sudo apt install cuda-toolkit-9-0 -y
wget https://cdn.shinobi.video/installers/libcudnn7_7.5.1.10-1+cuda9.0_amd64.deb -O cuda-dnn.deb
sudo dpkg -i cuda-dnn.deb
wget https://cdn.shinobi.video/installers/libcudnn7-dev_7.5.1.10-1+cuda9.0_amd64.deb -O cuda-dnn-dev.deb
sudo dpkg -i cuda-dnn-dev.deb
else
echo "CUDA Toolkit 9.0 found..."
fi fi
echo "-----------------------------------" echo "-----------------------------------"
if [ ! -d "./faces" ]; then if [ ! -d "./faces" ]; then
@ -35,7 +27,16 @@ if [ ! -d "./faces" ]; then
fi fi
if [ ! -d "./weights" ]; then if [ ! -d "./weights" ]; then
mkdir weights mkdir weights
if [ ! -x "$(command -v wget)" ]; then
# Check if Ubuntu
if [ -x "$(command -v apt)" ]; then
sudo apt install wget -y sudo apt install wget -y
fi
# Check if Cent OS
if [ -x "$(command -v yum)" ]; then
sudo yum install wget -y
fi
fi
cdnUrl="https://cdn.shinobi.video/weights/plugin-face-weights" cdnUrl="https://cdn.shinobi.video/weights/plugin-face-weights"
wget -O weights/face_landmark_68_model-shard1 $cdnUrl/face_landmark_68_model-shard1 wget -O weights/face_landmark_68_model-shard1 $cdnUrl/face_landmark_68_model-shard1
wget -O weights/face_landmark_68_model-weights_manifest.json $cdnUrl/face_landmark_68_model-weights_manifest.json wget -O weights/face_landmark_68_model-weights_manifest.json $cdnUrl/face_landmark_68_model-weights_manifest.json
@ -61,19 +62,41 @@ if [ ! -e "./conf.json" ]; then
else else
echo "conf.json already exists..." echo "conf.json already exists..."
fi fi
sudo npm i npm -g echo "-----------------------------------"
echo "Updating Node Package Manager"
sudo npm install npm -g --unsafe-perm
echo "-----------------------------------"
echo "Adding Random Plugin Key to Main Configuration"
node $THE_DIR/../../tools/modifyConfigurationForPlugin.js face key=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')
echo "-----------------------------------" echo "-----------------------------------"
echo "Getting node-gyp to build C++ modules" echo "Getting node-gyp to build C++ modules"
sudo npm install node-gyp -g --unsafe-perm if [ ! -x "$(command -v node-gyp)" ]; then
# Check if Ubuntu
if [ -x "$(command -v apt)" ]; then
sudo apt install node-gyp -y
fi
# Check if Cent OS
if [ -x "$(command -v yum)" ]; then
sudo yum install node-gyp -y
fi
fi
sudo npm install node-gyp -g --unsafe-perm --force
echo "-----------------------------------" echo "-----------------------------------"
echo "Getting C++ module : face-api.js" echo "Getting C++ module : face-api.js"
echo "https://github.com/justadudewhohacks/face-api.js" echo "https://github.com/justadudewhohacks/face-api.js"
sudo npm install --unsafe-perm sudo npm install --unsafe-perm --force
echo "Getting C++ module : @tensorflow/tfjs-node-gpu@0.1.21" echo "Getting C++ module : @tensorflow/tfjs-node@0.1.21"
echo "https://github.com/tensorflow/tfjs-node" echo "https://github.com/tensorflow/tfjs-node"
sudo npm install @tensorflow/tfjs-node-gpu@0.1.21 --unsafe-perm sudo npm install @tensorflow/tfjs-layers@0.8.5 --unsafe-perm --force
sudo npm install @tensorflow/tfjs-converter@0.6.7 --unsafe-perm --force
if [ "$INSTALL_WITH_GPU" = "1" ]; then
echo "GPU version of tjfs : https://github.com/tensorflow/tfjs-node-gpu"
sudo npm install @tensorflow/tfjs-node-gpu@0.1.21 --unsafe-perm --force
else
echo "CPU version of tjfs : https://github.com/tensorflow/tfjs-node"
sudo npm install @tensorflow/tfjs-node@0.1.21 --unsafe-perm --force
fi
sudo npm audit fix --force sudo npm audit fix --force
cd $THE_DIR
echo "-----------------------------------" echo "-----------------------------------"
echo "Start the plugin with pm2 like so :" echo "Start the plugin with pm2 like so :"
echo "pm2 start shinobi-face.js" echo "pm2 start shinobi-face.js"