Spaces:
Running
Running
fix zero-gpu error
Browse files- backend_deploy.py +21 -1
backend_deploy.py
CHANGED
|
@@ -1290,7 +1290,27 @@ def duplicate_space_to_user(
|
|
| 1290 |
# Duplicate the space
|
| 1291 |
print(f"[Duplicate] Duplicating {from_space_id} to {username}/{to_space_name}")
|
| 1292 |
print(f"[Duplicate] Parameters: {list(duplicate_params.keys())}")
|
| 1293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1294 |
|
| 1295 |
# Extract space URL
|
| 1296 |
space_url = f"https://huggingface.co/spaces/{to_space_id}"
|
|
|
|
| 1290 |
# Duplicate the space
|
| 1291 |
print(f"[Duplicate] Duplicating {from_space_id} to {username}/{to_space_name}")
|
| 1292 |
print(f"[Duplicate] Parameters: {list(duplicate_params.keys())}")
|
| 1293 |
+
|
| 1294 |
+
try:
|
| 1295 |
+
duplicated_repo = duplicate_space(**duplicate_params)
|
| 1296 |
+
except Exception as dup_error:
|
| 1297 |
+
# Check if it's a zero-gpu hardware error
|
| 1298 |
+
error_str = str(dup_error).lower()
|
| 1299 |
+
if 'zero' in error_str or 'hardware' in error_str:
|
| 1300 |
+
print(f"[Duplicate] Hardware error detected (likely zero-gpu issue): {dup_error}")
|
| 1301 |
+
print(f"[Duplicate] Retrying with cpu-basic hardware...")
|
| 1302 |
+
|
| 1303 |
+
# Retry with cpu-basic hardware
|
| 1304 |
+
duplicate_params["hardware"] = "cpu-basic"
|
| 1305 |
+
try:
|
| 1306 |
+
duplicated_repo = duplicate_space(**duplicate_params)
|
| 1307 |
+
print(f"[Duplicate] ✅ Successfully duplicated with cpu-basic hardware")
|
| 1308 |
+
except Exception as retry_error:
|
| 1309 |
+
print(f"[Duplicate] Retry with cpu-basic also failed: {retry_error}")
|
| 1310 |
+
raise retry_error
|
| 1311 |
+
else:
|
| 1312 |
+
# Not a hardware error, re-raise
|
| 1313 |
+
raise dup_error
|
| 1314 |
|
| 1315 |
# Extract space URL
|
| 1316 |
space_url = f"https://huggingface.co/spaces/{to_space_id}"
|