Can't build darknet (CNN) with CUDNN support
Iḿ trying to build darknet with cudnn support but it does not complete under manjaro. It reports the following error:
g++ -DOPENCV -I/usr/include/opencv4/opencv2/ `pkg-config --cflags opencv` -DGPU -I/usr/local/cuda/include/
-DCUDNN -Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -Ofast -DOPENCV -DGPU -DCUDNN -I/usr/local/cudnn/include -c ./src/http_stream.cpp -o obj/http_stream.o
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
Package 'opencv', required by 'virtual:world', not found
./src/http_stream.cpp:46:10: fatal error: opencv2/opencv.hpp: Arquivo ou diretório inexistente
#include "opencv2/opencv.hpp"
^~~~~~~~~~~~~~~~~~~~
Here is my make file:
GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=1
AVX=0
OPENMP=0
LIBSO=0
# set GPU=1 and CUDNN=1 to speedup on GPU
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision using Tensor Cores) on GPU Tesla V100, Titan V, DGX-2
# set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)
DEBUG=0
ARCH= -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] \
-gencode arch=compute_61,code=[sm_61,compute_61]
OS := $(shell uname)
# Tesla V100
# ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]
# GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61
# GP100/Tesla P100 � DGX-1
# ARCH= -gencode arch=compute_60,code=sm_60
# For Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX - uncomment:
# ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]
# For Jetson Tx2 or Drive-PX2 uncomment:
# ARCH= -gencode arch=compute_62,code=[sm_62,compute_62]
VPATH=./src/
EXEC=darknet
OBJDIR=./obj/
ifeq ($(LIBSO), 1)
LIBNAMESO=darknet.so
APPNAMESO=uselib
endif
CC=gcc
CPP=g++
NVCC=nvcc
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON=
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas
ifeq ($(DEBUG), 1)
OPTS= -O0 -g
else
ifeq ($(AVX), 1)
CFLAGS+= -ffp-contract=fast -mavx -msse4.1 -msse4a
endif
endif
CFLAGS+=$(OPTS)
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV -I/usr/include/opencv4/opencv2/
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv`
COMMON+= `pkg-config --cflags opencv`
endif
ifeq ($(OPENMP), 1)
CFLAGS+= -fopenmp
LDFLAGS+= -lgomp
endif
ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
ifeq ($(OS),Darwin) #MAC
LDFLAGS+= -L/usr/local/cuda/lib -lcuda -lcudart -lcublas -lcurand
else
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif
endif
ifeq ($(CUDNN), 1)
COMMON+= -DCUDNN
ifeq ($(OS),Darwin) #MAC
CFLAGS+= -DCUDNN -I/usr/local/cuda/include
LDFLAGS+= -L/usr/local/cuda/lib -lcudnn
else
CFLAGS+= -DCUDNN -I/usr/local/cudnn/include
LDFLAGS+= -L/usr/local/cudnn/lib64 -lcudnn
endif
endif
ifeq ($(CUDNN_HALF), 1)
COMMON+= -DCUDNN_HALF
CFLAGS+= -DCUDNN_HALF
ARCH+= -gencode arch=compute_70,code=[sm_70,compute_70]
endif
OBJ=http_stream.o gemm.o utils.o cuda.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 ...
/usr/include/opencv4/opencv2/
?DID you build the opencv libraries before ?
do you absolutely NEED opencv support for this ? try
-DOPENCV=OFF
first. (libdarknet compiles fine without, you justwon't be able to run some demos, that need video)Hello berak thanks for the reply. Well Iḿ open to new title suggestions. Contents under /usr/include/opencv4/opencv2/
aruco freetype.hpp opencv_modules.hpp superres aruco.hpp fuzzy optflow superres.hpp bgsegm.hpp fuzzy.hpp optflow.hpp surface_matching bioinspired gapi phase_unwrapping surface_matching.hpp bioinspired.hpp gapi.hpp phase_unwrapping.hpp text calib3d hdf photo text.hpp calib3d.hpp hdf.hpp photo.hpp tracking ccalib hfs.hpp plot.hpp tracking.hpp ccalib.hpp highgui quality video core highgui.hpp quality.hpp video.hpp core_detect.hpp
and I do absolutely beed it. I did work in some older ubuntu version
try:
explicitly linking opencv libraries (get rid of all pkg-config cruft)
Same issue. Here is my current makefile.
@berak About
-I/usr/include/opencv4
: shouldn't the pkg-config file have this solved for the user? After`pkg-config --cflags opencv`
the user shouldn't have to deal with all these problems.@berak Oh, I just noticed that the pkg-config file is named
opencv4
now instead ofopencv
. I don't think it's a good idea. Version control should be done inside the file, and not by using a different file. It broke my compilation, and didn't have any informative message.