ComfyUI - 在服务器中部署 AIGC 绘画的 ComfyUI 工具 教程

欢迎关注我的CSDN:https://spike.blog.csdn.net/

本文地址:https://spike.blog.csdn.net/article/details/141140498

免责声明:本文来源于个人知识与公开资料,仅用于学术交流,欢迎讨论,不支持转载。


ComfyUI 是功能强大且高度模块化的 AI 绘画工具,基于 Stable Diffusion 技术,采用节点式工作流界面,使用户能够更直观地控制图像生成过程。特点是模块化设计,允许用户通过拖放节点来创建和调整工作流,极大地提高了灵活性和可定制性。速度更快,灵活的组建工作流,专业团队的需求,节点式编辑。

GitHub: https://github.com/comfyanonymous/ComfyUI

bash 复制代码
git clone https://github.com/comfyanonymous/ComfyUI

配置 conda 环境

bash 复制代码
conda create -n comfyui python=3.9
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117
pip install numpy==1.26.4

Numpy 必须是 1.x 版本,否则报错:

bash 复制代码
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.

安装其他库:

bash 复制代码
pip install -r requirements.txt

启动任务,默认端口是 8188:

bash 复制代码
python3 main.py --listen 0.0.0.0
# nohup python3 -u main.py --listen 0.0.0.0 > nohup.run_main.out &
# ps -aux | grep "main.py"
# kill -9 [pid]

启动成功的日志,例如 http://[your ip]:8188/:

bash 复制代码
Total VRAM 81052 MB, total RAM 1031523 MB
pytorch version: 1.13.1+cu117
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA A100-SXM4-80GB : 
Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention
[Prompt Server] web root: workspace_comfyui/ComfyUI/web

Import times for custom nodes:
   0.0 seconds: workspace_comfyui/ComfyUI/custom_nodes/websocket_image_save.py

Starting server

To see the GUI go to: http://0.0.0.0:8188

ComfyUI 启动成功:

ComfyUI 支持复用 Stable Diffusion WebUI 的配置,修改 extra_model_paths.yaml

yaml 复制代码
a111:
    base_path: workspace/stable_diffusion_webui/

    checkpoints: models/Stable-diffusion
    configs: models/Stable-diffusion
    vae: models/VAE
    loras: |
         models/Lora
         models/LyCORIS
    upscale_models: |
                  models/ESRGAN
                  models/RealESRGAN
                  models/SwinIR
    embeddings: embeddings
    hypernetworks: models/hypernetworks
    controlnet: extensions/sd-webui-controlnet/models

注意:需要修改 controlnet 的默认模型路径,这个部分与默认不一致,其他逐个验证即可。

workspace_comfyui/ComfyUI/custom_nodes 文件夹中,安装自定义 ComfyUI-Manager 插件:

第 1 次启动时,需要等待安装配置,## ComfyUI-Manager: installing dependencies. (GitPython)

安装翻译插件:AIGODLIKE-ComfyUI-Translation,重启服务即可:

bash 复制代码
cd custom_nodes
git clone https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git

将 ComfyUI 页面翻译成中文:

点击 Queue Prompt,即可运行程序。

提示词:

  • beautiful scenery nature glass bottle landscape, purple galaxy bottle,
  • 美丽的风景自然玻璃瓶景观,紫色银河瓶。

如图所示:

运行报错:

bash 复制代码
  File "workspace_comfyui/ComfyUI/custom_nodes/ComfyUI-Manager/glob/manager_server.py", line 1710, in <lambda>
    threading.Thread(target=lambda: asyncio.run(default_cache_update())).start()
  File "envs/comfyui/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
	File "aiohttp/client_reqrep.py", line 1014, in start
    self._continue = None
  File "aiohttp/helpers.py", line 713, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError

原因是 GitHub 国内访问异常,使用代理即可,参考源码 ComfyUI-Manager/glob/manager_server.py#1688,即:

python 复制代码
async def default_cache_update():
    async def get_cache(filename):
        # uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/' + filename
        uri = 'https://mirror.ghproxy.com/https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/' + filename
        cache_uri = str(core.simple_hash(uri)) + '_' + filename
        cache_uri = os.path.join(core.cache_dir, cache_uri)

        json_obj = await core.get_data(uri, True)

        with core.cache_lock:
            with open(cache_uri, "w", encoding='utf-8') as file:
                json.dump(json_obj, file, indent=4, sort_keys=True)
                print(f"[ComfyUI-Manager] default cache updated: {uri}")

    a = get_cache("custom-node-list.json")
    b = get_cache("extension-node-map.json")
    c = get_cache("model-list.json")
    d = get_cache("alter-list.json")
    e = get_cache("github-stats.json")

    await asyncio.gather(a, b, c, d, e)


threading.Thread(target=lambda: asyncio.run(default_cache_update())).start()

修改 uri,增加 https://mirror.ghproxy.com/ 前缀,即可

参考:https://github.com/runningcheese/MirrorSite

相关推荐
春末的南方城市41 分钟前
VidSketch:具有扩散控制的手绘草图驱动视频生成
人工智能·深度学习·计算机视觉·aigc
Francek Chen1 小时前
【大模型科普】AIGC技术发展与应用实践(一文读懂AIGC)
人工智能·深度学习·语言模型·大模型·aigc
kakaZhui2 小时前
【多模态大模型】GLM-4-Voice端到端语音交互机器人VoiceAI
人工智能·chatgpt·机器人·aigc·llama
LittleNyima8 小时前
【代码解读】阿里最新开源视频生成模型 Wan 2.1 实现解析
人工智能·stable diffusion·aigc·音视频
寻道码路11 小时前
深度剖析 Video-RAG:厦门大学和罗切斯特大学联合推出的一种用于长视频理解的检索增强生成技术
人工智能·语言模型·开源·aigc·音视频·ai编程
AIGC安琪14 小时前
AI绘画(Stable Diffusion)喂饭级教程
人工智能·ai作画·stable diffusion·aigc·美女
乱世刀疤14 小时前
AI绘画软件Stable Diffusion详解教程(2):Windows系统本地化部署操作方法(专业版)
ai作画·stable diffusion
春末的南方城市15 小时前
CineMaster: 用于电影文本到视频生成的 3D 感知且可控的框架。
人工智能·数码相机·计算机视觉·语言模型·aigc·图像生成
EdisonZhou15 小时前
基于Microsoft.Extensions.VectorData实现语义搜索
llm·aigc·.net core
隔岸观火烧连营15 小时前
JBoltAI_SpringBoot如何基于Deepseek官网API区分 R1大模型深度思考和具体回答的内容?
spring·aigc