]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
make : check nvcc version and set flag (#1115)
authoralonfaraj <redacted>
Tue, 25 Jul 2023 16:10:54 +0000 (19:10 +0300)
committerGitHub <redacted>
Tue, 25 Jul 2023 16:10:54 +0000 (19:10 +0300)
Makefile

index 2dd7cb788f82abb00d53fbcf71ad4dd76e554631..5c46d295f804630557754d44ad1426661c267a9d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,12 @@ ifndef UNAME_M
 UNAME_M := $(shell uname -m)
 endif
 
+ifndef NVCC_VERSION
+       ifeq ($(call,$(shell which nvcc))$(.SHELLSTATUS),0)
+               NVCC_VERSION := $(shell nvcc --version | egrep -o "V[0-9]+.[0-9]+.[0-9]+" | cut -c2-)
+       endif
+endif
+
 CCV := $(shell $(CC) --version | head -n 1)
 CXXV := $(shell $(CXX) --version | head -n 1)
 
@@ -167,12 +173,18 @@ ifdef WHISPER_OPENBLAS
 endif
 
 ifdef WHISPER_CUBLAS
+       ifeq ($(shell expr $(NVCC_VERSION) \>= 11.6), 1)
+               CUDA_ARCH_FLAG=native
+       else
+               CUDA_ARCH_FLAG=all
+       endif
+
        CFLAGS      += -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I$(CUDA_PATH)/targets/$(UNAME_M)-linux/include
        CXXFLAGS    += -DGGML_USE_CUBLAS -I/usr/local/cuda/include -I/opt/cuda/include -I$(CUDA_PATH)/targets/$(UNAME_M)-linux/include
        LDFLAGS     += -lcublas -lculibos -lcudart -lcublasLt -lpthread -ldl -lrt -L/usr/local/cuda/lib64 -L/opt/cuda/lib64 -L$(CUDA_PATH)/targets/$(UNAME_M)-linux/lib
        WHISPER_OBJ += ggml-cuda.o
        NVCC        = nvcc
-       NVCCFLAGS   = --forward-unknown-to-host-compiler -arch=any
+       NVCCFLAGS   = --forward-unknown-to-host-compiler -arch=$(CUDA_ARCH_FLAG)
 
 ggml-cuda.o: ggml-cuda.cu ggml-cuda.h
        $(NVCC) $(NVCCFLAGS) $(CXXFLAGS) -Wno-pedantic -c $< -o $@