【ComfyUI】安装 之 window版

文章目录

序言

由于stable diffusion web ui无法做到对流程进行控制,只是点击个生成按钮后,一切都交给AI来处理。但是用于生产生活是需要精细化对各个流程都要进行控制的。

故也就有个今天的猪脚:Comfyui

步骤

  1. 下载comfyui项目
  2. 配置大模型和vae
  3. 下载依赖组件
  4. 启动

下载comfyUI

官网地址:https://github.com/comfyanonymous/ComfyUI

将项目下载到自己喜欢的目录下,下面是我的:

shell 复制代码
yutao@yutao MINGW64 /e/openai/project
$ git clone https://github.com/comfyanonymous/ComfyUI.git

配置大模型和vae

  1. 在ComfyUI\models\checkpoints中放大模型文件
  2. 在ComfyUI\models\vae中放vae文件。

但是 ,我们学stable diffusion基本都是从stable diffusion webui开始的,所以我们其实不需要再额外的下载,checkpoint和vae,而是共用他们。

ComfyUI的作者提供了配置方法:

  1. 修改extra_model_paths.yaml.example文件重命名为:extra_model_paths.yaml
  2. 打开文件,将里面的base_path进行修改:
    以下是我的stable-diffusion-webui的路径
yaml 复制代码
a111:
    base_path: E:\openai\project\stable-diffusion-webui

保存退出。

下载依赖组件

在ComfyUI中调出命令行(将文件夹路径上敲cmd,回车即可)中执行:

shell 复制代码
E:\openai\project\ComfyUI>pip install -r requirements.txt

就会开始下载所需的依赖组件。

启动

命令:python main.py

python 复制代码
E:\openai\project\ComfyUI>python main.py

浏览器访问地址:http://127.0.0.1:8188

最左边,因为我之前玩stable diffusion时候已经下载好了guofeng3大模型。所以load checkpoint 里面我显示的是guofeng3.

大模型,我下载的是guofeng3。

放到models/checkpoints文件夹里,例如:E:\openai\project\ComfyUI\models\checkpoints。

生成图片

因为默认参数就可以生成一个花瓶,点击右上角的Queue Prompt。

但是我的电脑总是不是那么顺利。

详细描述文章:【ComfyUI】RuntimeError: CUDA error: operation not supported

报了如下错误:

python 复制代码
got prompt
model_type EPS
adm 0
making attention of type 'vanilla-pytorch' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla-pytorch' with 512 in_channels
missing {'cond_stage_model.text_projection', 'cond_stage_model.logit_scale'}
left over keys: dict_keys(['cond_stage_model.transformer.text_model.embeddings.position_ids', 'model_ema.decay', 'model_ema.num_updates'])
loading new
loading new
loading in lowvram mode 1842.6899042129517
!!! Exception during processing !!!
Traceback (most recent call last):
  File "E:\openai\project\ComfyUI\execution.py", line 152, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\openai\project\ComfyUI\execution.py", line 82, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\openai\project\ComfyUI\execution.py", line 75, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\openai\project\ComfyUI\nodes.py", line 1236, in sample
    return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\openai\project\ComfyUI\nodes.py", line 1206, in common_ksampler
    samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\openai\project\ComfyUI\comfy\sample.py", line 81, in sample
    comfy.model_management.load_models_gpu([model] + models, comfy.model_management.batch_area_memory(noise.shape[0] * noise.shape[2] * noise.shape[3]) + inference_memory)
  File "E:\openai\project\ComfyUI\comfy\model_management.py", line 394, in load_models_gpu
    cur_loaded_model = loaded_model.model_load(lowvram_model_memory)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\openai\project\ComfyUI\comfy\model_management.py", line 288, in model_load
    accelerate.dispatch_model(self.real_model, device_map=device_map, main_device=self.device)
  File "D:\Program Files\Python\Lib\site-packages\accelerate\big_modeling.py", line 391, in dispatch_model
    attach_align_device_hook_on_blocks(
  File "D:\Program Files\Python\Lib\site-packages\accelerate\hooks.py", line 532, in attach_align_device_hook_on_blocks
    add_hook_to_module(module, hook)
  File "D:\Program Files\Python\Lib\site-packages\accelerate\hooks.py", line 155, in add_hook_to_module
    module = hook.init_hook(module)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Program Files\Python\Lib\site-packages\accelerate\hooks.py", line 253, in init_hook
    set_module_tensor_to_device(module, name, self.execution_device)
  File "D:\Program Files\Python\Lib\site-packages\accelerate\utils\modeling.py", line 307, in set_module_tensor_to_device
    new_value = old_value.to(device)
                ^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA error: operation not supported
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

其实就是说,我当前电脑的GPU或硬件,并不支持当前CUDA中的某些操作。

解决办法

官方提供了两种解决策略。

方式一:黑名单策略

加完后,再重启。发现还是不行。

方式二:启动时添加--disable-cuda-malloc

shell 复制代码
# 注意--disable-cuda-malloc
E:\openai\project\ComfyUI>python main.py --disable-cuda-malloc

最后,通过方式二,得以解决。


参考地址:

https://github.com/comfyanonymous/ComfyUI#manual-install-windows-linux

Stable Diffusion ComfyUI 入门感受

相关推荐
Sayai8 小时前
ComfyUI+Flux ControlNet 实战:一张图拆线稿和深度图,双模型重构画面(12G 显存实测,附模型与工作流)
人工智能·重构·aigc·flux·controlnet·comfyui
Sayai1 天前
ComfyUI+MiniMax H3 文生视频实测:12G 显存跑 21G 模型,5 分钟出片自带音效(附模型与工作流)
人工智能·aigc·音视频·文生视频·comfyui·minimax
Sayai1 天前
ComfyUI+MiniMax H3 图生视频实战:一张静态图 5 分钟变带音效大片(12G 显存,附工作流)
人工智能·aigc·音视频·comfyui·图生视频·minimax
瑶山2 天前
stable-diffusion.cpp 参数全集整理(sd-cli.exe / sd-server.exe)
java·数据库·stable diffusion·参数全集
GPU实战笔记2 天前
云端 ComfyUI 访问入口选择:本地私密访问与对外开放端口
comfyui·远程访问·ssh隧道·端口开放·rtx4090·gpu云计算
云间月13142 天前
Stable Diffusion WebUI完整部署:从本地出图到7860远程访问
stable diffusion
霸道流氓气质2 天前
Java调用StableDiffusion/ComfyUI图像生成:DAG工作流编排、WebSocket实时进度与Flux模型集成的生产级实战
java·websocket·stable diffusion
AIGC小尼3 天前
本地 AI 漫剧流水线模型缓存与特征向量持久化:IPAdapter 预编码、特征池复用与内存池管理实战
人工智能·spring boot·缓存·预编码算法·comfyui·ai漫剧
Sayai4 天前
ComfyUI 一键换衣 2.0:FLUX Fill 服装一致性工作流全模型清单与新版避坑指南(12G 显存实测跑通)
人工智能·aigc·flux·图生图·comfyui
粥里有勺糖4 天前
Windows 搭建 ComfyUI 环境 | 小白也能直接上手
ai·经验总结·comfyui