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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mudler
Copy link

@mudler mudler commented Mar 18, 2024

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: #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).

Signed-off-by: mudler <mudler@localai.io>
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

Successfully merging this pull request may close these issues.

None yet

1 participant