adapt get-whishper for gpu support
This commit is contained in:
113
get-whishper.sh
113
get-whishper.sh
@@ -1,78 +1,121 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Color codes
|
||||||
|
RED='\033[0;31m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
# Check if docker is installed
|
# Check if docker is installed
|
||||||
if ! [ -x "$(command -v docker)" ]; then
|
if ! [ -x "$(command -v docker)" ]; then
|
||||||
echo "Docker is not installed. Please install docker first."
|
echo -e "${RED}❌ Docker is not installed. Please install docker first.${NC}"
|
||||||
echo "Run official docker installation script? (y/n)"
|
echo -e "> Run official docker installation script? (y/n)"
|
||||||
echo "----> Check out the script: https://get.docker.com"
|
echo -e "---> Check out the script: https://get.docker.com"
|
||||||
echo "----> I will run: 'curl -fsSL https://get.docker.com | sudo sh'"
|
echo -e "---> I will run: 'curl -fsSL https://get.docker.com | sudo sh'"
|
||||||
read answer
|
read answer
|
||||||
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
||||||
echo "Running official docker installation script"
|
echo -e "${BLUE}ℹ️ Running official docker installation script${NC}"
|
||||||
curl -fsSL https://get.docker.com | sudo sh
|
curl -fsSL https://get.docker.com | sudo sh
|
||||||
else
|
else
|
||||||
echo "Aborting installation"
|
echo -e "${RED}❌ Aborting installation${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ask if user wants to get everything in the current directory or in a new directory
|
# Ask if user wants to get everything in the current directory or in a new directory
|
||||||
echo "Do you want to set up everything in the current directory? (y/n)"
|
echo -e "${BLUE}> Do you want to set up everything in the current directory? (y/n)${NC}"
|
||||||
read answer
|
read answer
|
||||||
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
||||||
echo "Setting up everything in the current directory"
|
echo -e "ℹ️ Setting up everything in the current directory"
|
||||||
else
|
else
|
||||||
echo "Enter the name of the directory where you want to set up everything: "
|
echo -e "${BLUE}> Enter the name of the directory where you want to set up everything:${NC}"
|
||||||
read directory
|
read directory
|
||||||
echo "----> Setting up everything in the $directory directory"
|
echo -e "ℹ️ Setting up everything in the $directory directory"
|
||||||
mkdir $directory
|
mkdir $directory
|
||||||
cd $directory
|
cd $directory
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Getting the docker-compose.yml file from Github"
|
echo ""
|
||||||
curl -o docker-compose.yml https://raw.githubusercontent.com/pluja/whishper/main/docker-compose.yml
|
echo -e "ℹ️ For more info about GPU support check out: https://whishper.net/guides/gpu/"
|
||||||
|
echo -e "${BLUE}> Do you want to use the GPU version? (y/n)${NC}"
|
||||||
echo "Getting the nginx.conf file from Github"
|
read gpu
|
||||||
curl -o nginx.conf https://raw.githubusercontent.com/pluja/whishper/main/nginx.conf
|
if [ "$gpu" != "${gpu#[Yy]}" ] ;then
|
||||||
|
gpu=true
|
||||||
# Copy env.example to .env
|
if ! [ -x "$(command -v nvidia-container-toolkit)" ]; then
|
||||||
# check if .env exists
|
echo ""
|
||||||
if [ -f .env ]; then
|
echo -e "${YELLOW}⚠️ WARNING: nvidia-container-toolkit seems to not be installed. You must install it for whishper to work with GPU. Read more at: https://whishper.net/guides/gpu/${NC}"
|
||||||
echo ".env file already exists"
|
echo -e "${BLUE}> Do you want to continue anyways? (y/n)"
|
||||||
echo "Do you want to overwrite it? (y/n)"
|
read continue
|
||||||
read answer
|
if [ "$gpu" != "${gpu#[Yy]}" ] ;then
|
||||||
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
echo -e "ℹ️ Continuing..."
|
||||||
echo "Copying env.example to .env"
|
else
|
||||||
cp env.example .env
|
echo -e "${RED}❌ Aborting installation${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Getting the default .env file from Github"
|
gpu=false
|
||||||
curl -o .env https://raw.githubusercontent.com/pluja/whishper/main/example.env
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "ℹ️ Getting the docker-compose.yml file from Github"
|
||||||
|
curl -o docker-compose.yml https://raw.githubusercontent.com/pluja/whishper/main/docker-compose.yml > /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo -e "ℹ️ Getting the nginx.conf file from Github"
|
||||||
|
curl -o nginx.conf https://raw.githubusercontent.com/pluja/whishper/main/nginx.conf > /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# check if .env exists
|
||||||
|
if [ -f .env ]; then
|
||||||
|
echo ""
|
||||||
|
echo -e "${YELLOW}⚠️ .env file already exists${NC}"
|
||||||
|
echo -e "${BLUE}> Do you want to overwrite it? (y/n)"
|
||||||
|
read answer
|
||||||
|
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
||||||
|
echo -e "ℹ️ Copying env.example to .env"
|
||||||
|
cp .env .env.backup
|
||||||
|
curl -o .env https://raw.githubusercontent.com/pluja/whishper/main/example.env > /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo -e "ℹ️ Getting the default .env file from Github"
|
||||||
|
curl -o .env https://raw.githubusercontent.com/pluja/whishper/main/example.env > /dev/null 2>&1
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$gpu" = true ] ;then
|
||||||
|
sed -i 's/COMPOSE_PROFILES=cpu/COMPOSE_PROFILES=gpu/g' .env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create necessary directories for libretranslate
|
# Create necessary directories for libretranslate
|
||||||
echo "Creating necessary directories for libretranslate"
|
echo -e "ℹ️ Creating necessary directories for libretranslate"
|
||||||
sudo mkdir -p ./whishper_data/libretranslate/{data,cache}
|
sudo mkdir -p ./whishper_data/libretranslate/{data,cache}
|
||||||
|
sleep 1
|
||||||
|
|
||||||
# This permissions are for libretranslate docker container
|
# This permissions are for libretranslate docker container
|
||||||
echo "Setting permissions for libretranslate"
|
echo -e "ℹ️ Setting permissions for libretranslate"
|
||||||
case "$OSTYPE" in
|
case "$OSTYPE" in
|
||||||
darwin*) echo "macOS detected... Leaving permissions as is." ;;
|
darwin*) echo -e "ℹ️ macOS detected... Leaving permissions as is." ;;
|
||||||
linux*) sudo chown -R 1032:1032 ./whishper_data/libretranslate ;;
|
linux*) sudo chown -R 1032:1032 ./whishper_data/libretranslate ;;
|
||||||
*) echo "unknown: $OSTYPE" ;;
|
*) echo -e "${YELLOW}⚠️ unknown: $OSTYPE${NC}" ;;
|
||||||
esac
|
esac
|
||||||
|
sleep 1
|
||||||
|
|
||||||
echo "Do you want to pull docker images? (y/n)"
|
echo ""
|
||||||
|
echo -e "${BLUE}> Do you want to pull the docker images? (y/n)"
|
||||||
read answer
|
read answer
|
||||||
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
||||||
echo "Pulling and building docker images"
|
echo -e "ℹ️ Pulling and building docker images"
|
||||||
sudo docker compose pull
|
sudo docker compose pull
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Do you want to start the containers? (y/n)"
|
echo ""
|
||||||
|
echo -e "${BLUE}> Do you want to start the containers now? (y/n)"
|
||||||
read answer
|
read answer
|
||||||
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
||||||
echo "Starting whishper..."
|
echo -e "ℹ️ Starting whishper..."
|
||||||
sudo docker compose up -d
|
sudo docker compose up -d
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user