V-Sekai / godot-whisper

An GDExtension addon for the Godot Engine that enables realtime audio transcription, supports OpenCL for most platforms, Metal for Apple devices, and runs on a separate thread.
MIT License
65 stars 6 forks source link

Errors on Godot 4.2 #73

Closed petterthowsen closed 1 month ago

petterthowsen commented 4 months ago

I just downloaded this plugin via asset library and getting these errors:

Can't open dynamic library: addons/godot_whisper/bin/libgodot_whisper.linux.template_release.x86_64.so. Error: addons/godot_whisper/bin/libgodot_whisper.linux.template_release.x86_64.so: undefined symbol: clBuildProgram.
  core/extension/gdextension.cpp:719 - GDExtension dynamic library not found: addons/godot_whisper/bin/libgodot_whisper.linux.template_release.x86_64.so
  Failed loading resource: res://addons/godot_whisper/godot_whisper.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

I'm on Linux.

Do I need to build this project or something?

Ughuuu commented 4 months ago

Don't have linux to debug/test this. Looks like the libgodot_whisper.linux.template_release.x86_64.so binary exists, but probably at link stage something went wrong as it doesn't see clBuildProgram.

Normally it should all be built, however it seems like for linux the build is failing(but since for linux symbol resolution is done at runtime it doesnt show any error).

Ughuuu commented 4 months ago

Here is how we build and link OpenCL:

https://github.com/V-Sekai/godot-whisper/blob/main/.github/workflows/build_linux.yml

Currently we clone OpenCL repo, build it and then maybe our build doesnt take that lib? not 100% sure, will have to investigate though.

@fire can you also take a look if you get some time?

petterthowsen commented 4 months ago

Ok. I'm not very familiar with C++ so this is greek for me. I'll patiently wait for someone to chime in!

fire commented 4 months ago

Can you check if opencl drivers are installed?

Like sudo apt install opencl-headers ocl-icd-opencl-dev -y.

Also what linux and what hardware.

petterthowsen commented 4 months ago

@fire Linux Mint 21.3 x86_64 Host: ASUS TUF Gaming A17 FA707NV_FA707NV 1.0 Kernel: 6.5.0-14-generic CPU: AMD Ryzen 5 7535HS with Radeon Graphics (12) @ 4.603GHz GPU: AMD ATI 35:00.0 Rembrandt GPU: NVIDIA 01:00.0 NVIDIA Corporation Device 28e0

ocl-icd-opencl-dev is already the newest version (2.2.14-3). opencl-headers is already the newest version (3.0~2022.01.04-1).

fire commented 4 months ago

I have no idea but maybe it's confused trying to use opencl on amd vs opencl on nvidia.

adamflaigg commented 4 months ago

Hi, I'm also getting this same issue on Ubuntu 22.04 LTS with an AMD RX 6700XT GPU and Ryzen 5 5600X CPU.

I compiled the addon myself and made sure I had all the opencl apt packages installed as mentioned above just to see if that would make a difference but I got the same issue.

I'm not familiar with C++ all too much but I'll ask around and see if I can figure something out with this, and I'll report back if I find out a way to solve this.

Ughuuu commented 4 months ago

Are you able to run whisper.cpp locally on ubuntu? That might be a good start point to see how they run it.

adamflaigg commented 4 months ago

I was able to get the basic transcription example working compiling the base whisper.cpp with the below command. It appears to be using the GPU just fine as far as I can tell.

# build the main example
make

# transcribe an audio file
./main -f samples/jfk.wav

image

image

Ughuuu commented 4 months ago

Interesting. I wonder what kind of opencl the make is uaing for linux. Ill check also.

Nihlus commented 1 month ago

I did some digging myself, and this is probably because the gdextension doesn't link with OpenCL itself. If you force OpenCL to load using LD_PRELOAD, it gets a bit further but fails because it can't find "SET_CPU_S" (which is odd, since that's typically a macro).

Looking into it further, it looks like we need to define _GNU_SOURCE (https://github.com/ggerganov/whisper.cpp/blob/22fcd5fd110ba1ff592b4e23013d870831756259/ggml/src/CMakeLists.txt#L1236) to have ggml pick up the right functions at build time.