added the mormons install script but no idea if it works.

This commit is contained in:
cloveranon
2019-12-18 03:53:36 -05:00
parent fec5edaa45
commit 027943635f
Executable → Regular
+68 -34
View File
@@ -1,38 +1,72 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
cd "$(dirname "${0}")"
BASE_DIR="$(pwd)"
PACKAGES=(aria2 git unzip wget)
# Tensorflow states 3.4.0 as the minimum version.
# This is also the minimum version with venv support.
# 3.8.0 and up only includes tensorflow 2.0 and not 1.15
MIN_PYTHON_VERS="3.4.0"
MAX_PYTHON_VERS="3.7.9"
MODELS_DIRECTORY=generator/gpt2/models
MODEL_VERSION=model_v5
MODEL_NAME=model-550
MODEL_TORRENT_URL="https://github.com/AIDungeon/AIDungeon/files/3935881/model_v5.torrent.zip"
MODEL_TORRENT_BASENAME="$(basename "${MODEL_TORRENT_URL}")"
version_check () {
MAX_VERS=$(echo -e "$(python3 --version | cut -d' ' -f2)\n$MAX_PYTHON_VERS\n$MIN_PYTHON_VERS"\
| sort -V | tail -n1)
MIN_VERS=$(echo -e "$(python3 --version | cut -d' ' -f2)\n$MAX_PYTHON_VERS\n$MIN_PYTHON_VERS"\
| sort -V | head -n1)
if [ "$MIN_VERS" != "$MIN_PYTHON_VERS" ]; then
echo "Your installed python version, $(python3 --version), is too old."
echo "Please update to at least $MIN_PYTHON_VERS."
exit 1
elif [ "$MAX_VERS" != "$MAX_PYTHON_VERS" ]; then
echo "Your installed python version, $(python3 --version), is too new."
echo "Please install $MAX_PYTHON_VERS."
exit 1
fi
}
if [[ -d "${MODELS_DIRECTORY}/${MODEL_VERSION}" ]]; then
echo "AIDungeon2 is already installed"
else
echo "Installing dependencies"
pip install -r requirements.txt > /dev/null
apt-get install aria2 unzip > /dev/null
echo "Downloading AIDungeon2 Model... (this may take a very, very long time)"
mkdir -p "${MODELS_DIRECTORY}"
cd "${MODELS_DIRECTORY}"
mkdir "${MODEL_VERSION}"
wget "${MODEL_TORRENT_URL}"
unzip "${MODEL_TORRENT_BASENAME}"
echo -e "\n\n==========================================="
echo "We are now starting to download the model."
echo "It will take a while to get up to speed."
echo "DHT errors are normal."
echo -e "===========================================\n"
aria2c \
--max-connection-per-server 16 \
--split 64 \
--bt-max-peers 500 \
--seed-time=0 \
--summary-interval=15 \
--disable-ipv6 \
"${MODEL_TORRENT_BASENAME%.*}"
echo "Download Complete!"
fi
pip_install () {
if [ ! -d "./venv" ]; then
# Some distros have venv built into python so this isn't always needed.
if is_command 'apt-get'; then
apt-get install python3-venv
fi
python3 -m venv ./venv
fi
source "${BASE_DIR}/venv/bin/activate"
pip install --upgrade pip setuptools
pip install -r "${BASE_DIR}/requirements.txt"
}
is_command() {
command -v "${@}" > /dev/null
}
system_package_install() {
PACKAGES=(aria2 git unzip wget)
if is_command 'apt-get'; then
sudo apt-get install ${PACKAGES[@]}
elif is_command 'brew'; then
brew install ${PACKAGES[@]}
elif is_command 'yum'; then
sudo yum install ${PACKAGES[@]}
elif is_command 'dnf'; then
sudo dnf install ${PACKAGES[@]}
elif is_command 'pacman'; then
sudo pacman -S ${PACKAGES[@]}
elif is_command 'apk'; then
sudo apk --update add ${PACKAGES[@]}
else
echo "You do not seem to be using a supported package manager."
echo "Please make sure ${PACKAGES[@]} are installed then press [ENTER]"
read NOT_USED
fi
}
install_aid () {
version_check
pip_install
system_package_install
}
install_aid