48 lines
2.5 KiB
Python
48 lines
2.5 KiB
Python
# 文件名 comfyui_v2.py
|
|
import subprocess
|
|
|
|
import modal
|
|
|
|
image = ( # build up a Modal Image to run ComfyUI, step by step
|
|
modal.Image.debian_slim( # start from basic Linux with Python
|
|
python_version="3.10"
|
|
)
|
|
.apt_install("git", "gcc", "libportaudio2", "ffmpeg")
|
|
.pip_install("fastapi[standard]==0.115.4") # install web dependencies
|
|
.pip_install("comfy_cli==0.0.0",
|
|
index_url="https://packages-1747622887395:0ee15474ccd7b27b57ca63a9306327678e6c2631@g-ldyi2063-pypi.pkg.coding.net/dev/packages/simple")
|
|
.run_commands( # use comfy-cli to install ComfyUI and its dependencies
|
|
"comfy --skip-prompt install --fast-deps --nvidia --version 0.3.40"
|
|
)
|
|
.pip_install_from_pyproject("./pyproject_comfyui.toml")
|
|
.run_commands("comfy node install https://e.coding.net/g-ldyi2063/dev/ComfyUI-CustomNode.git", force_build=True)
|
|
.run_commands("comfy node install https://github.com/yolain/ComfyUI-Easy-Use.git", force_build=True)
|
|
# .add_local_file("ext/webhook_forward.py", "/root/comfy/ComfyUI/custom_nodes/webhook_forward.py", copy=True)
|
|
# .add_local_file("ext/prompt_id_generator.py", "/root/comfy/ComfyUI/custom_nodes/prompt_id_generator.py", copy=True)
|
|
# .add_local_file("ext/load_image_pro.py", "/root/comfy/ComfyUI/custom_nodes/load_image_pro.py", copy=True)
|
|
# .add_local_file('ext/image.py', '/root/comfy/ComfyUI/custom_nodes/image.py', copy=True)
|
|
# .add_local_file('ext/nodes_bfl.py', '/root/comfy/ComfyUI/comfy_api_nodes/nodes_bfl.py', copy=True)
|
|
# # .add_local_file('ext/s3_utils.py', '/root/comfy/ComfyUI/custom_nodes/s3_utils.py', copy=True)
|
|
# .add_local_file('ext/cos_utils.py', '/root/comfy/ComfyUI/custom_nodes/cos_utils.py', copy=True)
|
|
# .add_local_file('ext/random_line.py', '/root/comfy/ComfyUI/custom_nodes/random_line.py', copy=True)
|
|
)
|
|
app = modal.App(name="test", image=image)
|
|
vol = modal.Volume.from_name("test", environment_name="dev", create_if_missing=True)
|
|
custom_secret = modal.Secret.from_name("comfyui-custom-secret", environment_name="dev")
|
|
|
|
|
|
# modal deploy .\comfyui_v2.py --name dev
|
|
@app.cls(
|
|
max_containers=1, # limit interactive session to 1 container
|
|
# gpu="L40S", # good starter GPU for inference
|
|
volumes={"/cache": vol}, # mounts our cached models
|
|
secrets=[custom_secret]
|
|
)
|
|
@modal.concurrent(
|
|
max_inputs=10
|
|
) # required for UI startup process which runs several API calls concurrently
|
|
@modal.web_server(8000, startup_timeout=60)
|
|
class ModalComfy():
|
|
|
|
subprocess.Popen("comfy launch -- --cpu --listen 0.0.0.0 --port 8000", shell=True)
|