whisper.cpp icon indicating copy to clipboard operation
whisper.cpp copied to clipboard

fix(bindings/go): also look into stubs when CUBLAS is enabled

Open mudler opened this issue 1 year ago • 0 comments

In some CUDA installations libcuda.so is present only in the stubs folders.

Example log:

root@76d08ab315dc:/build/sources/whisper.cpp# WHISPER_CUBLAS=1 make -j libwhisper.so                                                                                                                                                         
I whisper.cpp build info:                                                                                                                                                                                                                    
I UNAME_S:  Linux                                                                                                                                                                                                                            
I UNAME_P:  x86_64                                                                                                                                                                                                                           
I UNAME_M:  x86_64                                                                                                                                                                                                                           
I CFLAGS:   -I.              -O3 -DNDEBUG -std=c11   -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/includ
e                                                                                                                                                                                                                                            
I CXXFLAGS: -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/includ
e                                                                                                                                                                                                                                            
I LDFLAGS:  -lcuda -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L/usr/local/cuda/lib64 -L/opt/cuda/lib64 -L/targets/x86_64-linux/lib -L/usr/lib/wsl/lib                                                                       
I CC:       cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0                                                                                                                                                                                         
I CXX:      g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0                                                                                                                                                                                        
                                                                                                                                                                                                                                             
nvcc --forward-unknown-to-host-compiler -arch=native -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cu
da/include -I/targets/x86_64-linux/include -Wno-pedantic -c ggml-cuda.cu -o ggml-cuda.o                                                                                                                                                      
cc  -I.              -O3 -DNDEBUG -std=c11   -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include   -c g
gml.c -o ggml.o                                                                                                                                                                                                                              
cc  -I.              -O3 -DNDEBUG -std=c11   -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include   -c g
gml-alloc.c -o ggml-alloc.o                                                                                           
cc  -I.              -O3 -DNDEBUG -std=c11   -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include   -c g
gml-backend.c -o ggml-backend.o                                                                                       
cc  -I.              -O3 -DNDEBUG -std=c11   -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include   -c g
gml-quants.c -o ggml-quants.o                                                                                                                                                                                                                
g++ -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include -c whi
sper.cpp -o whisper.o                                                                                                                                                                                                                        
nvcc warning : Cannot find valid GPU for '-arch=native', default arch is used                                                                                                                                                                
g++ -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -pthread -mavx -mavx2 -mfma -mf16c -msse3 -mssse3 -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I/targets/x86_64-linux/include -share
d -o libwhisper.so ggml-cuda.o ggml.o ggml-alloc.o ggml-backend.o ggml-quants.o whisper.o -lcuda -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L/usr/local/cuda/lib64 -L/opt/cuda/lib64 -L/targets/x86_64-linux/lib -L/usr/lib/
wsl/lib                                                                                                                                                                                                                                      
/usr/bin/ld: cannot find -lcuda: No such file or directory                                                            
collect2: error: ld returned 1 exit status                                                                                                                                                                                                   
make: *** [Makefile:374: libwhisper.so] Error 1                             

Try to fix: https://github.com/ggerganov/whisper.cpp/issues/155 (or at least it does, for me and LocalAI)

Also update the docs to mention out that it might be needed to tweak CGO_LDFLAGS during building of the golang binary (if using e.g. libwhisper.a).

mudler avatar Mar 18 '24 11:03 mudler