-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_app.sh
More file actions
executable file
·100 lines (85 loc) · 2.49 KB
/
run_app.sh
File metadata and controls
executable file
·100 lines (85 loc) · 2.49 KB
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
#!/bin/bash
# Function to check if conda is initialized
check_conda_init() {
if ! command -v conda &> /dev/null; then
echo "Conda is not installed or not in PATH"
return 1
fi
return 0
}
# Function to initialize conda
init_conda() {
# Get the path to conda.sh
CONDA_BASE=$(conda info --base)
source "$CONDA_BASE/etc/profile.d/conda.sh"
if [ $? -ne 0 ]; then
echo "Failed to source conda.sh"
exit 1
fi
echo "Conda initialized successfully"
}
# Function to check CUDA version
check_cuda() {
if command -v nvidia-smi &> /dev/null; then
CUDA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | cut -d'.' -f1)
echo "CUDA version detected: $CUDA_VERSION"
return 0
else
echo "NVIDIA driver not found, installing CPU-only version"
return 1
fi
}
# Function to setup Ollama
setup_ollama() {
if ! command -v ollama &> /dev/null; then
echo "Installing Ollama..."
curl -fsSL https://ollama.com/install.sh | sh
if [ $? -ne 0 ]; then
echo "Failed to install Ollama"
exit 1
fi
echo "Ollama installed successfully"
else
echo "Ollama is already installed"
fi
echo "Pulling default model (llama3.2)..."
ollama pull llama3.2
if [ $? -ne 0 ]; then
echo "Failed to pull llama3.2 model"
exit 1
fi
echo "Model pulled successfully"
}
# Main script
echo "Setting up Ollama..."
setup_ollama
echo "Checking conda initialization..."
if ! check_conda_init; then
echo "Please install conda first"
exit 1
fi
echo "Initializing conda..."
init_conda
# Check if dp-clinical environment exists
if conda env list | grep -q "dp-clinical"; then
echo "Removing existing dp-clinical environment..."
conda deactivate
conda env remove -n dp-clinical -y
fi
echo "Creating new dp-clinical environment..."
conda create -n dp-clinical python=3.9 -y
conda activate dp-clinical
# Install PyTorch with appropriate CUDA version
echo "Checking CUDA availability..."
if check_cuda; then
echo "Installing PyTorch with CUDA support..."
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y
else
echo "Installing CPU-only PyTorch..."
conda install pytorch torchvision torchaudio cpuonly -c pytorch -y
fi
echo "Installing other requirements..."
pip install -r requirements.txt
# Run the Streamlit app
echo "Starting Streamlit app..."
streamlit run app.py