我采用的时darknet V4版本,在使用CUDA10.2 CUDNN8.0.5 OPENCV4.5.3编译完毕darknet之后,做darknet.exe测试,可以检测到dog图片,采用调用摄像头检测也是可以,并且可以看到GPU已经被使用。但是在使用darknet.dll时,出现错误。加载网络到一定时就报错,具体错误代码如下:
151 route 147 -> 38 x 38 x 256
152 conv 512 3 x 3/ 2 38 x 38 x 256 -> 19 x 19 x 512 0.852 BF
153 route 152 116 -> 19 x 19 x1024
154 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
155 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
156 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
157 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
158 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
159 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
160 conv 255 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 255 0.189 BF
161 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.05
Total BFLOPS 128.459
avg_outputs = 1068395
Allocate additional workspace_size = 81.03 MB
Loading weights from .\yolov4.weights... Used GPU 0
net.optimized_memory = 0
mini_batch = 1, batch = 16, time_steps = 1, train = 1
Create CUDA-stream - 0
Create cudnn-handle 0
nms_kind: greedynms (1), beta = 0.600000
nms_kind: greedynms (1), beta = 0.600000
nms_kind: greedynms (1), beta = 0.600000
Done! Loaded 162 layers from weights-file
Darknet error location: E:\TRY\darknet-master\src\dark_cuda.c, cudnn_check_error, line #205
cuDNN Error: CUDNN_STATUS_BAD_PARAM: Bad file descriptor
seen 64, trained: 32032 K-images (500 Kilo-batches_64)
cuDNN status Error in: file: E:\TRY\darknet-master\src\convolutional_layer.c : cudnn_convolutional_setup() : line: 253 : build time: Aug 17 2021 - 20:41:18
cuDNN Error: CUDNN_STATUS_BAD_PARAM。
我调用darknet.dll采用的C# wrapper。其调用的代码为:
[DllImport(YoloLibraryGpu, EntryPoint = "init")]
internal static extern int InitializeYoloGpu(string configurationFilename, string weightsFilename, int gpuIndex);
[DllImport(YoloLibraryGpu, EntryPoint = "detect_image")]
internal static extern int DetectImageGpu(string filename, ref BboxContainer container);
[DllImport(YoloLibraryGpu, EntryPoint = "detect_mat")]
internal static extern int DetectImageGpu(IntPtr pArray, int nSize, ref BboxContainer container);
[DllImport(YoloLibraryGpu, EntryPoint = "dispose")]
internal static extern int DisposeYoloGpu();
[DllImport(YoloLibraryGpu, EntryPoint = "get_device_count")]
internal static extern int GetDeviceCount();
[DllImport(YoloLibraryGpu, EntryPoint = "get_device_name")]
internal static extern int GetDeviceName(int gpu, StringBuilder deviceName);
//每次程序都在初始化darknet网络的时候报错,即在下面这一行代码:
this._yoloWrapper = new YoloWrapper(config.ConfigFile, config.WeightsFile, config.NamesFile, gpuConfig);
后面又换到cuda11.0,cudnn换到8.2.0,问题还是照旧出现!!!!
请码友帮忙参谋一下,请收下我的膝盖!