-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathentrypoint.sh
More file actions
90 lines (80 loc) · 2.27 KB
/
entrypoint.sh
File metadata and controls
90 lines (80 loc) · 2.27 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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# CUDA 검사 및 설정
echo "Checking CUDA availability..."
# Python을 통한 CUDA 검사
python_cuda_check() {
python3 -c "
import torch
try:
if torch.cuda.is_available():
print('CUDA_AVAILABLE')
exit(0)
else:
print('CUDA_NOT_AVAILABLE')
exit(1)
except Exception as e:
print(f'CUDA_ERROR: {e}')
exit(2)
" 2>/dev/null
}
# CUDA 검사 실행
cuda_status=$(python_cuda_check)
case $? in
0)
echo "✅ CUDA is available and working (Python check)"
export CUDA_VISIBLE_DEVICES=0
export FORCE_CUDA=1
;;
1)
echo "❌ CUDA is not available (Python check)"
echo "Error: CUDA is required but not available. Exiting..."
exit 1
;;
2)
echo "❌ CUDA check failed (Python check)"
echo "Error: CUDA initialization failed. Exiting..."
exit 1
;;
esac
# 추가적인 nvidia-smi 검사
if command -v nvidia-smi &> /dev/null; then
if nvidia-smi &> /dev/null; then
echo "✅ NVIDIA driver working (nvidia-smi check)"
else
echo "❌ NVIDIA driver found but not working"
echo "Error: NVIDIA driver is not working properly. Exiting..."
exit 1
fi
else
echo "❌ NVIDIA driver not found"
echo "Error: NVIDIA driver is required but not found. Exiting..."
exit 1
fi
# CUDA 환경 변수 설정
echo "Using CUDA device: $CUDA_VISIBLE_DEVICES"
# Start ComfyUI in the background
echo "Starting ComfyUI in the background..."
python /ComfyUI/main.py --listen --use-sage-attention &
# Wait for ComfyUI to be ready
echo "Waiting for ComfyUI to be ready..."
max_wait=120 # 최대 2분 대기
wait_count=0
while [ $wait_count -lt $max_wait ]; do
if curl -s http://127.0.0.1:8188/ > /dev/null 2>&1; then
echo "ComfyUI is ready!"
break
fi
echo "Waiting for ComfyUI... ($wait_count/$max_wait)"
sleep 2
wait_count=$((wait_count + 2))
done
if [ $wait_count -ge $max_wait ]; then
echo "Error: ComfyUI failed to start within $max_wait seconds"
exit 1
fi
# Start the handler in the foreground
# 이 스크립트가 컨테이너의 메인 프로세스가 됩니다.
echo "Starting the handler..."
exec python handler.py