GPT-SoVITS/Docker/anaconda_install.sh
2025-05-03 05:07:36 +01:00

71 lines
1.8 KiB
Bash

#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
cd "$SCRIPT_DIR" || exit 1
cd .. || exit 1
if [ -d "$HOME/anaconda3" ]; then
exit 0
fi
WORKFLOW=${WORKFLOW:-"false"}
TARGETPLATFORM=${TARGETPLATFORM:-"linux/amd64"}
if [ "$WORKFLOW" = "true" ]; then
WGET_CMD="wget -nv --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404"
else
WGET_CMD="wget --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404"
fi
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
eval "$WGET_CMD -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh"
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
eval "$WGET_CMD -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-aarch64.sh"
else
exit 1
fi
LOG_PATH="/tmp/anaconda-install.log"
bash anaconda.sh -b -p "$HOME/anaconda3" >"$LOG_PATH" 2>&1
if [ $? -eq 0 ]; then
echo "== Anaconda Installed =="
else
echo "Failed to Install Anaconda"
tail -n 50 "$LOG_PATH"
exit 1
fi
rm anaconda.sh
source "$HOME/anaconda3/etc/profile.d/conda.sh"
"$HOME/anaconda3/bin/conda" config --add channels conda-forge
"$HOME/anaconda3/bin/conda" update -q --all -y 1>/dev/null
"$HOME/anaconda3/bin/conda" install python=3.11 -q -y
"$HOME/anaconda3/bin/conda" install gcc=14 gxx ffmpeg cmake make unzip -q -y
if [ "$CUDA_VERSION" = "12.8" ]; then
"$HOME/anaconda3/bin/pip" install torch torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/cu128
elif [ "$CUDA_VERSION" = "12.4" ]; then
"$HOME/anaconda3/bin/pip" install torch==2.5.1 torchaudio==2.5.1 --no-cache-dir --index-url https://download.pytorch.org/whl/cu124
fi
"$HOME/anaconda3/bin/pip" cache purge
rm $LOG_PATH
rm -rf "$HOME/anaconda3/pkgs"
mkdir "$HOME/anaconda3/pkgs"
rm -rf "$HOME/.conda" "$HOME/.cache"