- Make Tensorflow's INSTALL.sh optionally non-interactive

- Update README
fix-non-showing-inputs
dapowers87 2020-10-06 04:44:34 +00:00
parent ce5107550a
commit 0eb4732650
2 changed files with 137 additions and 40 deletions

View File

@ -4,54 +4,137 @@ echo "Removing existing Tensorflow Node.js modules..."
npm uninstall @tensorflow/tfjs-node-gpu --unsafe-perm
npm uninstall @tensorflow/tfjs-node --unsafe-perm
npm install yarn -g --unsafe-perm --force
GPU_INSTALL="0"
echo "Shinobi - Are you installing on ARM64? This applies to computers like Jetson Nano and Raspberry Pi Model 3 B+"
echo "(y)es or (N)o"
read armCpu
if [ "$armCpu" = "y" ] || [ "$armCpu" = "Y" ]; then
echo "Shinobi - Is it a Jetson Nano?"
echo "You must be on JetPack 4.3 for this plugin to install."
echo "JetPack 4.3 Image can be found here : https://developer.nvidia.com/jetpack-43-archive"
echo "(y)es or (N)o"
read isItJetsonNano
echo "Shinobi - You may see Unsupported Errors, please wait while patches are applied."
if [ "$isItJetsonNano" = "y" ] || [ "$isItJetsonNano" = "Y" ]; then
GPU_INSTALL="1"
npm install @tensorflow/tfjs-node-gpu@1.7.3 --unsafe-perm
cd node_modules/@tensorflow/tfjs-node-gpu
echo '{"tf-lib": "https://cdn.shinobi.video/installers/libtensorflow-gpu-linux-arm64-1.15.0.tar.gz"}' > "scripts/custom-binary.json"
else
npm install @tensorflow/tfjs-node@1.7.3 --unsafe-perm
cd node_modules/@tensorflow/tfjs-node
echo '{"tf-lib": "https://cdn.shinobi.video/installers/libtensorflow-cpu-linux-arm-1.15.0.tar.gz"}' > "scripts/custom-binary.json"
fi
npm install --unsafe-perm
npm audit fix --force
cd ../../..
else
echo "Shinobi - Do you want to install TensorFlow.js with GPU support? "
echo "You can run this installer again to change it."
echo "(y)es or (N)o"
read nodejsinstall
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
GPU_INSTALL="1"
npm install @tensorflow/tfjs-node-gpu@1.7.3 --unsafe-perm
else
npm install @tensorflow/tfjs-node@1.7.3 --unsafe-perm
fi
installJetsonFlag=false
installArmFlag=false
installGpuFlag=false
dontCreateKeyFlag=false
while [ ! $# -eq 0 ]
do
case "$1" in
--jetson)
installJetsonFlag=true
exit
;;
--arm)
installArmFlag=true
exit
;;
--gpu)
installGpuFlag=true
exit
;;
--dont-create-key)
dontCreateKeyFlag=true
exit
;;
esac
shift
done
if [ "$installJetsonFlag" = true ] && [ "$installArmFlag" = true ]; then
echo "--jetson and --arm cannot both be set. Exiting..."
exit -1
fi
if ([ "$installJetsonFlag" = true ] || [ "$installArmFlag" = true ]) && [ "$installGpuFlag" = true ]; then
echo "--gpu flag cannot be set with --jetson or --arm"
exit -2
fi
nonInteractiveFlag=false
if [ "$installJetsonFlag" = true ] || [ "$installArmFlag" = true ] || [ "$installGpuFlag" = true ]; then
nonInteractiveFlag=true
fi
installJetson() {
installGpuFlag=true
npm install @tensorflow/tfjs-node-gpu@1.7.3 --unsafe-perm
cd node_modules/@tensorflow/tfjs-node-gpu
echo '{"tf-lib": "https://cdn.shinobi.video/installers/libtensorflow-gpu-linux-arm64-1.15.0.tar.gz"}' > "scripts/custom-binary.json"
}
installArm() {
npm install @tensorflow/tfjs-node@1.7.3 --unsafe-perm
cd node_modules/@tensorflow/tfjs-node
echo '{"tf-lib": "https://cdn.shinobi.video/installers/libtensorflow-cpu-linux-arm-1.15.0.tar.gz"}' > "scripts/custom-binary.json"
}
installGpuRoute() {
installGpuFlag=true
npm install @tensorflow/tfjs-node-gpu@1.7.3 --unsafe-perm
}
installNonGpuRoute() {
npm install @tensorflow/tfjs-node@1.7.3 --unsafe-perm
}
if [ "$nonInteractiveFlag" = false ]; then
echo "Shinobi - Are you installing on ARM64? This applies to computers like Jetson Nano and Raspberry Pi Model 3 B+"
echo "(y)es or (N)o"
read armCpu
if [ "$armCpu" = "y" ] || [ "$armCpu" = "Y" ]; then
echo "Shinobi - Is it a Jetson Nano?"
echo "You must be on JetPack 4.3 for this plugin to install."
echo "JetPack 4.3 Image can be found here : https://developer.nvidia.com/jetpack-43-archive"
echo "(y)es or (N)o"
read isItJetsonNano
echo "Shinobi - You may see Unsupported Errors, please wait while patches are applied."
if [ "$isItJetsonNano" = "y" ] || [ "$isItJetsonNano" = "Y" ]; then
installJetson
else
installArm
fi
else
echo "Shinobi - Do you want to install TensorFlow.js with GPU support? "
echo "You can run this installer again to change it."
echo "(y)es or (N)o"
read nodejsinstall
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
installGpuRoute
else
installNonGpuRoute
fi
fi
else
if [ "$installJetsonFlag" = true ]; then
installJetson
armAfterInstall
fi
if [ "$installArmFlag" = true ]; then
installArm
armAfterInstall
fi
if [ "$installGpuFlag" = true ]; then
installGpuRoute
else
installNonGpuRoute
fi
fi
npm install --unsafe-perm
npm audit fix --force
if [ ! -e "./conf.json" ]; then
dontCreateKeyFlag=false
echo "Creating conf.json"
sudo cp conf.sample.json conf.json
else
echo "conf.json already exists..."
fi
echo "Adding Random Plugin Key to Main Configuration"
tfjsBuildVal="cpu"
if [ "$GPU_INSTALL" = "1" ]; then
tfjsBuildVal="gpu"
if [ "$dontCreateKeyFlag" = false ]; then
tfjsBuildVal="cpu"
if [ "$installGpuFlag" = true ]; then
tfjsBuildVal="gpu"
fi
echo "Adding Random Plugin Key to Main Configuration"
node /tools/modifyConfigurationForPlugin.js tensorflow key=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}') tfjsBuild=$tfjsBuildVal
fi
node $DIR/../../tools/modifyConfigurationForPlugin.js tensorflow key=$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}') tfjsBuild=$tfjsBuildVal
echo "TF_FORCE_GPU_ALLOW_GROWTH=true" > "$DIR/.env"
echo "#CUDA_VISIBLE_DEVICES=0,2" >> "$DIR/.env"

View File

@ -10,9 +10,23 @@ cd /home/Shinobi/plugins/tensorflow
Copy the config file.
- To run the install script interactively:
```
sh INSTALL.sh
```
- To run the install script non-interactively:
```
sh INSTALL.sh
```
*WITH* the appropriate flags
| Flag | Purpose |
| ----------- | ----------- |
| `--jetson`| Install for Jetson Nano|
| `--arm`| Install for ARM Processors (like Raspberry Pi Model 3 B+)|
| `--gpu`| Install for GPU support|
| `--dont-create-key`| Don't generate random plugin key|
Start the plugin.