Skip to content

Homebrew package unable to find the file "ggml-metal.metal" #1050

@mislav

Description

@mislav

Hi, reporting something that is not necessarily a bug with this codebase, but a packaging problem. I'm not familiar with this project enough to determine that, so I'm leaving it here:

I was trying out this project by installing it via Homebrew:

brew install whisper-cpp

It seems to successfully transcribe audio, but it's very slow on an M1 MacBook. The output suggests that it wasn't able to use Metal backend:

whisper_backend_init: using Metal backend
ggml_metal_init: allocating
ggml_metal_init: found device: Apple M1
ggml_metal_init: picking default device: Apple M1
ggml_metal_init: default.metallib not found, loading from source
ggml_metal_init: GGML_METAL_PATH_RESOURCES = nil
ggml_metal_init: error: could not use bundle path to find ggml-metal.metal, falling back to trying cwd
ggml_metal_init: loading 'ggml-metal.metal'
ggml_metal_init: error: Error Domain=NSCocoaErrorDomain Code=260 "The file “ggml-metal.metal” couldn’t be opened because there is no such file." UserInfo={NSFilePath=ggml-metal.metal, NSURL=ggml-metal.metal -- file:///Users/mislav/Projects/whisper/, NSUnderlyingError=0x60000014c360 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
whisper_backend_init: ggml_backend_metal_init() failed

The homebrew formula does include this file during installation and its location is share/whisper-cpp/ggml-metal.metal under its installation prefix: https://github.com/Homebrew/homebrew-core/blob/418ec8d5274aa16e99bdbb96dfc9c88f01a3b0ac/Formula/w/whisper-cpp.rb#L29

But I'm guessing at runtime whisper-cpp does not discover this file at this location. It can be helped by setting an environment variable:

GGML_METAL_PATH_RESOURCES="$(brew --prefix whisper-cpp)/share/whisper-cpp" whisper-cpp ...

Now it uses Metal and it seems noticeably faster. I think that ideally, setting GGML_METAL_PATH_RESOURCES should not be necessary as that the metal file should have been auto-discovered, but this might be a problem with how whisper-cpp is packaged within Homebrew. It that seems to be the case, please close this issue with a suggestion of a better location for the file, and I will go ahead and submit a PR to Homebrew. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions