全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

ComfyUI 部署和生图模型加载实践教程

最近更新时间:2025-08-13 11:20:06

概述

模型在线服务 MOS(Model Online Service),帮助用户快速将一个或多个模型部署为在线服务,通过 API 接口调用的方式将 AI 集成到自身业务应用中,而无需关心底层IT基础设施的管理和维护。平台提供了丰富的资源供给、灵活的计费方式以及各种开发和调试工具,使得模型在线服务变得既强大又易于管理,从而更好地满足业务创新对 AI 的需求。

本教程将带你体验基于 MOS 部署 ComfyUI 以及配置生图模型到生成第一张美图。

第一步 创建文件共享服务

已创建过文件共享服务请略过(多个服务只需要开通一次文件共享服务)。

前往地址 https://kenc.console.ksyun.com/#/simple/fileShare

创建文件共享服务,节点选择 厦门电信41 节点,网络选择 经典网络 选项,其他按需,点击【确认订单】。

第二步 将模型文件导入文件共享服务

前往地址 https://mos.console.ksyun.com/#/modelManage

在公共模型列表找到 stable-diffusion-3.5-large-turbo,点击【导入】按钮。

选择刚才创建的文件共享服务,点击【确认】即可。

点击右上角【导入历史】

查看模型文件导入进度,不同的模型耗时差异很大,主要看模型文件的大小,本次部署的模型大概会6分钟左右的时间即可导入成功。

第三步 部署服务

点击 MOS 左侧菜单【服务】或前往地址 https://mos.console.ksyun.com/#/serverManage

点击左上角【部署服务】

资源部署信息选择如下

属性

属性值

备注

资源类型

公共资源组

地域

厦门电信41

算力类型

GPU

算力规格

MOS.NM1IN.32C128G.2A9

模型服务信息,配置如下

属性

属性值

备注

服务名称

comfyui

字母开头,支持数字、小写字母以及中横线(-),不得以中横线开始或者结尾,长度位 3~63 位

镜像

公共镜像

library/comfyui:v0.3.26

模型配置

NFS:上述导入模型的文件共享服务实例

NFS源路径(导入成功后可下拉选择):stable-diffusion-3.5-large-turbo/

挂载路径:/data/stable-diffusion-3.5-large-turbo

运行命令

python3 main.py --port 8000 --listen 0.0.0.0

端口号

8000

共享内存

10

实例数量为 1 即可。点击【部署】。

首次部署需要等待 8 分钟左右,之后部署需要 2 分钟左右,服务状态就会转换为“运行中”。

访问服务

点击 MOS 左侧菜单【服务】或前往服务列表 https://mos.console.ksyun.com/#/serverManage

点击服务列表或详情【调用信息】,获取服务域名,例如 https://comfyui.ksymos.com/

使用浏览器打开服务域名,此时ComfyUI已经部署好了,可以正常访问。

配置模型

该案例中导入的模型已经给大家准备好了ComfyUI生图所依赖的模型文件,文件及目录如下:

/data/stable-diffusion-3.5-large-turbo/sd3.5_large_turbo.safetensors
/data/stable-diffusion-3.5-large-turbo/text_encoders/clip_g.safetensors
/data//stable-diffusion-3.5-large-turbo/text_encoders/clip_l.safetensors
/data/stable-diffusion-3.5-large-turbo/text_encoders/t5xxl_fp8_e4m3fn.safetensors

注意,“/data/stable-diffusion-3.5-large-turbo/”是模型文件导入到文件共享服务中的目录。

点击 MOS 左侧菜单【服务】或前往服务列表 https://mos.console.ksyun.com/#/serverManage

点击服务名称,进入服务详情-》服务实例,点击列表操作【进入容器】,运行以下命令配置ComfyUI文生图/图生图所依赖的模型文件:

ln -s /data/stable-diffusion-3.5-large-turbo/sd3.5_large_turbo.safetensors /ComfyUI/models/checkpoints/sd3.5_large_turbo.safetensors && \
ln -s /data/stable-diffusion-3.5-large-turbo/text_encoders/clip_g.safetensors   /ComfyUI/models/clip/clip_g.safetensors && \
ln -s /data//stable-diffusion-3.5-large-turbo/text_encoders/clip_l.safetensors   /ComfyUI/models/clip/clip_l.safetensors && \
ln -s /data/stable-diffusion-3.5-large-turbo/text_encoders/t5xxl_fp8_e4m3fn.safetensors   /ComfyUI/models/clip/t5xxl_fp8_e4m3fn.safetensors

执行该命令后,进入 ComfyUI ,刷新页面。

创建第一个 workflow 模板

创建第一个 workflow 模板,命名为 SD.json,内容如下:

{
  "last_node_id": 300,
  "last_link_id": 605,
  "nodes": [
    {
      "id": 70,
      "type": "ConditioningSetTimestepRange",
      "pos": [
        126,
        252
      ],
      "size": {
        "0": 317.4000244140625,
        "1": 82
      },
      "flags": {},
      "order": 7,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 93,
          "slot_index": 0
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            92
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningSetTimestepRange"
      },
      "widgets_values": [
        0,
        0.1
      ]
    },
    {
      "id": 68,
      "type": "ConditioningSetTimestepRange",
      "pos": [
        126,
        126
      ],
      "size": {
        "0": 317.4000244140625,
        "1": 82
      },
      "flags": {},
      "order": 9,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 90
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            91
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningSetTimestepRange"
      },
      "widgets_values": [
        0.1,
        1
      ]
    },
    {
      "id": 67,
      "type": "ConditioningZeroOut",
      "pos": [
        -126,
        126
      ],
      "size": {
        "0": 211.60000610351562,
        "1": 26
      },
      "flags": {},
      "order": 8,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning",
          "type": "CONDITIONING",
          "link": 597
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            90
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningZeroOut"
      }
    },
    {
      "id": 71,
      "type": "CLIPTextEncode",
      "pos": [
        -1010,
        252
      ],
      "size": [
        351.8130934034689,
        195.5754530459866
      ],
      "flags": {},
      "order": 5,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 94
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            93,
            597
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPTextEncode"
      },
      "widgets_values": [
        ""
      ],
      "color": "#322",
      "bgcolor": "#533"
    },
    {
      "id": 6,
      "type": "CLIPTextEncode",
      "pos": [
        -1008,
        2
      ],
      "size": [
        342.83352734520565,
        177.20867231021555
      ],
      "flags": {},
      "order": 4,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 5
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            569
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPTextEncode"
      },
      "widgets_values": [
        "beautiful scenery nature glass bottle landscape, purple galaxy bottle,"
      ],
      "color": "#232",
      "bgcolor": "#353"
    },
    {
      "id": 13,
      "type": "ModelSamplingSD3",
      "pos": [
        126,
        -504
      ],
      "size": {
        "0": 315,
        "1": 58
      },
      "flags": {
        "collapsed": false
      },
      "order": 6,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 445
        }
      ],
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            568
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ModelSamplingSD3"
      },
      "widgets_values": [
        3
      ]
    },
    {
      "id": 69,
      "type": "ConditioningCombine",
      "pos": [
        504,
        126
      ],
      "size": {
        "0": 228.39999389648438,
        "1": 46
      },
      "flags": {},
      "order": 10,
      "mode": 0,
      "inputs": [
        {
          "name": "conditioning_1",
          "type": "CONDITIONING",
          "link": 91
        },
        {
          "name": "conditioning_2",
          "type": "CONDITIONING",
          "link": 92
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            604
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ConditioningCombine"
      }
    },
    {
      "id": 8,
      "type": "VAEDecode",
      "pos": [
        1386,
        -504
      ],
      "size": {
        "0": 210,
        "1": 46
      },
      "flags": {},
      "order": 12,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 572
        },
        {
          "name": "vae",
          "type": "VAE",
          "link": 605
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            274
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "VAEDecode"
      }
    },
    {
      "id": 50,
      "type": "PreviewImage",
      "pos": [
        1764,
        -504
      ],
      "size": {
        "0": 616.689697265625,
        "1": 613.84130859375
      },
      "flags": {},
      "order": 13,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 274
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    },
    {
      "id": 135,
      "type": "EmptySD3LatentImage",
      "pos": [
        -1008,
        -252
      ],
      "size": [
        315,
        106
      ],
      "flags": {},
      "order": 0,
      "mode": 0,
      "inputs": [],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            598
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "EmptySD3LatentImage"
      },
      "widgets_values": [
        1024,
        1024,
        1
      ]
    },
    {
      "id": 105,
      "type": "Note",
      "pos": [
        -1260,
        -252
      ],
      "size": [
        210,
        110.1894832228611
      ],
      "flags": {},
      "order": 1,
      "mode": 0,
      "properties": {
        "text": ""
      },
      "widgets_values": [
        "Make sure the resolution is multiple of 64 pixels and adds up to around 1 megapixel. "
      ],
      "color": "#432",
      "bgcolor": "#653"
    },
    {
      "id": 11,
      "type": "TripleCLIPLoader",
      "pos": [
        -2016,
        -252
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 2,
      "mode": 0,
      "outputs": [
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [
            5,
            94
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "TripleCLIPLoader"
      },
      "widgets_values": [
        "clip_g_sdxl_base.safetensors",
        "clip_l_sdxl_base.safetensors",
        "t5xxl.safetensors"
      ]
    },
    {
      "id": 294,
      "type": "KSampler",
      "pos": [
        882,
        -504
      ],
      "size": [
        378,
        504
      ],
      "flags": {},
      "order": 11,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 568
        },
        {
          "name": "positive",
          "type": "CONDITIONING",
          "link": 569
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "link": 604
        },
        {
          "name": "latent_image",
          "type": "LATENT",
          "link": 598
        }
      ],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            572
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "KSampler"
      },
      "widgets_values": [
        349467226218834,
        "randomize",
        4,
        1,
        "dpmpp_2m",
        "sgm_uniform",
        1
      ]
    },
    {
      "id": 4,
      "type": "CheckpointLoaderSimple",
      "pos": [
        -2016,
        -504
      ],
      "size": {
        "0": 632.6060180664062,
        "1": 98
      },
      "flags": {},
      "order": 3,
      "mode": 0,
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            445
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": null,
          "shape": 3
        },
        {
          "name": "VAE",
          "type": "VAE",
          "links": [
            605
          ],
          "shape": 3,
          "slot_index": 2
        }
      ],
      "properties": {
        "Node name for S&R": "CheckpointLoaderSimple"
      },
      "widgets_values": [
        "sd3.5_large_turbo.safetensors"
      ]
    }
  ],
  "links": [
    [
      5,
      11,
      0,
      6,
      0,
      "CLIP"
    ],
    [
      90,
      67,
      0,
      68,
      0,
      "CONDITIONING"
    ],
    [
      91,
      68,
      0,
      69,
      0,
      "CONDITIONING"
    ],
    [
      92,
      70,
      0,
      69,
      1,
      "CONDITIONING"
    ],
    [
      93,
      71,
      0,
      70,
      0,
      "CONDITIONING"
    ],
    [
      94,
      11,
      0,
      71,
      0,
      "CLIP"
    ],
    [
      274,
      8,
      0,
      50,
      0,
      "IMAGE"
    ],
    [
      445,
      4,
      0,
      13,
      0,
      "MODEL"
    ],
    [
      568,
      13,
      0,
      294,
      0,
      "MODEL"
    ],
    [
      569,
      6,
      0,
      294,
      1,
      "CONDITIONING"
    ],
    [
      572,
      294,
      0,
      8,
      0,
      "LATENT"
    ],
    [
      597,
      71,
      0,
      67,
      0,
      "CONDITIONING"
    ],
    [
      598,
      135,
      0,
      294,
      3,
      "LATENT"
    ],
    [
      604,
      69,
      0,
      294,
      2,
      "CONDITIONING"
    ],
    [
      605,
      4,
      2,
      8,
      1,
      "VAE"
    ]
  ],
  "groups": [],
  "config": {},
  "extra": {
    "ds": {
      "scale": 0.3452271214393102,
      "offset": [
        2070.782739748983,
        1025.5502104141715
      ]
    }
  },
  "version": 0.4
}

进入 ComfyUI 页面,点击左上角工作流-》打开,选择 SD.json 文件。

修改三重CLIP加载器修改内容如下图所示:

模型文件没有

修改正面条件和负面条件如下图所示

内容如下,可以直接复制:

正向提示词:
score_9, score_8_up, 1girl, alice cartelet, from below, looking at viewer, light smile, standing, leaning forward, sunset, cloudy sky, flower, white thighhighs, hair ornament, white collared shirt, cardigan, open cardigan, striped bow, blue pleated skirt, mary janes

反向提示词:
score_4, score_5, score_6, low quality, bad anatomy, bad proportions, extra legs, deformed anatomy, messy color, deformed fingers, distracted, hyperrealistic, source_furry, source_pony, source_cartoon,

点击中下部的【执行】按钮,看到工作流在执行,直到执行完最后一步(大概等1分钟左右),就可以看到生成的图片了,第一次生成可能比较慢,之后就会很快。

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈