-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodal_beast_runner.py
More file actions
72 lines (66 loc) · 2.13 KB
/
Copy pathmodal_beast_runner.py
File metadata and controls
72 lines (66 loc) · 2.13 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
import modal
from modal import App, Image, Secret
# Define the App
app = App("nexus-visual-weaver-beast")
# High-performance image with all necessary dependencies
# Using CUDA 12.1 base for maximum compatibility with modern diffusion models
image = (
Image.debian_slim(python_version="3.10")
.apt_install("git", "libgl1-mesa-glx", "libglib2.0-0")
.pip_install(
"gradio==4.44.0",
"diffusers==0.30.0",
"transformers==4.44.0",
"accelerate==0.33.0",
"xformers",
"opencv-python-headless",
"pillow",
"safetensors",
"huggingface_hub",
"einops",
"compel",
extra_index_url="https://download.pytorch.org/whl/cu121",
)
.pip_install(
"torch",
"torchvision",
"torchaudio",
extra_index_url="https://download.pytorch.org/whl/cu121",
)
.add_local_dir(
"/workspace/NEXUS_Visual_Weaver",
remote_path="/root/nexus",
)
.env({
"HF_HUB_ENABLE_HF_TRANSFER": "1", # Fast downloads
"CUDA_VISIBLE_DEVICES": "0",
})
)
# Define the Beast Mode Function
@app.function(
image=image,
gpu="A100-80GB", # THE ROAR: 80GB VRAM A100
timeout=14400, # 4 hours (matching your remaining time)
secrets=[Secret.from_name("huggingface-secret", required_keys=["HF_TOKEN"])],
max_containers=20, # High concurrency
)
@modal.concurrent(max_inputs=10)
@modal.asgi_app()
def run_gradio_app():
import os
import sys
# Add the nexus module to path
sys.path.insert(0, "/root/nexus/src")
os.chdir("/root/nexus")
# Import the main app file
# The original repo uses 'app.py' which defines 'demo' as gr.Blocks
try:
import app as nexus_app
except ImportError:
raise ImportError("Could not import app.py. Ensure NEXUS_Visual_Weaver is mounted correctly.")
# The NEXUS Visual Weaver app defines the interface as 'demo' (gr.Blocks)
# We return this object directly for Modal's ASGI handler
if hasattr(nexus_app, 'demo'):
return nexus_app.demo
else:
raise AttributeError("Could not find Gradio app object 'demo' in app.py")