summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorTim Dettmers <dettmers@g3030.hyak.local>2021-10-21 17:22:43 -0700
committerTim Dettmers <dettmers@g3030.hyak.local>2021-10-21 17:22:43 -0700
commit0fb378b4eed1fffc61b71439a5d5b11ad8335dd0 (patch)
treeb6991395aa0d889ca738bf25210c7187ce98ec4d /Makefile
parentd2f16726905f53952fc744147802076f6a1d8711 (diff)
Added compilation from source instructions; easier compilation.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile80
1 files changed, 46 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index 4fbe918..36ab33c 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,11 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
GPP:= /usr/bin/g++
+ifeq ($(CUDA_HOME),)
+ CUDA_HOME:= $(shell which nvcc | rev | cut -d'/' -f3- | rev)
+endif
NVCC := $(CUDA_HOME)/bin/nvcc
+
###########################################
CSRC := $(ROOT_DIR)/csrc
@@ -15,58 +19,66 @@ INCLUDE := -I $(CUDA_HOME)/include -I $(ROOT_DIR)/csrc -I $(CONDA_PREFIX)/inclu
LIB := -L $(CUDA_HOME)/lib64 -lcudart -lcuda -lcublas -lcurand -lcusparse -L $(CONDA_PREFIX)/lib
# NVIDIA NVCC compilation flags
-#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
-#COMPUTE_CAPABILITY += -gencode arch=compute_72,code=sm_72 # Volta
-#
-## 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
-#CC_CUDA10x += -gencode arch=compute_75,code=sm_75
-#
-#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
-
-COMPUTE_CAPABILITY := -gencode arch=compute_70,code=sm_70 # Volta
-
-
-all: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR)
+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
+COMPUTE_CAPABILITY += -gencode arch=compute_72,code=sm_72 # Volta
+
+# 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
+CC_CUDA10x += -gencode arch=compute_75,code=sm_75
+
+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
+
+all: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR) env
$(NVCC) $(COMPUTE_CAPABILITY) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
$(NVCC) $(COMPUTE_CAPABILITY) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
$(GPP) -std=c++11 -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes.so $(LIB)
-cuda92: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR)
+cuda92: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR) env
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA92) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA92) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
$(GPP) -std=c++11 -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes.so $(LIB)
-cuda10x: $(ROOT_DIR)/dependencies/cub $(BUILD_DIR)
+cuda10x: $(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)
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
$(GPP) -std=c++11 -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes.so $(LIB)
-cuda110: $(BUILD_DIR)
+cuda110: $(BUILD_DIR) env
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
$(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
$(GPP) -std=c++11 -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes.so $(LIB)
-cuda11x: $(BUILD_DIR)
- $(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
- $(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA10x) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
+cuda11x: $(BUILD_DIR) env
+ $(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA11x) -Xcompiler '-fPIC' --use_fast_math -Xptxas=-v -dc $(FILES_CUDA) $(INCLUDE) $(LIB) --output-directory $(BUILD_DIR)
+ $(NVCC) $(COMPUTE_CAPABILITY) $(CC_CUDA11x) -Xcompiler '-fPIC' -dlink $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o -o $(BUILD_DIR)/link.o
$(GPP) -std=c++11 -shared -fPIC $(INCLUDE) $(BUILD_DIR)/ops.o $(BUILD_DIR)/kernels.o $(BUILD_DIR)/link.o $(FILES_CPP) -o ./bitsandbytes/libbitsandbytes.so $(LIB)
+env:
+ @echo "ENVIRONMENT"
+ @echo "============================"
+ @echo "NVCC path: $(NVCC)"
+ @echo "GPP path: $(GPP)"
+ @echo "CUDA_HOME: $(CUDA_HOME)"
+ @echo "CONDA_PREFIX: $(CONDA_PREFIX)"
+ @echo "PATH: $(PATH)"
+ @echo "LD_LIBRARY_PATH: $(LD_LIBRARY_PATH)"
+ @echo "============================"
+
$(BUILD_DIR):
mkdir -p cuda_build
mkdir -p dependencies