diff --git a/comfy/cli_args.py b/comfy/cli_args.py index 2f30b72d2981..ffb15becf484 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -205,6 +205,8 @@ def is_valid_directory(path: str) -> str: parser.add_argument("--enable-compress-response-body", action="store_true", help="Enable compressing response body.") +parser.add_argument("--num-workers", type=int, default=1, help="Set the number of worker threads to process the queue (default: 1). Increase this for better concurrency but be aware of GPU memory limitations.") + parser.add_argument( "--comfy-api-base", type=str, diff --git a/main.py b/main.py index e1b0f1620bbc..a02e8c5a4fb4 100644 --- a/main.py +++ b/main.py @@ -336,7 +336,10 @@ def start_comfyui(asyncio_loop=None): prompt_server.add_routes() hijack_progress(prompt_server) - threading.Thread(target=prompt_worker, daemon=True, args=(prompt_server.prompt_queue, prompt_server,)).start() + num_workers = max(1, args.num_workers) + logging.info(f"Starting {num_workers} worker thread(s) for queue processing") + for i in range(num_workers): + threading.Thread(target=prompt_worker, daemon=True, args=(prompt_server.prompt_queue, prompt_server,), name=f"PromptWorker-{i+1}").start() if args.quick_test_for_ci: exit(0) diff --git a/requirements.txt b/requirements.txt index 249c36dee8c1..3b9b0e6dbed6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,29 +1,198 @@ -comfyui-frontend-package==1.28.8 -comfyui-workflow-templates==0.2.11 -comfyui-embedded-docs==0.3.1 -torch -torchsde -torchvision -torchaudio -numpy>=1.25.0 -einops -transformers>=4.37.2 -tokenizers>=0.13.3 -sentencepiece -safetensors>=0.4.2 -aiohttp>=3.11.8 -yarl>=1.18.0 -pyyaml -Pillow -scipy -tqdm -psutil -alembic -SQLAlchemy -av>=14.2.0 +#################################### +# 注意,如果不慎安装了GPU版本,要: +# 1. 卸载现有的 torch 相关包 +# pip uninstall torch torchvision torchaudio triton -y +# 2. (可选)安装 CPU 版本的 PyTorch +# pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cpu +#################################### -#non essential dependencies: -kornia>=0.7.1 -spandrel -pydantic~=2.0 -pydantic-settings~=2.0 + +--extra-index-url https://download.pytorch.org/whl/cpu + +aiofiles==24.1.0 +aiohappyeyeballs==2.6.1 +aiohttp==3.11.8 +aiohttp_socks==0.10.1 +aiosignal==1.4.0 +aiosmtplib==3.0.1 +alembic==1.16.4 +amqp==5.3.1 +annotated-types==0.7.0 +anyio==3.7.1 +asgiref==3.9.1 +async-timeout==4.0.3 +attrs==25.3.0 +autobahn==24.4.2 +Automat==25.4.16 +av==14.2.0 +bcrypt==4.3.0 +billiard==4.2.1 +captcha==0.5.0 +celery==5.5.3 +certifi==2025.7.14 +cffi==1.17.1 +chardet==5.2.0 +charset-normalizer==3.4.2 +click==8.2.1 +click-didyoumean==0.3.1 +click-plugins==1.1.1.2 +click-repl==0.3.0 +comfyui-embedded-docs==0.3.0 +comfyui_frontend_package==1.28.8 +comfyui_workflow_templates==0.2.4 +constantly==23.10.4 +cos-python-sdk-v5==1.9.25 +crcmod==1.7 +cryptography==45.0.5 +daphne==4.2.1 +dashscope==1.14.1 +decorator==4.4.2 +distro==1.9.0 +dnspython==2.7.0 +ecdsa==0.19.1 +einops==0.8.1 +email-validator==2.1.0 +fastapi==0.104.1 +fastapi-pagination==0.13.3 +filelock==3.19.1 +flower==2.0.1 +frozenlist==1.7.0 +fsspec==2025.9.0 +gitdb==4.0.12 +GitPython==3.1.45 +google-cloud-storage==2.18.2 +greenlet==3.2.3 +gunicorn==23.0.0 +h11==0.16.0 +h2==4.2.0 +hf-xet==1.1.10 +hpack==4.1.0 +http-client==0.1.22 +httpcore==1.0.9 +httptools==0.6.4 +httpx==0.25.2 +huggingface-hub==0.35.1 +humanize==4.13.0 +Hypercorn==0.17.3 +hyperframe==6.1.0 +hyperlink==21.0.0 +idna==3.10 +imageio==2.37.0 +imageio-ffmpeg==0.6.0 +incremental==24.7.2 +Jinja2==3.1.6 +jiter==0.10.0 +jsonpatch==1.33 +jsonpointer==3.0.0 +jsonschema==4.25.1 +jsonschema-specifications==2025.9.1 +kombu==5.5.4 +kornia==0.7.1 +langchain==0.3.27 +langchain-core==0.3.74 +langchain-text-splitters==0.3.9 +langgraph==0.6.5 +langgraph-checkpoint==2.1.1 +langgraph-prebuilt==0.6.4 +langgraph-sdk==0.2.0 +langsmith==0.4.14 +Mako==1.3.10 +markdown-it-py==4.0.0 +MarkupSafe==3.0.2 +matrix-nio==0.25.2 +mdurl==0.1.2 +moviepy==1.0.3 +mpmath==1.3.0 +multidict==6.6.4 +mysql-connector-python==9.4.0 +networkx==3.5 +numpy==2.3.3 +openai==1.97.1 +orjson==3.11.2 +ormsgpack==1.10.0 +packaging==25.0 +passlib==1.7.4 +Pillow==10.0.1 +priority==2.0.0 +proglog==0.1.12 +prometheus_client==0.22.1 +prompt_toolkit==3.0.52 +propcache==0.3.2 +psutil==7.1.0 +pyasn1==0.6.1 +pyasn1_modules==0.4.2 +pycparser==2.22 +pycryptodome==3.23.0 +pycurl==7.45.7 +pydantic==2.11.7 +pydantic_core==2.33.2 +pydantic-settings==2.10.1 +pydub==0.25.1 +PyGithub==2.8.1 +Pygments==2.19.2 +PyJWT==2.10.1 +PyMySQL==1.1.0 +PyNaCl==1.6.0 +pyOpenSSL==25.1.0 +python-dateutil==2.9.0.post0 +python-dotenv==1.0.0 +python-jose==3.3.0 +python-multipart==0.0.6 +python-socks==2.7.2 +pytz==2025.2 +PyYAML==6.0.2 +redis==6.2.0 +referencing==0.37.0 +regex==2025.9.18 +requests==2.31.0 +requests-toolbelt==1.0.0 +rich==14.2.0 +rpds-py==0.28.0 +rsa==4.9.1 +safetensors==0.4.2 +scipy==1.16.2 +sentencepiece==0.2.1 +service-identity==24.2.0 +shellingham==1.5.4 +six==1.17.0 +smmap==5.0.2 +sniffio==1.3.1 +soundfile==0.13.1 +spandrel==0.4.1 +SQLAlchemy==2.0.41 +starlette==0.27.0 +sympy==1.14.0 +tenacity==9.1.2 +tokenizers==0.15.2 +toml==0.10.2 +torch==2.4.0 +torchaudio==2.4.0 +torchsde==0.2.6 +torchvision==0.19.0 +tornado==6.5.2 +tqdm==4.67.1 +trampoline==0.1.2 +transformers==4.37.2 +Twisted==25.5.0 +txaio==25.6.1 +typer==0.20.0 +typing_extensions==4.14.1 +typing-inspection==0.4.1 +tzdata==2025.2 +uni-sdk==0.2.0 +unisms==0.0.7 +unpaddedbase64==2.1.0 +urllib3==2.5.0 +uv==0.9.5 +uvicorn==0.24.0 +uvloop==0.21.0 +vine==5.1.0 +watchfiles==1.1.0 +wcwidth==0.2.13 +websockets==15.0.1 +wsproto==1.2.0 +xmltodict==0.14.2 +xxhash==3.5.0 +yarl==1.18.0 +zope.interface==7.2 +zstandard==0.23.0