-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
81 lines (67 loc) · 2.13 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ARCH := $(shell getconf LONG_BIT)
OS := $(shell cat /etc/issue)
RHEL_OS := $(shell cat /etc/redhat-release)
# Gets Driver Branch
DRIVER_BRANCH := $(shell nvidia-smi | grep Driver | cut -f 3 -d' ' | cut -f 1 -d '.')
# Location of the CUDA Toolkit
CUDA_PATH ?= "/usr/local/cuda-8.0"
ifeq (${ARCH},$(filter ${ARCH},32 64))
# If correct architecture and libnvidia-ml library is not found
# within the environment, build using the stub library
ifneq (,$(findstring Ubuntu,$(OS)))
DEB := $(shell dpkg -l | grep cuda)
ifneq (,$(findstring cuda, $(DEB)))
NVML_LIB := /usr/lib/nvidia-$(DRIVER_BRANCH)
else
NVML_LIB := /lib${ARCH}
endif
endif
ifneq (,$(findstring SUSE,$(OS)))
RPM := $(shell rpm -qa cuda*)
ifneq (,$(findstring cuda, $(RPM)))
NVML_LIB := /usr/lib${ARCH}
else
NVML_LIB := /lib${ARCH}
endif
endif
ifneq (,$(findstring CentOS,$(RHEL_OS)))
RPM := $(shell rpm -qa cuda*)
ifneq (,$(findstring cuda, $(RPM)))
NVML_LIB := /usr/lib${ARCH}/nvidia
else
NVML_LIB := /lib${ARCH}
endif
endif
ifneq (,$(findstring Red Hat,$(RHEL_OS)))
RPM := $(shell rpm -qa cuda*)
ifneq (,$(findstring cuda, $(RPM)))
NVML_LIB := /usr/lib${ARCH}/nvidia
else
NVML_LIB := /lib${ARCH}
endif
endif
ifneq (,$(findstring Fedora,$(RHEL_OS)))
RPM := $(shell rpm -qa cuda*)
ifneq (,$(findstring cuda, $(RPM)))
NVML_LIB := /usr/lib${ARCH}/nvidia
else
NVML_LIB := /lib${ARCH}
endif
endif
else
NVML_LIB := ../../lib${ARCH}/stubs/
$(info "libnvidia-ml.so.1" not found, using stub library.)
endif
ifneq (${ARCH},$(filter ${ARCH},32 64))
$(error Unknown architecture!)
endif
NVML_LIB += /usr/local/cuda-10.0/lib64
NVML_LIB_L := $(addprefix -L , $(NVML_LIB))
CFLAGS := -I /usr/local/cuda-10.0/include
LDFLAGS := -lnvidia-ml $(NVML_LIB_L)
all: VII-smi
VII-smi: VII-smi.o
$(CC) $< $(CFLAGS) $(LDFLAGS) -o $@
clean:
-@rm -f VII-smi.o
-@rm -f VII-smi