mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
117 lines
3.0 KiB
Makefile
117 lines
3.0 KiB
Makefile
GPU=1
|
|
CUDNN=0
|
|
OPENCV=0
|
|
OPENMP=0
|
|
DEBUG=0
|
|
|
|
|
|
VPATH=./src/:./examples
|
|
SLIB=libdarknet.so
|
|
ALIB=libdarknet.a
|
|
EXEC=darknet
|
|
OBJDIR=./obj/
|
|
|
|
# 设置编译参数
|
|
AR=ar
|
|
ARFLAGS=rcs
|
|
OPTS=-Ofast
|
|
LDFLAGS= -lm -pthread
|
|
COMMON= -Iinclude/ -Isrc/
|
|
CFLAGS= -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -Wno-write-strings -fPIC
|
|
|
|
CC=gcc
|
|
CPP=g++
|
|
ifeq ($(GPU), 1)
|
|
HIP_ROOT_PATH=/opt/dtk-22.04.2
|
|
|
|
CC=${HIP_ROOT_PATH}/bin/hipcc
|
|
CPP=${HIP_ROOT_PATH}/bin/hipcc
|
|
NVCC=${HIP_ROOT_PATH}/bin/hipcc
|
|
COMMON+= -DGPU -I${HIP_ROOT_PATH}/include/ -I${HIP_ROOT_PATH}/rocrand/include/ -I${HIP_ROOT_PATH}/hiprand/include/ -I${HIP_ROOT_PATH}/hipblas/include/
|
|
CFLAGS+= -DGPU -D__HIP_PLATFORM_HCC__
|
|
LDFLAGS+= -L${HIP_ROOT_PATH}/lib64 -lhipblas -lhiprand
|
|
endif
|
|
|
|
|
|
ifeq ($(OPENMP), 1)
|
|
CFLAGS+= -fopenmp
|
|
endif
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
OPTS=-O0 -g
|
|
endif
|
|
|
|
CFLAGS+=$(OPTS)
|
|
|
|
ifeq ($(OPENCV), 1)
|
|
COMMON+= -DOPENCV
|
|
CFLAGS+= -DOPENCV
|
|
LDFLAGS+= `pkg-config --libs opencv` -lstdc++
|
|
COMMON+= `pkg-config --cflags opencv`
|
|
endif
|
|
|
|
#ifeq ($(GPU), 1)
|
|
#COMMON+= -DGPU -I/usr/local/cuda/include/
|
|
#CFLAGS+= -DGPU
|
|
#LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
|
|
#endif
|
|
|
|
ifeq ($(CUDNN), 1)
|
|
COMMON+= -DCUDNN
|
|
CFLAGS+= -DCUDNN
|
|
LDFLAGS+= -lcudnn
|
|
endif
|
|
|
|
OBJ=gemm.o utils.o cuda.o deconvolutional_layer.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o \
|
|
softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o detection_layer.o route_layer.o upsample_layer.o box.o normalization_layer.o \
|
|
avgpool_layer.o layer.o local_layer.o shortcut_layer.o logistic_layer.o activation_layer.o rnn_layer.o gru_layer.o crnn_layer.o demo.o batchnorm_layer.o region_layer.o \
|
|
reorg_layer.o tree.o lstm_layer.o l2norm_layer.o yolo_layer.o iseg_layer.o
|
|
ifeq ($(OPENCV), 1)
|
|
OBJ+=image_opencv.o
|
|
endif
|
|
|
|
EXECOBJA=captcha.o lsd.o super.o art.o tag.o cifar.o go.o rnn.o segmenter.o regressor.o classifier.o coco.o yolo.o detector.o nightmare.o instance-segmenter.o darknet.o
|
|
#EXECOBJA=darknet.o
|
|
ifeq ($(GPU), 1)
|
|
LDFLAGS+= -lstdc++
|
|
OBJ+=convolutional_kernels.o deconvolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o avgpool_layer_kernels.o
|
|
endif
|
|
|
|
EXECOBJ = $(addprefix $(OBJDIR), $(EXECOBJA))
|
|
OBJS = $(addprefix $(OBJDIR), $(OBJ))
|
|
DEPS = $(wildcard src/*.h) Makefile include/darknet.h
|
|
|
|
all: obj backup results $(SLIB) $(ALIB) $(EXEC)
|
|
#all: obj results $(SLIB) $(ALIB) $(EXEC)
|
|
|
|
$(EXEC): $(EXECOBJ) $(ALIB)
|
|
$(CC) $(COMMON) $(CFLAGS) $^ -o $@ $(LDFLAGS)
|
|
|
|
$(ALIB): $(OBJS)
|
|
$(AR) $(ARFLAGS) $@ $^
|
|
|
|
$(SLIB): $(OBJS)
|
|
$(CC) $(CFLAGS) -shared $^ -o $@ $(LDFLAGS)
|
|
|
|
$(OBJDIR)%.o: %.cpp $(DEPS)
|
|
$(CPP) $(COMMON) $(CFLAGS) -c $< -o $@
|
|
|
|
$(OBJDIR)%.o: %.c $(DEPS)
|
|
$(CC) $(COMMON) $(CFLAGS) -c $< -o $@
|
|
|
|
$(OBJDIR)%.o: %.cu $(DEPS)
|
|
$(NVCC) -c $< -o $@ $(COMMON) $(CFLAGS)
|
|
|
|
obj:
|
|
mkdir -p obj
|
|
backup:
|
|
mkdir -p backup
|
|
results:
|
|
mkdir -p results
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
rm -rf $(OBJS) $(SLIB) $(ALIB) $(EXEC) $(EXECOBJ) $(OBJDIR)/*
|
|
|