今天 在编译darknet的时候,出现了下面的错误:

/usr/local/cuda/include/crt/host_runtime.h:19:2: warning: #warning "crt/device_functions.h is an internal header file and must not be used directly.  Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp]
#warning "crt/device_functions.h is an internal header file and must not be used directly. Please use cuda_runtime_api.h or cuda_runtime.h instead."
^~~~~~~
/tmp/tmpxft_000057f7_00000000-5_convolutional_kernels.compute_52.cudafe1.stub.c: In function ‘void __device_stub__Z15binarize_kernelPfiS_(float*, int, float*)’:
/tmp/tmpxft_000057f7_00000000-5_convolutional_kernels.compute_52.cudafe1.stub.c:13:87: error: ‘__args_arr’ was not declared in this scope
__Z15binarize_kernelPfiS_(float *__par0, int __par1, float *__par2){__cudaSetupArgSimple(__par0, 0UL);__cudaSetupArgSimple(__par1, 8UL);__cudaSetupArgSimple(__par2, 16UL);__cudaLaunch(((char *)((void ( *)(float *, int, float *))binarize_kernel)));}
^
compilation terminated due to -Wfatal-errors.
Makefile:92: recipe for target 'obj/convolutional_kernels.o' failed
make: *** [obj/convolutional_kernels.o] Error 1

我的编译命令为:

cd darknet && cp  Makefile-GPU Makefile && make

解决方法

ifeq ($(GPU), 1) 
COMMON+= -DGPU -I/usr/local/cuda-9.0/include/
CFLAGS+= -DGPU
LDFLAGS+= -L/usr/local/cuda-9.0/lib64 -lcuda -lcudart -lcublas -lcurand
endif

把Makefile-GPU的关于cuda的配置指向你cuda路径就行了,我的是cuda-9.0

参考文献

[1].failing to compile with GPU=1 #200. ​​https://github.com/pjreddie/darknet/issues/200​