ai277014717

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

  •  
  •   ai277014717 · May 30, 2023 · 961 views
    This topic created in 1083 days ago, the information mentioned may be changed or developed.

    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 之间。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3190 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 11:12 · PVG 19:12 · LAX 04:12 · JFK 07:12
    ♥ Do have faith in what you're doing.