From a0bb409f512b1ac8c5c523dd60075905e5870664 Mon Sep 17 00:00:00 2001 From: alonfaraj Date: Tue, 25 Jul 2023 19:10:54 +0300 Subject: [PATCH] make : check nvcc version and set flag (#1115) --- Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2dd7cb78..5c46d295 100644 --- 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 $@