Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,19 @@ import os
|
|
7 |
import torch
|
8 |
import bitsandbytes
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
print(f"Is CUDA available: {torch.cuda.is_available()}") # True
|
11 |
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
12 |
|
|
|
7 |
import torch
|
8 |
import bitsandbytes
|
9 |
|
10 |
+
# Function to wait for ZeroGPU to initialize
|
11 |
+
def wait_for_gpu(timeout=60):
|
12 |
+
print("Waiting for ZeroGPU to initialize...")
|
13 |
+
start_time = time.time()
|
14 |
+
while not torch.cuda.is_available():
|
15 |
+
if time.time() - start_time > timeout:
|
16 |
+
raise RuntimeError("Timeout: ZeroGPU did not initialize within the expected time.")
|
17 |
+
time.sleep(2) # Wait and check again
|
18 |
+
print("ZeroGPU is ready! Proceeding with model loading...")
|
19 |
+
|
20 |
+
# Wait for GPU before loading the model
|
21 |
+
wait_for_gpu()
|
22 |
+
|
23 |
print(f"Is CUDA available: {torch.cuda.is_available()}") # True
|
24 |
print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
25 |
|