2021-10-06 02:16:20 +00:00
|
|
|
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
ROOT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
|
|
|
|
2022-08-01 02:41:56 +00:00
|
|
|
ifndef CUDA_VERSION
|
|
|
|
$(error ERROR: CUDA_VERSION not set. Call make with CUDA string, for example: make cuda11x CUDA_VERSION=115 or make cpuonly CUDA_VERSION=CPU)
|
|
|
|
endif
|
|
|
|
|
2021-10-06 02:16:20 +00:00
|
|
|
GPP:= /usr/bin/g++
|
2021-10-22 00:22:43 +00:00
|
|
|
ifeq ($(CUDA_HOME),)
|
|
|
|
CUDA_HOME:= $(shell which nvcc | rev | cut -d'/' -f3- | rev)
|
|
|
|
endif
|
2022-08-01 02:41:56 +00:00
|
|
|
|
|
|
|
|
2021-10-06 02:16:20 +00:00
|
|
|
NVCC := $(CUDA_HOME)/bin/nvcc
|
2021-10-22 00:22:43 +00:00
|
|
|
|
2021-10-06 02:16:20 +00:00
|
|
|
###########################################
|
|
|
|
|
|
|
|
CSRC := $(ROOT_DIR)/csrc
|
2022-07-01 14:16:10 +00:00
|
|
|
BUILD_DIR:= $(ROOT_DIR)/build
|
2021-10-06 02:16:20 +00:00
|
|
|
|
|
|
|
FILES_CUDA := $(CSRC)/ops.cu $(CSRC)/kernels.cu
|
2022-07-01 14:16:10 +00:00
|
|
|
FILES_CPP := $(CSRC)/common.cpp $(CSRC)/cpu_ops.cpp $(CSRC)/pythonInterface.c
|
2021-10-06 02:16:20 +00:00
|
|
|
|
|
|
|
INCLUDE := -I $(CUDA_HOME)/include -I $(ROOT_DIR)/csrc -I $(CONDA_PREFIX)/include -I $(ROOT_DIR)/dependencies/cub -I $(ROOT_DIR)/include
|
2022-07-25 21:02:14 +00:00
|
|
|
LIB := -L $(CUDA_HOME)/lib64 -lcudart -lcublas -lcublasLt -lcurand -lcusparse -L $(CONDA_PREFIX)/lib
|
2021-10-06 02:16:20 +00:00
|
|
|
|
|
|
|
# NVIDIA NVCC compilation flags
|
2021-11-29 17:54:19 +00:00
|
|
|
COMPUTE_CAPABILITY := -gencode arch=compute_35,code=sm_35 # Kepler
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_37,code=sm_37 # Kepler
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_50,code=sm_50 # Maxwell
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_52,code=sm_52 # Maxwell
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_60,code=sm_60 # Pascal
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_61,code=sm_61 # Pascal
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_70,code=sm_70 # Volta
|
|
|
|
COMPUTE_CAPABILITY += -gencode arch=compute_72,code=sm_72 # Volta
|
2021-10-22 00:22:43 +00:00
|
|
|
|
|
|
|
# CUDA 9.2 supports CC 3.0, but CUDA >= 11.0 does not
|
|
|
|
CC_CUDA92 := -gencode arch=compute_30,code=sm_30
|
|
|
|
|
|
|
|
# Later versions of CUDA support the new architectures
|
|
|
|
CC_CUDA10x := -gencode arch=compute_30,code=sm_30
|
2022-07-26 05:34:14 +00:00
|
|
|
CC_CUDA10x += -gencode arch=compute_75,code=sm_75
|
2021-10-22 00:22:43 +00:00
|
|
|
|
|
|
|
CC_CUDA110 := -gencode arch=compute_75,code=sm_75
|
|
|
|
CC_CUDA110 += -gencode arch=compute_80,code=sm_80
|
|
|
|
|
|
|
|
CC_CUDA11x := -gencode arch=compute_75,code=sm_75
|
|
|
|
CC_CUDA11x += -gencode arch=compute_80,code=sm_80
|
|
|
|
CC_CUDA11x += -gencode arch=compute_86,code=sm_86
|
|
|
|
|
2022-07-26 05:34:14 +00:00
|
|
|
CC_cublasLt110 := -gencode arch=compute_75,code=sm_75
|
|
|
|
CC_cublasLt110 += -gencode arch=compute_80,code=sm_80
|
|
|
|
|
|
|
|
CC_cublasLt111 := -gencode arch=compute_75,code=sm_75
|
|
|
|
CC_cublasLt111 += -gencode arch=compute_80,code=sm_80
|
|
|
|
CC_cublasLt111 += -gencode arch=compute_86,code=sm_86
|
|
|
|
|
|
|
|
|
2021-10-22 00:22:43 +00:00
|
|
|
all: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR) env
|
2022-07-27 02:38:17 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
|
2021-10-06 02:16:20 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION).so $(LIB)
|
2021-10-06 02:16:20 +00:00
|
|
|
|
2021-10-22 00:22:43 +00:00
|
|
|
cuda92: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR) env
|
2022-07-26 02:30:37 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA92) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR) -D NO_CUBLASLT
|
2021-10-18 04:21:39 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA92) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION)_nocublaslt.so $(LIB)
|
2021-10-06 02:16:20 +00:00
|
|
|
|
2022-07-26 05:34:14 +00:00
|
|
|
cuda10x_nomatmul: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR) env
|
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR) -D NO_CUBLASLT
|
2021-10-18 04:21:39 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION)_nocublaslt.so $(LIB)
|
2021-10-06 02:16:20 +00:00
|
|
|
|
2022-07-26 05:34:14 +00:00
|
|
|
cuda110_nomatmul: $(BUILD_DIR) env
|
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA110) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR) -D NO_CUBLASLT
|
2021-10-22 05:30:55 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA110) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION)_nocublaslt.so $(LIB)
|
2021-10-06 02:16:20 +00:00
|
|
|
|
2022-07-26 05:34:14 +00:00
|
|
|
cuda11x_nomatmul: $(BUILD_DIR) env
|
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA11x) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR) -D NO_CUBLASLT
|
2021-10-22 00:22:43 +00:00
|
|
|
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA11x) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION)_nocublaslt.so $(LIB)
|
2022-07-26 05:34:14 +00:00
|
|
|
|
|
|
|
cuda110: $(BUILD_DIR) env
|
|
|
|
$(NVCC) $(CC_cublasLt110) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
|
|
|
|
$(NVCC) $(CC_cublasLt110) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION).so $(LIB)
|
2022-07-26 05:34:14 +00:00
|
|
|
|
|
|
|
cuda11x: $(BUILD_DIR) env
|
|
|
|
$(NVCC) $(CC_cublasLt111) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
|
|
|
|
$(NVCC) $(CC_cublasLt111) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -DBUILD_CUDA -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_cuda$(CUDA_VERSION).so $(LIB)
|
2022-07-01 14:16:10 +00:00
|
|
|
|
|
|
|
cpuonly: $(BUILD_DIR) env
|
2022-08-01 02:41:56 +00:00
|
|
|
$(GPP) -std=c++14 -shared -fPIC -I $(ROOT_DIR)/csrc -I $(ROOT_DIR)/include $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes_$(CUDA_VERSION).so
|
2021-10-06 02:16:20 +00:00
|
|
|
|
2021-10-22 00:22:43 +00:00
|
|
|
env:
|
|
|
|
@echo "ENVIRONMENT"
|
|
|
|
@echo "============================"
|
2022-08-01 02:41:56 +00:00
|
|
|
@echo "CUDA_VERSION: $(CUDA_VERSION)"
|
|
|
|
@echo "============================"
|
2021-10-22 00:22:43 +00:00
|
|
|
@echo "NVCC path: $(NVCC)"
|
2021-11-29 05:31:03 +00:00
|
|
|
@echo "GPP path: $(GPP) VERSION: `$(GPP) --version | head -n 1`"
|
2021-10-22 00:22:43 +00:00
|
|
|
@echo "CUDA_HOME: $(CUDA_HOME)"
|
|
|
|
@echo "CONDA_PREFIX: $(CONDA_PREFIX)"
|
|
|
|
@echo "PATH: $(PATH)"
|
|
|
|
@echo "LD_LIBRARY_PATH: $(LD_LIBRARY_PATH)"
|
|
|
|
@echo "============================"
|
|
|
|
|
2021-10-06 02:16:20 +00:00
|
|
|
$(BUILD_DIR):
|
2022-07-01 14:16:10 +00:00
|
|
|
mkdir -p build
|
2021-10-06 02:16:20 +00:00
|
|
|
mkdir -p dependencies
|
|
|
|
|
|
|
|
$(ROOT_DIR)/dependencies/cub:
|
|
|
|
git clone https://github.com/NVlabs/cub $(ROOT_DIR)/dependencies/cub
|
2021-10-07 15:39:38 +00:00
|
|
|
cd dependencies/cub; git checkout 1.11.0
|
2021-10-06 02:16:20 +00:00
|
|
|
|
|
|
|
clean:
|
2022-08-01 02:41:56 +00:00
|
|
|
rm build/* ./bitsandbytes/libbitsandbytes.so
|
2021-10-06 02:16:20 +00:00
|
|
|
|
|
|
|
cleaneggs:
|
|
|
|
rm -rf *.egg*
|