-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·119 lines (102 loc) · 2.85 KB
/
setup.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
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
print_status() {
echo -e "${GREEN}[+]${NC} $1"
}
print_error() {
echo -e "${RED}[!]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[*]${NC} $1"
}
check_prerequisites() {
print_status "Checking prerequisites..."
# Check for docker
if ! command -v docker &> /dev/null; then
print_error "Docker not found. Please install Docker first."
print_warning "Visit: https://docs.docker.com/engine/install/"
return 1
fi
print_status "Docker: Found"
# Check for docker-compose
if ! command -v docker-compose &> /dev/null; then
print_error "Docker Compose not found. Please install Docker Compose first."
print_warning "Visit: https://docs.docker.com/compose/install/"
return 1
fi
print_status "Docker Compose: Found"
# Check for nvidia-docker
if ! docker info 2>/dev/null | grep -q "Runtimes.*nvidia"; then
print_error "NVIDIA Docker runtime not found. Please install nvidia-docker2."
print_warning "Visit: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html"
return 1
fi
print_status "NVIDIA Docker Runtime: Found"
# Check for NVIDIA GPU
if ! command -v nvidia-smi &> /dev/null; then
print_error "NVIDIA GPU driver not found."
print_warning "Please install NVIDIA drivers first."
return 1
fi
print_status "NVIDIA GPU: Found"
return 0
}
start_service() {
print_status "Starting GPU Monitor..."
docker-compose up -d
if [ $? -eq 0 ]; then
print_status "GPU Monitor started successfully!"
print_status "Dashboard available at: http://localhost:8081"
print_status "To check logs: docker-compose logs -f"
else
print_error "Failed to start GPU Monitor."
print_warning "Check logs with: docker-compose logs"
return 1
fi
}
stop_service() {
print_status "Stopping GPU Monitor..."
docker-compose down
}
restart_service() {
print_status "Restarting GPU Monitor..."
docker-compose restart
}
show_status() {
docker-compose ps
}
show_logs() {
docker-compose logs -f
}
case "$1" in
start)
check_prerequisites && start_service
;;
stop)
stop_service
;;
restart)
restart_service
;;
status)
show_status
;;
logs)
show_logs
;;
*)
echo "Usage: $0 {start|stop|restart|status|logs}"
echo
echo "Commands:"
echo " start - Check prerequisites and start the service"
echo " stop - Stop the service"
echo " restart - Restart the service"
echo " status - Show service status"
echo " logs - Show service logs"
exit 1
;;
esac