Skip to content
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

ruby: Installation problem #2483

Closed
KitaitiMakoto opened this issue Oct 15, 2024 · 4 comments
Closed

ruby: Installation problem #2483

KitaitiMakoto opened this issue Oct 15, 2024 · 4 comments

Comments

@KitaitiMakoto
Copy link
Contributor

Hi,

whisper.cpp is great for me as a mac user and Ruby binding is also great as a Rubyist. Thank you so much.

I found gem install whispercpp fails on my machine and I investigated what happened. I needed some fixes for extconf.rb:

diff --git a/bindings/ruby/ext/extconf.rb b/bindings/ruby/ext/extconf.rb
index 5518928..aec1f0d 100644
--- a/bindings/ruby/ext/extconf.rb
+++ b/bindings/ruby/ext/extconf.rb
@@ -1,19 +1,20 @@
 require 'mkmf'
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','whisper.cpp')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','whisper.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml.c')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-impl.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-aarch64.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-aarch64.c')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-alloc.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-alloc.c')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-backend-impl.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-backend.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-backend.cpp')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-common.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-quants.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-quants.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','src','whisper.cpp')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','include','whisper.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','include','ggml.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-impl.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-aarch64.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-aarch64.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','include','ggml-alloc.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-alloc.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-backend-impl.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','include','ggml-backend.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-backend.cpp')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-common.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-quants.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-quants.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-cpu-impl.h')} .")
 system("cp #{File.join(File.dirname(__FILE__),'..','..','..','examples','dr_wav.h')} .")
 
 

That's almost good, but one problem remains:

% uname -a
Darwin XXX 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:13 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8112 arm64
% ruby -v
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]
% ruby extconf.rb
creating Makefile
source files duplication - ggml-backend.{c,cpp}

Which should I choose C or C++ source file for ggml-backend? It seems C++ source is suitable because the compile fails if I remove ggml-backend.cpp. But, I'm not familiar with C and C++, so I'm not sure.

Thanks.

@KitaitiMakoto
Copy link
Contributor Author

@ggerganov answered to this problem: #507 (reply in thread)
Thanks!

Will close this issue.

@oriolgual
Copy link

But aren’t those changes still requires @KitaitiMakoto ? I’m saying this because maybe the issue needs to be open?

@KitaitiMakoto
Copy link
Contributor Author

KitaitiMakoto commented Oct 15, 2024

@oriolgual
The changes are just for quick investigation. Those are not good for creating Ruby binding.

I filed this issue for only one question about ggml-backend.cpp and ggml-backend.c. So, it completed its role.

Additionally, I created a pull request #2484, which includes fixes for this issue and more. So, I don't think reopening this issue is needed. But, I have no objection if you will file a tracking issue corresponding to the pull request or so.

@oriolgual
Copy link

@oriolgual The changes are just for quick investigation. Those are not good for creating Ruby binding.

I filed this issue for only one question about ggml-backend.cpp and ggml-backend.c. So, it completed its role.

Additionally, I created a pull request #2484, which includes fixes for this issue and more. So, I don't think reopening this issue is needed. But, I have no objection if you will file a tracking issue corresponding to the pull request or so.

No worries, I didn't see the PR. Great job and thanks for contributing with the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants