leejet / stable-diffusion.cpp

Stable Diffusion in pure C/C++
MIT License
2.91k stars 233 forks source link

Error: Unsupported op TIMESTEP_EMBEDDING #182

Closed paulocoutinhox closed 3 months ago

paulocoutinhox commented 4 months ago

Hi,

Im getting this version from latest master commit:

ggml_metal_init: allocating
ggml_metal_init: found device: Apple M1 Pro
ggml_metal_init: picking default device: Apple M1 Pro
ggml_metal_init: default.metallib not found, loading from source
ggml_metal_init: GGML_METAL_PATH_RESOURCES = nil
ggml_metal_init: loading '/Users/paulo/Developer/workspaces/cpp/build-ai-kit-Qt_6_6_1_for_macOS-Debug/bin/ggml-metal.metal'
ggml_metal_init: GPU name:   Apple M1 Pro
ggml_metal_init: GPU family: MTLGPUFamilyApple7  (1007)
ggml_metal_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_init: GPU family: MTLGPUFamilyMetal3  (5001)
ggml_metal_init: simdgroup reduction support   = true
ggml_metal_init: simdgroup matrix mul. support = true
ggml_metal_init: hasUnifiedMemory              = true
ggml_metal_init: recommendedMaxWorkingSetSize  = 11453.25 MB
ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =   235.08 MiB, (  236.95 / 10922.67)
ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =  1640.27 MiB, ( 1877.22 / 10922.67)
ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =    94.47 MiB, ( 1971.69 / 10922.67)
ggml_gallocr_reserve_n: reallocating Metal buffer from size 0.00 MiB to 1.40 MiB
ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =     1.41 MiB, ( 1973.09 / 10922.67)
ggml_gallocr_reserve_n: reallocating Metal buffer from size 0.00 MiB to 1.40 MiB
ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =     1.41 MiB, ( 1973.09 / 10922.67)
ggml_gallocr_reserve_n: reallocating Metal buffer from size 0.00 MiB to 559.90 MiB
ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =   559.91 MiB, ( 2296.52 / 10922.67)
ggml_metal_graph_compute_block_invoke: error: unsupported op 'TIMESTEP_EMBEDDING'
GGML_ASSERT: /Users/paulo/Developer/workspaces/cpp/ai-kit/vendor/ggml/src/ggml-metal.m:798: !"unsupported op"
Option: 
    n_threads:         8
    mode:              0
    model_path:        /Users/paulo/Downloads/dreamshaper_8.safetensors
    wtype:             unspecified
    vae_path:          
    taesd_path:        
    esrgan_path:       
    output_path:       output.png
    init_img:          
    prompt:            a cat with blue eyes
    negative_prompt:   
    cfg_scale:         7.00
    clip_skip:         -1
    width:             512
    height:            512
    sample_method:     0
    schedule:          0
    sample_steps:      20
    strength(img2img): 0.75
    rng:               1
    seed:              42
    batch_count:       1
    vae_tiling:        false
paulocoutinhox commented 4 months ago

I tried with a lot of models, example:

CRASH without message

ggml_metal_init: allocating
ggml_metal_init: found device: Apple M1 Pro
ggml_metal_init: picking default device: Apple M1 Pro
ggml_metal_init: default.metallib not found, loading from source
ggml_metal_init: GGML_METAL_PATH_RESOURCES = nil
ggml_metal_init: loading '/Users/paulo/Developer/workspaces/cpp/build-ai-kit-Qt_6_6_1_for_macOS-Debug/bin/ggml-metal.metal'
ggml_metal_init: GPU name:   Apple M1 Pro
ggml_metal_init: GPU family: MTLGPUFamilyApple7  (1007)
ggml_metal_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_init: GPU family: MTLGPUFamilyMetal3  (5001)
ggml_metal_init: simdgroup reduction support   = true
ggml_metal_init: simdgroup matrix mul. support = true
ggml_metal_init: hasUnifiedMemory              = true
ggml_metal_init: recommendedMaxWorkingSetSize  = 11453.25 MB
drasticactions commented 4 months ago

GGML_OP_TIMESTEP_EMBEDDING is not implemented in the ggml fork for Metal. The error in this case is correct: Until it gets implemented it won't ever work. I think they did it for the regular CPU case and Cuda? So those should work.

leejet commented 4 months ago

I have added Metal support for ggml_arange and ggml_timestep_embedding, and it has been merged upstream. I've also updated sd.cpp to the latest commit. Please try pulling the latest code to test it.

paulocoutinhox commented 4 months ago

It is working :)

stablediff-img

Tested with: dreamshaper_8.safetensors

leejet commented 3 months ago

Problem solved, this issue should be closed.