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

Problem compiling addon.node (+solution) #2091

Open
pprobst opened this issue Apr 24, 2024 · 7 comments
Open

Problem compiling addon.node (+solution) #2091

pprobst opened this issue Apr 24, 2024 · 7 comments

Comments

@pprobst
Copy link
Contributor

pprobst commented Apr 24, 2024

Hello there.

When I compile addon.node in examples, running the following line after npm install:

npx cmake-js compile -T whisper-addon -B Release

Yields:

info TOOL Using Ninja generator, because ninja is available.
info TOOL Building only the whisper-addon target, as specified from the command line.
info CMD BUILD
info RUN [
info RUN   'cmake',
info RUN   '--build',
info RUN   '/home/probst/Projects/whisper.cpp.ggerganov/build',
info RUN   '--config',
info RUN   'Release',
info RUN   '--target',
info RUN   'whisper-addon'
info RUN ]
[0/1] Re-running CMake...
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- x86 detected
CMake Error at examples/CMakeLists.txt:81 (set_target_properties):
  set_target_properties Can not find target to add properties to: addon.node


-- Configuring incomplete, errors occurred!
FAILED: build.ninja
/usr/bin/cmake --regenerate-during-build -S/home/probst/Projects/whisper.cpp.ggerganov -B/home/probst/Projects/whisper.cpp.ggerganov/build
ninja: error: rebuilding 'build.ninja': subcommand failed
info REP Build has been failed, trying to do a full rebuild.
info CMD CLEAN
info RUN [
info RUN   'cmake',
info RUN   '-E',
info RUN   'remove_directory',
info RUN   '/home/probst/Projects/whisper.cpp.ggerganov/build'
info RUN ]
info CMD CONFIGURE
info TOOL Building only the whisper-addon target, as specified from the command line.
info RUN [
info RUN   'cmake',
info RUN   '/home/probst/Projects/whisper.cpp.ggerganov',
info RUN   '--no-warn-unused-cli',
info RUN   '-G',
info RUN   'Ninja',
info RUN   '-DCMAKE_JS_VERSION=7.3.0',
info RUN   '-DCMAKE_BUILD_TYPE=Release',
info RUN   '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/probst/Projects/whisper.cpp.ggerganov/build/Release',
info RUN   '-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>',
info RUN   '-DCMAKE_JS_INC=/home/probst/.cmake-js/node-x64/v18.20.2/include/node',
info RUN   '-DCMAKE_JS_SRC=',
info RUN   '-DNODE_RUNTIME=node',
info RUN   '-DNODE_RUNTIMEVERSION=18.20.2',
info RUN   '-DNODE_ARCH=x64',
info RUN   '-DCMAKE_JS_LIB=',
info RUN   '-DCMAKE_CXX_FLAGS=-DBUILDING_NODE_EXTENSION'
info RUN ]
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.44.0")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- x86 detected
CMake Error at examples/CMakeLists.txt:81 (set_target_properties):
  set_target_properties Can not find target to add properties to: addon.node


-- Configuring incomplete, errors occurred!
ERR! OMG Process terminated: 1

However, this can be fixed by simply changing

set_target_properties(addon.node PROPERTIES FOLDER "examples")

to

set_target_properties(whisper-addon PROPERTIES FOLDER "examples")

However, I suppose a cleaner solution would be to replace the occurrences of whisper-addon with addon.node, to maintain the intended naming scheme.

@ggerganov Let me know your preference and I can shoot a PR if needed.

@gabrielmicko
Copy link

Hey @pprobst thank you for creating an issue on this and referencing it. It works. I have one question. Do you know how could I build for node, but it should use the GPU (cuda) instead of CPU.

@gabrielmicko
Copy link

gabrielmicko commented Apr 28, 2024

Other problems I found:
In the example index.js file the source of whisper-node is wrong. Changed ../../build/Release/whisper-addon to ../../build/bin/Release/whisper-addon.node. I had to also download the model, but that is fine.

When I ran the example, I got the following error:

node:internal/util:375
      ReflectApply(original, this, args);
      ^

TypeError: A boolean was expected

I looked into addon.cpp, and I think no_timestamps is also needed as params. I added it and the example worked.

@pprobst
Copy link
Contributor Author

pprobst commented Apr 28, 2024

Hey @pprobst thank you for creating an issue on this and referencing it. It works. I have one question. Do you know how could I build for node, but it should use the GPU (cuda) instead of CPU.

Hmm, to be fair in my use case I have only been using the node addon with CPU, and I'm not very experienced with node myself. Do you mean that it's not compiling for GPU?

Other problems I found: In the example index.js file the source of whisper-node is wrong. Changed ../../build/Release/whisper-addon to ../../build/bin/Release/whisper-addon.node. I had to also download the model, but that is fine.

When I ran the example, I got the following error:

node:internal/util:375
      ReflectApply(original, this, args);
      ^

TypeError: A boolean was expected

I looked into addon.cpp, and I think no_timestamps is also needed as params. I added it and the example worked.

Correct, no_timestamps should be passed as a parameter. In fact, I added the no_timestamps option recently as a PR 😅, so the existing example is outdated. I think it's important enough to be a parameter, since there's quite a big difference in WER when it comes to using or not timestamps (see #1724 (comment)).

@gabrielmicko
Copy link

Hey @pprobst I meant using GPU and CUDA, I am not sure how that works. What to do to speed up the process. My goal is to create text as fast as possible for few second recordings. I am trying to record air traffic control communication and turn it into text. I have tried using smart-whisper npm library with base.en model but it is slow and messages fall behind. It is good in a sense that it loads the model only once so I don't wase time with that, but also the quality is pretty inaccurate. I run windows and RTX4090, Procesor AMD Ryzen 9 7950X.

@pprobst
Copy link
Contributor Author

pprobst commented Apr 29, 2024

You can set use_gpu to true, but it's supposed to be true by default, so you're already using GPU if you have CUDA. Check your outputs and GPU usage to see if it's using your GPU.

EDIT: made a PR #2115.

@tom-leamon
Copy link

Other problems I found: In the example index.js file the source of whisper-node is wrong. Changed ../../build/Release/whisper-addon to ../../build/bin/Release/whisper-addon.node. I had to also download the model, but that is fine.

When I ran the example, I got the following error:

node:internal/util:375
      ReflectApply(original, this, args);
      ^

TypeError: A boolean was expected

I looked into addon.cpp, and I think no_timestamps is also needed as params. I added it and the example worked.

The path is still incorrect in the most recent commit. This still needs to be fixed. When I changed it to ../../build/bin/Release/addon.node as suggested, it worked.

@pprobst
Copy link
Contributor Author

pprobst commented May 6, 2024

I cannot replicate this error here. For reference, what I do is:

  1. Inside examples/addon.node, I run npm install.
  2. In the whisper.cpp root directory, I run npx cmake-js compile -T addon.node -B Release.
  3. cd examples/addon.node again and run node index.js.

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

3 participants