WasmEdge / WasmEdge

WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications. It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.
https://WasmEdge.org
Apache License 2.0
8.53k stars 766 forks source link

bug: `Segmentation fault` while running flux.1-dev with sd plugin #3794

Closed apepkuss closed 1 month ago

apepkuss commented 1 month ago

Summary

Stable-diffusion plugin causes Segmentation fault (core dumped) while running flux.1-dev. The following shows the complete log messages, including the error:

WASMEDGE_PLUGIN_PATH=/data/sam/sd/plugin wasmedge --dir .:. sd-api-server.wasm --model-name flux1-dev --diffusion-model flux1-dev-Q4_0.gguf --vae ae.safetensors --clip-l clip_l.safetensors --t5xxl t5xxl-Q8_0.gguf
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:79: server version: 0.1.4
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:87: model_name: flux1-dev
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:103: diffusion model: flux1-dev-Q4_0.gguf
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:111: vae: ae.safetensors
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:119: clip_l: clip_l.safetensors
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:127: t5xxl: t5xxl-Q8_0.gguf
[2024-09-25 07:14:41.011] [info] sd_api_server in src/main.rs:135: lora_model_dir: 
[2024-09-25 07:14:41.012] [info] sd_api_server in src/main.rs:136: threads: -1
[2024-09-25 07:14:41.012] [info] llama_core in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/lib.rs:900: Initializing the stable diffusion context with the standalone diffusion model
[2024-09-25 07:14:41.012] [info] llama_core in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/lib.rs:976: The stable diffusion text-to-image context has been initialized
[2024-09-25 07:14:41.012] [info] llama_core in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/lib.rs:1052: The stable diffusion image-to-image context has been initialized
[2024-09-25 07:14:41.012] [info] sd_api_server in src/main.rs:168: Listening on 0.0.0.0:8080
[2024-09-25 07:19:40.167] [info] sd_api_server in src/main.rs:162: remote_addr: 0.0.0.0:42844, local_addr: 0.0.0.0:8080
[2024-09-25 07:19:40.168] [info] sd_api_server in src/main.rs:199: method: POST, endpoint: /v1/images/generations, http_version: HTTP/1.1, content-length: 466
[2024-09-25 07:19:40.168] [info] sd_api_server::backend::sd in src/backend/sd.rs:18: Handling the coming image generation request
[2024-09-25 07:19:40.168] [info] sd_api_server::backend::sd in src/backend/sd.rs:42: Prepare the image generation request.
[2024-09-25 07:19:40.168] [info] sd_api_server::backend::sd in src/backend/sd.rs:75: user: imgen-29a8cbbd-fc7e-4cc4-a40c-00141f5fc96b
[2024-09-25 07:19:40.169] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:21: Processing the image generation request.
[2024-09-25 07:19:40.169] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:45: create computation context.
[2024-09-25 07:19:40.169] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:48: config of sd: StableDiffusion { task: TextToImage, model_path: "", clip_l_path: "clip_l.safetensors", t5xxl_path: "t5xxl-Q8_0.gguf", diffusion_model_path: "flux1-dev-Q4_0.gguf", vae_path: "ae.safetensors", taesd_path: "", control_net_path: "", lora_model_dir: "", embed_dir: "", id_embed_dir: "", vae_decode_only: true, vae_tiling: false, n_threads: -1, wtype: SdTypeCount, rng_type: StdDefaultRng, schedule: DEFAULT, clip_on_cpu: false, control_net_cpu: false, vae_on_cpu: false }
[2024-09-25 07:19:40.169] [info] [WasmEdge-StableDiffusion] Create context.
WARNING: Behavior may be unexpected when allocating 0 bytes for ggml_calloc!
WARNING: Behavior may be unexpected when allocating 0 bytes for ggml_calloc!
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:77: prompt: Capture a street food vendor in Tokyo at night, shot with a wide-angle lens (24mm) at f/1.8. Use a shallow depth of field to focus on the vendor’s hands preparing takoyaki, with the glowing street signs and bustling crowd blurred in the background. High ISO setting to capture the ambient light, giving the image a slight grain for a cinematic feel.
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:84: negative prompt: 
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:91: cfg_scale: 1
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:98: sample_method: euler
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:139: steps: 20
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:147: height: 512, width: 512
[2024-09-25 07:20:01.323] [info] llama_core::images in /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama-core-0.18.0/src/images.rs:151: generate image
[2024-09-25 07:20:01.324] [info] [WasmEdge-StableDiffusion] Start to generate image.
Segmentation fault (core dumped)

Current State

No response

Expected State

No response

Reproduction steps

Screenshots

No response

Any logs you want to share for showing the specific issue

No response

Components

Others

WasmEdge Version or Commit you used

0.14.1

Operating system information

macOS 14.6.1, ubuntu-2204

Hardware Architecture

Apple M1 Pro, x86_64

Compiler flags and options

No response

hydai commented 1 month ago

Hi @grorge123 Please help figure out this issue.

hydai commented 1 month ago

Fixed via #3801