V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ai277014717
V2EX  ›  分享发现

分享下 AMD 黑苹果使用 CoreML 加速 AI 画图需要折腾的点。

  •  
  •   ai277014717 · 357 天前 · 541 次点击
    这是一个创建于 357 天前的主题,其中的信息可能已经有所发展或是发生改变。

    ml-stable-diffusion提供了 torch 到 coreml 的模型转换能力

    • 手动转换模型时需要添加--attention-implementation ORIGINAL

    否则默认会用到自然语言引擎。

    • 手动转换模型需要给 torch 打补丁

    AMD Hackintosh torch 依赖了 Intel MKL 。可以用 amdfriend 对动态库或二进制打补丁。

    • 无法正常图片的话需要手动转换模型并设置 CoreML 模型精度为 FP32 。
    coreml_model = ct.convert(
        torchscript_module,
        convert_to="mlprogram",
        minimum_deployment_target=ct.target.macOS13,
        inputs=_get_coreml_inputs(sample_inputs, args),
        outputs=[ct.TensorType(name=name) for name in output_names],
        compute_units=ct.ComputeUnit[args.compute_unit],
        compute_precision=ct.precision.FLOAT32,
        # skip_model_load=True,
    )
    

    整个流程搞定后 6800xt 可以 30 秒可以跑完 50 次迭代速度介于 M1 和 M2 之间。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3002 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:40 · PVG 12:40 · LAX 21:40 · JFK 00:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.