huggingface / candle

Minimalist ML framework for Rust
Apache License 2.0
15.8k stars 949 forks source link

Stable diffusion with mkl #1456

Closed killzoner closed 10 months ago

killzoner commented 10 months ago

Hey,

I have been trying to run the stable diffusion example with mkl, but it fails with undefined reference to "hgemm".

At first I thought I was missing some libs, but then I realized mkl is coming from containerized lib via rust-mkl and ocipkg so it seems the function doesn't exist (at least in the package referenced, I saw updated for the 2020.1 version in the repo but the static version in the container is hardcoded to an older one). I also played with MKLROOT path, and it seems that hgemm is the only missing part even if my local lib is found (didn't test 2024.x version)

After installing locally and some grep usr/include/mkl, no more luck but sgemm and dgemm do exist though. Checked the official mkl doc (https://www.ehu.eus/sgi/ARCHIVOS/mklman.pdf) and didn't find it too.

For reference, the command is

cargo run --features=mkl --example stable-diffusion --release    -- --cpu --prompt "a cosmonaut on a horse (hd, realistic, high-def)"

Tried with both

sudo apt install intel-mkl # => 2020.4.304-2ubuntu3
sudo apt install intel-oneapi-mkl # => 2024.0.0-49656

If you can give me a status on if this is supposed to work before I start digging in ghcr.io/rust-math/rust-mkl/linux/mkl-static-lp64-iomp:2020.1-6048495329 manually, this would be much appreciated

LaurentMazare commented 10 months ago

This is indeed supposed to work fine, the missing hgemm issue should only happen with outdated version of mkl and 2024.0.0 should actually be all good so not sure why it wasn't getting it right at that point (might be worth forcing a clean build after installing the lib). More details in this related issue #443 .

killzoner commented 10 months ago

Thanks @LaurentMazare, I will have a look at rust-mkl and submit a PR to update to 2024 version then because I don't think this crate is useful in the current state

Probably doing another PR here to mention minimal version of mkl needed