-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_envs.sh
executable file
·107 lines (85 loc) · 3.17 KB
/
setup_envs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Function to check if CUDA is available
check_cuda() {
if command -v nvcc &> /dev/null; then
echo "CUDA is available."
CUDA_VERSION=$(nvcc --version | grep "release" | sed 's/.*release //' | sed 's/,.*//')
echo "CUDA version: $CUDA_VERSION"
return 0
else
echo "CUDA is not available. Please ensure CUDA is installed and in your PATH."
return 1
fi
}
# Create and set up the main virtual environment
echo "Setting up main virtual environment..."
python3 -m venv venv
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Check CUDA availability
if check_cuda; then
# Extract major and minor version
CUDA_MAJOR_VERSION=$(echo $CUDA_VERSION | cut -d. -f1)
CUDA_MINOR_VERSION=$(echo $CUDA_VERSION | cut -d. -f2)
CUDA_VERSION_TAG="${CUDA_MAJOR_VERSION}${CUDA_MINOR_VERSION}"
# Install PyTorch with CUDA support
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION_TAG}
else
# Install CPU-only version of PyTorch
pip install torch torchvision torchaudio
fi
# Install other required packages
pip install transformers accelerate datasets evaluate scikit-learn \
requests beautifulsoup4 feedparser pyzmq nltk
# Install specific version of bitsandbytes compatible with the installed CUDA version
if check_cuda; then
pip install bitsandbytes
else
pip install bitsandbytes-cpu
fi
deactivate
# Setup for voice service
echo "Setting up environment for voice service..."
python3 -m venv voice_service_env
source voice_service_env/bin/activate
# Upgrade pip
pip install --upgrade pip
# Uninstall potentially problematic packages
pip uninstall -y numpy scipy librosa
# Install latest stable versions of NumPy, SciPy, and librosa
pip install numpy scipy librosa
# Install PyTorch and other dependencies
if check_cuda; then
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION_TAG}
else
pip install torch torchvision torchaudio
fi
# Install other dependencies
pip install pandas scikit-learn BeautifulSoup4 feedparser dtw pyzmq
# Clone and install OpenVoice
git clone https://github.com/myshell-ai/OpenVoice.git voice_service/openvoice
cd voice_service/openvoice
pip install -r requirements.txt
cd ../..
# Install MeloTTS
pip install git+https://github.com/myshell-ai/MeloTTS.git
python -m unidic download
# Download OpenVoice checkpoints
mkdir -p voice_service/checkpoints_v2
wget https://myshell-public-repo-host.s3.amazonaws.com/openvoice/checkpoints_v2_0417.zip
unzip checkpoints_v2_0417.zip -d voice_service/checkpoints_v2
rm checkpoints_v2_0417.zip
# Bug fix.
pip install numpy==1.24.3 scipy==1.10.1 librosa==0.10.0
deactivate
# Install Ollama
echo "Installing Ollama..."
curl https://ollama.ai/install.sh | sh
# Pull the gemma2:latest model
echo "Pulling gemma2:latest model..."
ollama pull gemma2:latest
echo "Virtual environments have been set up and dependencies installed."
echo "Ollama has been installed and the gemma2:latest model has been pulled."
echo "To activate the voice service environment, run: source voice_service_env/bin/activate"
echo "To start Ollama, run: ollama serve"