Darknet: Can't use detector demo on video file

Created on 10 Nov 2017  Â·  6Comments  Â·  Source: pjreddie/darknet

I'm following the instructions on https://pjreddie.com/darknet/yolo/, but I can't make the detector work with video file. I don't have any webcam connected to the PC.

I managed to compile with OpenCV and CUDA, but when I try to use ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights <video file>, I get ./darknet: error while loading shared libraries: libcudart.so.9.0: cannot open shared object file: No such file or directory error. My Makefile is set like this:

GPU=1
CUDNN=0
OPENCV=1
OPENMP=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_20,code=[sm_20,sm_21] \ This one is deprecated?

# This is what I use, uncomment if you know your arch and want to specify
# ARCH= -gencode arch=compute_52,code=compute_52

VPATH=./src/:./examples
SLIB=libdarknet.so
ALIB=libdarknet.a
EXEC=darknet
OBJDIR=./obj/

CC=gcc
NVCC=nvcc
NVCC += -D_FORCE_INLINES
AR=ar
ARFLAGS=rcs
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Iinclude/ -Isrc/
CFLAGS=-Wall -Wno-unknown-pragmas -Wfatal-errors -fPIC

EDIT:
Trying to remake with different Makefile. I changed from NVCC=nvcc to NVCC=/usr/local/cuda-9.0/bin/nvcc, but I'm getting /usr/bin/ld: warning: libcudart.so.7.5, needed by /usr/local/lib/libopencv_core.so, may conflict with libcudart.so.9.0 warning now during the build.

Most helpful comment

Make sure libcudart.so.9.0 is in your LD_LIBRARY_PATH. You can add it in your user's .bashrc, or use export in the current session, which will only work for the current session or launch darknet with a preamble, which will only set it for the command.

Assuming the .so is in /usr/local/cuda-9.0/lib64/, you need to run the following:
_export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/:$LD_LIBRARY_PATH_
if it works, you can add that line in your .bashrc
You can also launch darknet like this:
_LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/ ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights

All 6 comments

you need to rebuild your opencv with cuda 9.0

@FatherOfHam When trying to build with CUDA 9.0, I get the error described on edit, saying that CUDA 9.0 may conflict with CUDA 7.5 (I don't really know where CUDA 7.5 is used on the Makefile).

your opencv is compiled with cuda 7.5, not the darknet. Try to rebuild your opencv with cuda 9.0.

Hello, everyone!
I compiled OpenCV with CUDA 9.0 (no previous version) and I get the same error even when trying to load an image:
./darknet imtest data/eagle.jpg gives:
./darknet: error while loading shared libraries: libcudart.so.9.0: cannot open shared object file: No such file or directory

Are there any env variables that I'm missing or were does darknet look for this library and expecting it to be?

Has anyone managed to solve the issue?

Make sure libcudart.so.9.0 is in your LD_LIBRARY_PATH. You can add it in your user's .bashrc, or use export in the current session, which will only work for the current session or launch darknet with a preamble, which will only set it for the command.

Assuming the .so is in /usr/local/cuda-9.0/lib64/, you need to run the following:
_export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/:$LD_LIBRARY_PATH_
if it works, you can add that line in your .bashrc
You can also launch darknet like this:
_LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/ ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights

Was this page helpful?
0 / 5 - 0 ratings