Skip to content

Commit d1f64e1

Browse files
committed
make : add WHISPER_CUBLAS support
1 parent 05c3ea3 commit d1f64e1

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Makefile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
default: main bench
2+
13
ifndef UNAME_S
24
UNAME_S := $(shell uname -s)
35
endif
@@ -157,6 +159,18 @@ ifdef WHISPER_OPENBLAS
157159
LDFLAGS += -lopenblas
158160
endif
159161

162+
ifdef WHISPER_CUBLAS
163+
CFLAGS += -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I$(CUDA_PATH)/targets/x86_64-linux/include
164+
CXXFLAGS += -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I$(CUDA_PATH)/targets/x86_64-linux/include
165+
LDFLAGS += -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L/usr/local/cuda/lib64 -L/opt/cuda/lib64 -L$(CUDA_PATH)/targets/x86_64-linux/lib
166+
WHISPER_OBJ += ggml-cuda.o
167+
NVCC = nvcc
168+
NVCCFLAGS = --forward-unknown-to-host-compiler -arch=native
169+
170+
ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
171+
$(NVCC) $(NVCCFLAGS) $(CXXFLAGS) -Wno-pedantic -c $< -o $@
172+
endif
173+
160174
ifdef WHISPER_GPROF
161175
CFLAGS += -pg
162176
CXXFLAGS += -pg
@@ -200,28 +214,26 @@ $(info I CC: $(CCV))
200214
$(info I CXX: $(CXXV))
201215
$(info )
202216

203-
default: main bench
204-
205217
#
206218
# Build library
207219
#
208220

209-
ggml.o: ggml.c ggml.h
210-
$(CC) $(CFLAGS) -c ggml.c -o ggml.o
221+
ggml.o: ggml.c ggml.h ggml-cuda.h
222+
$(CC) $(CFLAGS) -c $< -o $@
211223

212-
whisper.o: whisper.cpp whisper.h ggml.h
213-
$(CXX) $(CXXFLAGS) -c whisper.cpp -o whisper.o
224+
whisper.o: whisper.cpp whisper.h ggml.h ggml-cuda.h
225+
$(CXX) $(CXXFLAGS) -c $< -o $@
214226

215227
ifndef WHISPER_COREML
216-
WHISPER_OBJ = whisper.o
228+
WHISPER_OBJ += whisper.o
217229
else
218230
whisper-encoder.o: coreml/whisper-encoder.mm coreml/whisper-encoder.h
219231
$(CXX) -O3 -I . -c coreml/whisper-encoder.mm -o whisper-encoder.o
220232

221233
whisper-encoder-impl.o: coreml/whisper-encoder-impl.m coreml/whisper-encoder-impl.h
222234
$(CXX) -O3 -I . -fobjc-arc -c coreml/whisper-encoder-impl.m -o whisper-encoder-impl.o
223235

224-
WHISPER_OBJ = whisper.o whisper-encoder.o whisper-encoder-impl.o
236+
WHISPER_OBJ += whisper.o whisper-encoder.o whisper-encoder-impl.o
225237
endif
226238

227239
libwhisper.a: ggml.o $(WHISPER_OBJ)

0 commit comments

Comments
 (0)