【发布时间】:2016-09-12 16:50:12
【问题描述】:
我在 Windows 上使用 caffe,并且遇到了我无法确定的分段错误。它发生在程序退出时,WinDbg 说scalar deleting destructor,不知道内存分配在哪里。我的完整代码(目前是一个试图缩小范围的虚拟代码,但它只是偶尔发生):
#include <string>
#include <vector>
#include "boost/algorithm/string.hpp"
#include "google/protobuf/text_format.h"
#include <stdio.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/net.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/util/db.hpp"
#include "caffe/util/format.hpp"
#include "caffe/util/io.hpp"
using caffe::Blob;
using caffe::Caffe;
using caffe::Datum;
using caffe::Net;
using std::string;
namespace db = caffe::db;
int main(int argc, char** argv) {
// Initialize logging with program call. First thing that needs to be done
::google::InitGoogleLogging(argv[0]);
cv::Mat mean_;
// Set Caffe to run in CPU only mode
Caffe::set_mode(caffe::Caffe::CPU);
std::vector<std::string> labels_;
/*std::shared_ptr<Net<float>> caffe_test_net;*/
Net<float>* caffe_test_net;
caffe_test_net = new Net<float>("D:\\Development\\caffe-windows\\models\\bvlc_reference_caffenet\\deploy.prototxt", caffe::Phase::TEST);
caffe_test_net->CopyTrainedLayersFrom("D:\\Development\\caffe-windows\\models\\bvlc_reference_caffenet\\bvlc_reference_caffenet.caffemodel");
delete caffe_test_net;
return 1;
}
我已经在 unique 或 shared_ptr 中使用 caffe_net 进行了测试,但这根本没有区别。我不知道如何找到手头的问题。
【问题讨论】:
标签: c++ segmentation-fault caffe