Используя пример dlib_mmod_train_find_cars_ex , после сохранения сети на диск она пытается вычислить и распечатать результаты обучения и тестирования.При вызове следующей строки:
cout << "training results: " << test_object_detection_function(net, images_train, boxes_train, test_box_overlap(), 0, options.overlaps_ignore);
Внутри «test_object_detection_function» (файл «validation.h») есть следующий вложенный цикл:
for (unsigned long i = 0; i < images.size(); ++i)
{
std::vector<mmod_rect> hits;
detector.to_tensor(&images[i], &images[i]+1, temp);
detector.subnet().forward(temp);
detector.loss_details().to_label(temp, detector.subnet(), &hits, adjust_threshold);
for (auto& label : impl::get_labels(truth_dets[i], hits))
{
std::vector<full_object_detection> truth_boxes;
std::vector<rectangle> ignore;
std::vector<std::pair<double,rectangle>> boxes;
// copy hits and truth_dets into the above three objects
for (auto&& b : truth_dets[i])
{
if (b.ignore)
{
ignore.push_back(b);
}
else if (b.label == label)
{
truth_boxes.push_back(full_object_detection(b.rect));
++total_true_targets;
}
}
for (auto&& b : hits)
{
if (b.label == label)
boxes.push_back(std::make_pair(b.detection_confidence, b.rect));
}
correct_hits += impl::number_of_truth_hits(truth_boxes, ignore, boxes, overlap_tester, all_dets, missing_detections, overlaps_ignore_tester);
}
}
После нескольких итераций (скажем, 1000)он выдает:
Error while calling cudaMalloc(&data, n) in file dlib/dnn/cuda_data_ptr.cpp:28. code: 2, reason: out of memory
Я запустил это на компьютере со следующими характеристиками:
i7 8700K
32 ГБ ОЗУ
2 x NVIDIA GeForce GTX 1070