-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homebrew package unable to find the file "ggml-metal.metal" #1050
Comments
The homebrew formula is a bit outdated. It should be updated in a similar way to llama.cpp.rb. When this is done, the Metal library will be embedded in the binary and the env path would not be required. I just haven't had the time to look into this. If you are interested in giving it a try, please go ahead and feel free to ping me with any questions. |
Ah and it will likely require updating |
Thanks for chiming in. After BTW, did I open this issue in the wrong repo? I was meaning to open it in https://github.com/ggerganov/whisper.cpp; please feel free to move it there. Thank you! |
It's ok to have the issue here - no problem. https://github.com/ggerganov/whisper.cpp/releases/tag/v1.7.3 has just been released. |
Here is the Homebrew PR to bump the version: Homebrew/homebrew-core#201851 It installs the "main" example as the
To figure out the right build incantation was very much trial-and-error on my side, so please correct me if I'm doing something obviously wrong. Notice that the installation now produces dylib files, whereas the build system for v1.5.4 (a simple P.S. here is some feedback about the build system from someone who has zero experience with cmake, but who has a solid grasp of the (BTW, everything that follows is in the context of the https://github.com/ggerganov/whisper.cpp repo.) On a fresh download of this project's source code, I've tried this (simplified for brevity): cmake -B "$BUILD_DIR" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" [args...]
cmake --build "$BUILD_DIR" --target main
cmake --install "$BUILD_DIR" What I expected was that the
It looks like the product of the install command are header files and dylibs, which is fine for other programs to use when linking to the whisper library, but I'm mainly interested in the The
I find this to be a problem, because if I move And finally, a small feature request: I wonder if my system already has libggml dylibs, the build system for this repo could be instructed to link to those at runtime instead of building fresh ones? For example, I can use Homebrew to install
This gives me Please forgive me if I'm not making sense; I just have a basic understanding of dylibs in general, which is that they're needed at runtime and that they are discovered in a list of locations that is dictated by the program's embedded configuration (and possibly some environment variables). And finally, thank you for this awesome project. It certainly solved my problem (a personal tool to |
Thank you for the very detailed explanation! I will attempt to address the install and link problems in ggerganov/whisper.cpp#2648. Regarding the shared |
Btw, I only now realize that the |
Ah, I thought that was intentional for the |
Yeah, so as far as I understand, the correct way to distribute both the So I am thinking that there are 2 possible solutions:
In the long term, the first option is what we should aim for, but I am not sure if we are ready for it at the moment. Maybe there is some way to make the second option work somehow? I will cc @slaren as he has very good knowledge about the build system and might have some additional insights on the topic. |
I am looking into packaging now, I am just not sure yet what's the best way to handle it. Generally I think we should have separate packages for the libraries that other developers can also use, but that will probably require at least us to start versioning ggml, which I am not sure that would be compatible with the way we currently have a duplicate of ggml in every repository. Some notes that may fix the immediate issues:
|
@slaren Thanks for that tip; I was able to simplify the Homebrew formula using that flag. https://github.com/mislav/homebrew-core/blob/e4dbcb99e2ce4ab6cbd167126578afe2fa795b9f/Formula/w/whisper-cpp.rb#L28-L42 It was apparently needed too, because with shared libs, the Homebrew formula seemed have been failing on Linux due to a dylib not being found: https://github.com/Homebrew/homebrew-core/actions/runs/12422801076/job/34685263836. I've only ever tested the formula on macOS, so I'm not sure what is different on Linux. By doing BUILD_SHARED_LIBS=OFF, I was able to avoid having to debug the Linux failure and just end up with a single self-contained binary. 👍 |
I pushed a v1.7.4-pre-0 tag that renames the binaries for consistency with I also fixed the install rule for the binary so it should appear in the
@mislav What if we keep the shared libraries build ON and try to set the RPATH relative to the binaries, such as: |
Update: Homebrew v1.7.3 formula has been merged and the original issue in this thread fixed, so as far as I'm concerned, this can be closed and followup work tracked in separate issues. 🎉
I'm not familiar with RPATH at all, but it sounds like that might work. However, now that we have a self-contained binary in Homebrew, what incentive would we have to break out dylibs into separate files anymore? As previously concluded in this thread, if both But in any case, feel free to share suggestions here and if I can help apply them to future versions of the Homebrew formula, I will do my best. Note that am not a machine learning developer of any sort, so I am not a target audience for libggml libraries and cannot weigh in on how they should be used. However, I support the previously expressed idea that in the future where libggml is more "stable" and is versioned on its own, both llama.ccp and whisper-cpp could be made to depend on it externally.
Great, thank you! BTW, in future Homebrew formula upgrades for this, should the Homebrew-installed binary be continued to be called |
The static builds are not ideal because
Yes, this seems like the ultimate solution.
For consistency with the |
Okay, I am preparing the change to the Homebrew formula to adjust it to the latest build system in this repo. I've reenabled BUILD_SHARED_LIBS and this is what I got so far: system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
if head?
system "cmake", "--build", "build"
system "cmake", "--install", "build"
(bin/"whisper-cpp").write <<~EOS
#!/bin/bash
here="${BASH_SOURCE[0]}"
echo "${BASH_SOURCE[0]}: warning: whisper-cpp is deprecated. Use whisper-cli instead."
exec "$(dirname "$here")/whisper-cli" "$@"
EOS
(bin/"whisper-cpp").chmod 0755
else
# the "main" target is our whisper-cpp binary
system "cmake", "--build", "build", "--target", "main"
bin.install "build/bin/main" => "whisper-cpp"
end As you can see, I've added a However, the Homebrew linking step now fails because I also have
Could I pass options to the build system to install header files and libraries to locations different to And finally, there is a
The file isn't even executable, so it should not end up in bin I think. |
I don't see a good way to deal with the library conflicts until we have versioned ggml. Maybe you could install the libraries into a different location, and change the shared library search path with I don't think |
I opened #1054 to fix this. Not sure what should we do when |
@slaren To enable dylibs but to place them in a different location than "lib", I've tried this:
The dylibs are now installed to "libinternal" but the
Do you know what I might be missing? I have no previous experience with RPATH. |
I tried this with llama.cpp and worked as expected: cmake -B build -DCMAKE_INSTALL_LIBDIR=libinternal -DCMAKE_INSTALL_RPATH=@loader_path/../libinternal
cmake --build build
cmake --install build --prefix "install_test"
install_test/bin/llama-cli I am not sure if whisper.cpp does something different, but I think it should work. |
For some reason, the install RPATH of I've tagged the latest version with v1.7.4-pre-1. This should probably work now. |
Thanks; the Homebrew PR is up: Homebrew/homebrew-core#202270 |
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:
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:
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#L29But I'm guessing at runtime whisper-cpp does not discover this file at this location. It can be helped by setting an environment variable:
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!
The text was updated successfully, but these errors were encountered: