开发者社区 > 大数据与机器学习 > 人工智能平台PAI > 正文

“AIGC Stable Diffusion文生图Lora模型微调实现虚拟上装”教程问题请教

本人PAI新手,正在尝试Stable Diffusion阿里云部署教程:


“AIGC Stable Diffusion文生图Lora模型微调实现虚拟上装”教程在PAI-DSW中学习如何微调训练LoRA模型,在教程第二步第3点遇到RuntimeError情况,该步骤代码为:

safety_checker_url = f"{prefix}/aigc-data/hug_model/models--CompVis--stable-diffusion-safety-checker.tar.gz"
aria2(safety_checker_url, safety_checker_url.split("/")[-1], "./")
! tar -xf models--CompVis--stable-diffusion-safety-checker.tar.gz -C /root/.cache/huggingface/hub/

clip_url = f"{prefix}/aigc-data/hug_model/models--openai--clip-vit-large-patch14.tar.gz"
aria2(clip_url, clip_url.split("/")[-1], "./")
! tar -xf models--openai--clip-vit-large-patch14.tar.gz -C /root/.cache/huggingface/hub/

model_url = f"{prefix}/aigc-data/sd_models/chilloutmix_NiPrunedFp32Fix.safetensors"
aria2(model_url, model_url.split("/")[-1], "stable-diffusion-webui/models/Stable-diffusion/")

! python diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py \
--checkpoint_path=stable-diffusion-webui/models/Stable-diffusion/chilloutmix_NiPrunedFp32Fix.safetensors \
--dump_path=chilloutmix-ni --from_safetensors

得到结果和报错内容为:
Download Results:
gid |stat|avg speed |path/URI
======+====+===========+=======================================================
c0a092|OK | 0B/s|.//models--CompVis--stable-diffusion-safety-checker.tar.gz

Status Legend:
(OK):download completed.

Download Results:
gid |stat|avg speed |path/URI
======+====+===========+=======================================================
ee42b3|OK | 0B/s|.//models--openai--clip-vit-large-patch14.tar.gz

Status Legend:
(OK):download completed.

Download Results:
gid |stat|avg speed |path/URI
======+====+===========+=======================================================
ee1e25|OK | 0B/s|stable-diffusion-webui/models/Stable-diffusion//chilloutmix_NiPrunedFp32Fix.safetensors

Status Legend:
(OK):download completed.
global_step key not found in model
Traceback (most recent call last):
File "/mnt/workspace/sdwebui_notebook_demo_lora_new/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py", line 131, in
pipe = download_from_original_stable_diffusion_ckpt(
File "/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1274, in download_from_original_stable_diffusion_ckpt
text_model = convert_ldm_clip_checkpoint(checkpoint)
File "/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 740, in convert_ldm_clip_checkpoint
text_model.load_state_dict(text_model_dict)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1671, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for CLIPTextModel:
Unexpected key(s) in state_dict: "text_model.embeddings.position_ids".


教程为DSW Gallery中的"AIGC Stable Diffusion文生图Lora模型微调实现虚拟上装",教程连接:https://help.aliyun.com/document_detail/2253191.html?spm=a2c4g.2384366.0.0.4fba3cf6qRDvs4

image.png


部署DSW实例规格:ecs.gn7i-c8g1.2xlarge

展开
收起
Martinezolovsky 2023-07-21 12:32:11 763 1
2 条回答
写回答
取消 提交回答
  • 在教程的第二步中,你遇到了一个 RuntimeError。根据提供的代码,可能有几个原因导致这个错误:

    1. 运行时依赖项缺失:RuntimeError 可能是由于缺少某些运行时依赖项引起的。请确保你的环境中已经安装了所需的软件包和库,并且版本与教程要求相匹配。

    2. 文件下载失败:RuntimeError 可能是由于文件下载失败导致的。请确保从 safety_checker_urlclip_urlmodel_url 下载的文件都成功获取并保存到正确的位置。

    3. 路径设置错误:RuntimeError 可能是由于路径设置不正确引起的。请检查路径变量(例如 prefix)是否被正确设置,并且路径名是否存在拼写错误或缺失。

    对于你遇到的具体 RuntimeError,建议你仔细检查错误消息和堆栈跟踪,以确定导致该错误的具体原因。如果可能,请提供更多的错误信息,以便我能够提供更精确的帮助。

    2023-07-31 17:16:07
    赞同 展开评论 打赏
  • 北京阿里云ACE会长

    这是一个关于如何在PAI-DSW中微调训练 AIGC Stable Diffusion Lora 模型并进行模型推理的教程。在第二步的第3点中,代码中使用了aria2函数下载models--CompVis--stable-diffusion-safety-checker.tar.gz文件,但是在下载时遇到了RuntimeError的错误。这可能是因为下载链接不正确或无法访问。

    建议您检查以下几点:

    确认您的实例网络是否正常,可以尝试使用ping命令测试网络连通性。
    检查您的阿里云账号是否有访问链接的权限。
    检查链接是否正确,您可以尝试手动访问该链接以确认它是否有效。
    如果链接无效,您可以尝试在阿里云上搜索相关的资源或联系阿里云客服以获取帮助。

    2023-07-30 15:34:32
    赞同 展开评论 打赏

热门讨论

热门文章

相关电子书

更多
新一代AIGC图像应用 在零售行业的实践成果 立即下载
云原生场景下, AIGC模型服务的工程挑战和应对 立即下载
关于《探索AIGC下的软件工程新范式》的联合声明 立即下载