prabindh / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
122 stars 46 forks source link

Error while compiling source #20

Closed ekorudiawan closed 6 years ago

ekorudiawan commented 7 years ago

I get an error when compiling your source code,,

deconvolutional_layer.c:(.text+0x8cc): undefined reference to forward_deconvolutional_layer_gpu' deconvolutional_layer.c:(.text+0x8d0): undefined reference toforward_deconvolutional_layer_gpu' deconvolutional_layer.c:(.text+0x8d8): undefined reference to backward_deconvolutional_layer_gpu' deconvolutional_layer.c:(.text+0x8dc): undefined reference tobackward_deconvolutional_layer_gpu' deconvolutional_layer.c:(.text+0x8e4): undefined reference to update_deconvolutional_layer_gpu' deconvolutional_layer.c:(.text+0x8e8): undefined reference toupdate_deconvolutional_layer_gpu' collect2: error: ld returned 1 exit status Makefile:99: recipe for target 'darknet' failed make: *** [darknet] Error 1

how to solve this problem

I use Jetson TX1 with Ubuntu 16.04, CUDA 8 and latest version OpenCV

prabindh commented 7 years ago

Could you update with the configuration in your Makefile, and what version of the darknet-cpp you are using (latest master, or older version) please ?

ekorudiawan commented 7 years ago

My configuration makefile :

GPU=1 CUDNN=1 OPENCV=1 DEBUG=0

I use latest master version

prabindh commented 7 years ago

If you are using darknet-cpp master, you should be able to see the lines in the Makefile that build deconvolution_layer.cu that exposes these functions, so it should link it. Could you confirm that you see the below in Makefile ? ' ifeq ($(GPU), 1) LDFLAGS+= -lstdc++ OBJ-GPU=convolutional_kernels.o deconvolutional_kernels.o '

ekorudiawan commented 7 years ago

Already written in Makefile, Here my complete makefile

GPU=1 CUDNN=1 OPENCV=1 DEBUG=1

ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \ -gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_35,code=sm_35 \ -gencode arch=compute_50,code=[sm_50,compute_50] \ -gencode arch=compute_52,code=[sm_52,compute_52]

VPATH=./src/ EXEC=darknet OBJDIR=./obj/ CC=gcc

EXEC_CPP=darknet-cpp SHARED_CPP=darknet-cpp-shared OBJDIR_CPP=./obj-cpp/ OBJDIR_CPP_SHARED=./obj-cpp-shared/ CC_CPP=g++ CFLAGS_CPP=-Wno-write-strings

NVCC=nvcc

OPTS=-Ofast LDFLAGS= -lm -pthread COMMON= CFLAGS=-Wall -Wfatal-errors

ifeq ($(DEBUG), 1) OPTS=-O0 -g endif

CFLAGS+=$(OPTS)

ifeq ($(OPENCV), 1) COMMON+= -DOPENCV CFLAGS+= -DOPENCV LDFLAGS+= pkg-config --libs opencv COMMON+= pkg-config --cflags opencv endif

LDFLAGS += -L./3rdparty

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-SHARED=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 captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o regressor.o classifier.o local_layer.o swag.o shortcut_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o lsd.o super.o voxel.o tree.o

ifeq ($(GPU), 1) LDFLAGS+= -lstdc++ OBJ-GPU=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 network_kernels.o avgpool_layer_kernels.o OBJ-SHARED+=$(OBJ-GPU) endif

OBJ=$(OBJ-SHARED) darknet.o OBJS = $(addprefix $(OBJDIR), $(OBJ)) DEPS = $(wildcard src/*.h) Makefile

OBJS_CPP = $(addprefix $(OBJDIR_CPP), $(OBJ)) OBJS_CPP_SHARED = $(addprefix $(OBJDIR_CPP_SHARED), $(OBJ-SHARED))

all: backup obj obj-cpp results $(EXEC) $(EXEC_CPP)

$(EXEC): obj clean $(OBJS) $(CC) $(COMMON) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)

$(OBJDIR)%.o: %.c $(DEPS) $(CC) $(COMMON) $(CFLAGS) -c $< -o $@

$(EXEC_CPP): obj-cpp clean-cpp $(OBJS_CPP) $(CC_CPP) $(COMMON) $(CFLAGS) $(OBJS_CPP) -o $@ $(LDFLAGS) $(SHARED_CPP): obj-shared-cpp clean-cpp $(OBJS_CPP_SHARED) $(CC_CPP) $(COMMON) $(CFLAGS) $(OBJS_CPP_SHARED) -o lib$@.so $(LDFLAGS) -shared

$(OBJDIR_CPP)%.o: %.c $(DEPS) $(CC_CPP) $(COMMON) $(CFLAGS_CPP) $(CFLAGS) -c $< -o $@ $(OBJDIR_CPP_SHARED)%.o: %.c $(DEPS) $(CC_CPP) $(COMMON) $(CFLAGS_CPP) $(CFLAGS) -fPIC -c $< -o $@

$(OBJDIR)%.o: %.cu $(DEPS) $(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@

$(OBJDIR_CPP)%.o: %.cu $(DEPS) $(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@ $(OBJDIR_CPP_SHARED)%.o: %.cu $(DEPS) $(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS) -fPIC" -c $< -o $@

obj: mkdir -p obj obj-cpp: mkdir -p obj-cpp obj-shared-cpp: mkdir -p obj-cpp-shared

backup: mkdir -p backup

results: mkdir -p results

.PHONY: clean

clean: rm -rf $(OBJS) $(EXEC) clean-cpp: rm -rf $(OBJS_CPP) $(OBJS_CPP_SHARED) $(EXEC_CPP) $(SHARED_CPP)

prabindh commented 7 years ago

Is it possible that the compilation of this .cu file failed in the compilation steps (and thus the .o file was not generated ?)

ekorudiawan commented 7 years ago

oke I know the problem, it cause by enable CUDNN . In original darknet source, I compile source with CUDNN no error, but in the end of compilation compiler says that libcudnn not compatible. This is not cause an error when compilation, darknet just skip compile with CUDNN. Darknet CPP not like that, when CUDNN not compatible, it return error message when compiling. I dont know why CUDNN not compatible, I use Jetson TX1 with ARM processor, when compiling in PC Desktop nothing message like that

prabindh commented 7 years ago

Could you share the compile logs please ?

prabindh commented 7 years ago

Please check with master, I was able to replicate this with Ubuntu 16.04 local setup. Surprisingly, this did not occur on 14.04.