DynaSLAM icon indicating copy to clipboard operation
DynaSLAM copied to clipboard

Bus error (core dumped)

Open kxhit opened this issue 5 years ago • 29 comments

Hi! I met an error when running the code. I have tried this both with cpu and gpu.

Initialated Mask RCNN network...
Creating net instance...
Loading net parameters...
Bus error (core dumped)

I run the Check.py successfully and can run the code without [PATH TO MASK] [PATH TO OUTPUT] parameters. Could anyone help me? Thanks!!!

kxhit avatar Mar 13 '19 07:03 kxhit

Hi! I met an error when running the code. I have tried this both with cpu and gpu.

Initialated Mask RCNN network...
Creating net instance...
Loading net parameters...
Bus error (core dumped)

I run the Check.py successfully and can run the code without [PATH TO MASK] [PATH TO OUTPUT] parameters. Could anyone help me? Thanks!!!

Hello there! Is your problem solved? I also encountered the same problem.

fanguohao avatar Mar 16 '19 04:03 fanguohao

@fanguohao @kxhit Hello! I also encountered the same problem. My configuration is GTX 1080. The version of my opencv is 3.4.1

leah0206 avatar Mar 16 '19 04:03 leah0206

@BertaBescos I am sorry to bother you. Do you have any suggestions on this problem?

leah0206 avatar Mar 16 '19 04:03 leah0206

I have fixed this problem. Just change your opencv version to 2.4.11

jsdd25 avatar Mar 16 '19 13:03 jsdd25

@BertaBescos I can run the code with openCV2 but not OpenCV3. I find the program not fluent either with MaskRCNN or not. Waiting for your reply. Thanks!

kxhit avatar Mar 18 '19 03:03 kxhit

I could not reproduce the problem. I would suggest to do as @jsdd25 proposes and change OpenCV version to 2.4.11. We will write you back if we find out what the problem is.

jmfacil avatar Mar 19 '19 16:03 jmfacil

I also have this problem. I find the C++ can't call the MaskRCNN.py. DynaSLAM::SegmentDynObject::SegmentDynObject(): Assertion `this->py_module != NULL' failed. I don't know how to solve it. Can you help me?

fangzhangyun avatar Mar 28 '19 10:03 fangzhangyun

Are you using OpenCV 2.4.11? If not, I would recommend you to use it. We will try to fix this issue for newer versions within the next weeks.

BertaBescos avatar Mar 28 '19 10:03 BertaBescos

Are you using OpenCV 2.4.11? If not, I would recommend you to use it. We will try to fix this issue for newer versions within the next weeks.

Thanks for your answer,I had changed my OpenCV from 2.4.13 to 2.4.11 ,but it is useless, I am looking forward to your newer versions

fangzhangyun avatar Mar 28 '19 12:03 fangzhangyun

Then the problem must be something else. It should work without problems on OpenCV 2.4.11. Are you running it from the DynaSLAM directory path?

BertaBescos avatar Mar 28 '19 12:03 BertaBescos

Then the problem must be something else. It should work without problems on OpenCV 2.4.11. Are you running it from the DynaSLAM directory path?

I run it from DynaSLAM directory path like the ORB_SLAM2,it succeeded. when I added the parameter [PATH_TO_MASK] [PATH_TO_OUTPUT] to call the MaskRCNN, the problem has happened.

fangzhangyun avatar Mar 28 '19 12:03 fangzhangyun

Then the problem must be something else. It should work without problems on OpenCV 2.4.11. Are you running it from the DynaSLAM directory path?

I found the python version is the key problem. Mask_RCNN requires the Python3.4 + TensorFlow1.3 + Keras2.0.8,but your DynaSLAM is python2.7. I will try this way to build the DynaSLAM.

fangzhangyun avatar Mar 28 '19 13:03 fangzhangyun

Any luck with this error? I have the same problem

PushyamiKaveti avatar Jun 25 '19 22:06 PushyamiKaveti

I have meet the trouble for several days.But ,i can't solver it .my system is Ubuntu16.04+cuda8.0+cudnn6+opencv 2.4.11+orbslam2 environment.Can anyone help me ?

qxdaaaaa avatar Jun 26 '19 08:06 qxdaaaaa

I got it working finally. The issue on my side was opencv 3.3. It works with opencv 2.4.10. When I debugged I found that the problem is in Conversion.cc inside the method toNDArray(const cv::Mat& m). The method has two sections for two opencv versions (2 and 3) in case of opencv 3 the PyObject returned from Mat seems to be the problem when it gets passed to GetDynSeg() of MaskRCNN.py. I am trying to fix it now.

PushyamiKaveti avatar Jun 26 '19 20:06 PushyamiKaveti

You are too good!Can you tell me about your configuration environment in detail ?and have you run check.py?I have trouble again yesterday, maybe I have to configure the environment for this code again.

qxdaaaaa avatar Jun 27 '19 01:06 qxdaaaaa

@PushyamiKaveti Can you help me ?

qxdaaaaa avatar Jun 27 '19 02:06 qxdaaaaa

@BertaBescos Can you help me? When I give [PATH TO MASK] [PATH TO OUTPUT] ,It is "core dumped".

qxdaaaaa avatar Jun 28 '19 05:06 qxdaaaaa

@PushyamiKaveti @BertaBescos My environment is :Ubuntu16.04 +cuda8.0+cudnn6+opencv2.4.11+python2.7+orbslam2.

qxdaaaaa avatar Jun 28 '19 05:06 qxdaaaaa

I have solved this problem, thank you for your help.@PushyamiKaveti @BertaBescos

qxdaaaaa avatar Jun 30 '19 08:06 qxdaaaaa

I have solved this problem, thank you for your help.@PushyamiKaveti @BertaBescos

I meet the same problem, can you help me? My error is Bus error too, my python is 2.7, opencv version is 2.4.11,and Ican run Check.py successfully. @qxdaaaaa

jzpwhu1996 avatar Nov 14 '19 10:11 jzpwhu1996

I meet the same problem, can you help me? My error is Bus error too, my python is 2.7, opencv version is 2.4.11 and 3.4.1,tensorflow-gpu1.4.0 and I can run Check.py successfully. @qxdaaaaa @kxhit @fanguohao

zxGH86 avatar Dec 08 '19 12:12 zxGH86

you can test the tensflow .the problem ,may be the tensflow.you can use tf==cpu------------------ 原始邮件 ------------------ 发件人: "zxGH86"[email protected] 发送时间: 2019年12月8日(星期天) 晚上8:51 收件人: "BertaBescos/DynaSLAM"[email protected]; 抄送: "qxd"[email protected];"Mention"[email protected]; 主题: Re: [BertaBescos/DynaSLAM] Bus error (core dumped) (#16)

I meet the same problem, can you help me? My error is Bus error too, my python is 2.7, opencv version is 2.4.11 and 3.4.1,tensorflow-gpu1.4.0 and I can run Check.py successfully. @qxdaaaaa @kxhit @fanguohao

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

qxdaaaaa avatar Dec 08 '19 14:12 qxdaaaaa

Thanks,@qxdaaaaa. I just test the masknet .cc find that the function cv::Mat SegmentDynObject::GetSegmentation(cv::Mat &image,std::string dir, std::string name){ .... PyObject* py_mask_image = PyObject_CallMethod(this->net, const_cast<char*>(this->get_dyn_seg.c_str()),"(O)",py_image); ......} doesn't working, how to solve this problem?

zxGH86 avatar Dec 09 '19 09:12 zxGH86

I meet the same problem, can you help me? My error is Bus error too, my python is 2.7, opencv version is 2.4.11 and 3.4.1,tensorflow-gpu1.4.0 and I can run Check.py successfully.

I‘d like to ask if cuda10.0 + tensorflow1.13.1 is ok? I think I have correctly installed with python2 but I can't pass check when I use terminal to run 'python check.py'. I think I need you help.....

SuperBigBrother avatar Mar 06 '20 06:03 SuperBigBrother

I have solved this problem, thank you for your help.@PushyamiKaveti @BertaBescos

How did you solve the problem? @PushyamiKaveti @qxdaaaaa My system is Python 2.7, OpenCV 3.3.0 , tensorflow-gpu=1.13.1, CUDA 10.0 and I can run Check.py successfully.

ghost avatar Jun 27 '20 17:06 ghost

I have solved this problem, thank you for your help.@PushyamiKaveti @BertaBescos

How did you solve the problem? @PushyamiKaveti @qxdaaaaa My system is Python 2.7, OpenCV 3.3.0 , tensorflow-gpu=1.13.1, CUDA 10.0 and I can run Check.py successfully.

Have you run successfully in cuda10?

KaninchenM avatar Oct 15 '20 07:10 KaninchenM

I got it working finally. The issue on my side was opencv 3.3. It works with opencv 2.4.10. When I debugged I found that the problem is in Conversion.cc inside the method toNDArray(const cv::Mat& m). The method has two sections for two opencv versions (2 and 3) in case of opencv 3 the PyObject returned from Mat seems to be the problem when it gets passed to GetDynSeg() of MaskRCNN.py. I am trying to fix it now.

Yes,it is the problem,the Conversion.cc failed with opencv3.And I have fixed it, here is my Conversion.cc:

#include "Conversion.h" #include

namespace DynaSLAM {

static void init() { import_array(); }

static PyObject* failmsgp(const char *fmt, ...) { char str[1000];

va_list ap;
va_start(ap, fmt);
vsnprintf(str, sizeof(str), fmt, ap);
va_end(ap);

PyErr_SetString(PyExc_TypeError, str);
return 0;

}

using namespace cv; //=================== ERROR HANDLING =========================================================

static int failmsg(const char *fmt, ...) { char str[1000];

va_list ap;
va_start(ap, fmt);
vsnprintf(str, sizeof(str), fmt, ap);
va_end(ap);

PyErr_SetString(PyExc_TypeError, str);
return 0;

}

//=================== THREADING ============================================================== class PyAllowThreads { public: PyAllowThreads() : _state(PyEval_SaveThread()) { } ~PyAllowThreads() { PyEval_RestoreThread(_state); } private: PyThreadState* _state; };

class PyEnsureGIL { public: PyEnsureGIL() : _state(PyGILState_Ensure()) { } ~PyEnsureGIL() { PyGILState_Release(_state); } private: PyGILState_STATE _state; };

enum { ARG_NONE = 0, ARG_MAT = 1, ARG_SCALAR = 2 };

class NumpyAllocator: public MatAllocator { public: NumpyAllocator() { stdAllocator = Mat::getStdAllocator(); } ~NumpyAllocator() { }

UMatData* allocate(PyObject* o, int dims, const int* sizes, int type,
		size_t* step) const {
	UMatData* u = new UMatData(this);
	u->data = u->origdata = (uchar*) PyArray_DATA((PyArrayObject*) o);
	npy_intp* _strides = PyArray_STRIDES((PyArrayObject*) o);
	for (int i = 0; i < dims - 1; i++)
		step[i] = (size_t) _strides[i];
	step[dims - 1] = CV_ELEM_SIZE(type);
	u->size = sizes[0] * step[0];
	u->userdata = o;
	return u;
}

UMatData* allocate(int dims0, const int* sizes, int type, void* data,
		size_t* step, int flags, UMatUsageFlags usageFlags) const {
	if (data != 0) {
		CV_Error(Error::StsAssert, "The data should normally be NULL!");
		// probably this is safe to do in such extreme case
		return stdAllocator->allocate(dims0, sizes, type, data, step, flags,
				usageFlags);
	}
	PyEnsureGIL gil;

	int depth = CV_MAT_DEPTH(type);
	int cn = CV_MAT_CN(type);
	const int f = (int) (sizeof(size_t) / 8);
	int typenum =
			depth == CV_8U ? NPY_UBYTE :
			depth == CV_8S ? NPY_BYTE :
			depth == CV_16U ? NPY_USHORT :
			depth == CV_16S ? NPY_SHORT :
			depth == CV_32S ? NPY_INT :
			depth == CV_32F ? NPY_FLOAT :
			depth == CV_64F ?
								NPY_DOUBLE :
								f * NPY_ULONGLONG + (f ^ 1) * NPY_UINT;
	int i, dims = dims0;
	cv::AutoBuffer<npy_intp> _sizes(dims + 1);
	for (i = 0; i < dims; i++)
		_sizes[i] = sizes[i];
	if (cn > 1)
		_sizes[dims++] = cn;
	PyObject* o = PyArray_SimpleNew(dims, _sizes, typenum);
	if (!o)
		CV_Error_(Error::StsError,
				("The numpy array of typenum=%d, ndims=%d can not be created", typenum, dims));
	return allocate(o, dims0, sizes, type, step);
}

bool allocate(UMatData* u, int accessFlags,
		UMatUsageFlags usageFlags) const {
	return stdAllocator->allocate(u, accessFlags, usageFlags);
}

void deallocate(UMatData* u) const {
	if (u) {
		PyEnsureGIL gil;
		PyObject* o = (PyObject*) u->userdata;
		Py_XDECREF(o);
		delete u;
	}
}

const MatAllocator* stdAllocator;

};

NumpyAllocator g_numpyAllocator;

NDArrayConverter::NDArrayConverter() { init(); }

void NDArrayConverter::init() { import_array(); }

cv::Mat NDArrayConverter::toMat(const PyObject o) { cv::Mat m; bool allowND = true; if (!PyArray_Check(o)) { failmsg("argument is not a numpy array"); if (!m.data) m.allocator = &g_numpyAllocator; } else { PyArrayObject oarr = (PyArrayObject*) o;

	bool needcopy = false, needcast = false;
	int typenum = PyArray_TYPE(oarr), new_typenum = typenum;
	int type = typenum == NPY_UBYTE ? CV_8U : typenum == NPY_BYTE ? CV_8S :
				typenum == NPY_USHORT ? CV_16U :
				typenum == NPY_SHORT ? CV_16S :
				typenum == NPY_INT ? CV_32S :
				typenum == NPY_INT32 ? CV_32S :
				typenum == NPY_FLOAT ? CV_32F :
				typenum == NPY_DOUBLE ? CV_64F : -1;

	if (type < 0) {
		if (typenum == NPY_INT64 || typenum == NPY_UINT64
				|| type == NPY_LONG) {
			needcopy = needcast = true;
			new_typenum = NPY_INT;
			type = CV_32S;
		} else {
			failmsg("Argument data type is not supported");
			m.allocator = &g_numpyAllocator;
			return m;
		}
	}

#ifndef CV_MAX_DIM const int CV_MAX_DIM = 32; #endif

	int ndims = PyArray_NDIM(oarr);
	if (ndims >= CV_MAX_DIM) {
		failmsg("Dimensionality of argument is too high");
		if (!m.data)
			m.allocator = &g_numpyAllocator;
		return m;
	}

	int size[CV_MAX_DIM + 1];
	size_t step[CV_MAX_DIM + 1];
	size_t elemsize = CV_ELEM_SIZE1(type);
	const npy_intp* _sizes = PyArray_DIMS(oarr);
	const npy_intp* _strides = PyArray_STRIDES(oarr);
	bool ismultichannel = ndims == 3 && _sizes[2] <= CV_CN_MAX;

	for (int i = ndims - 1; i >= 0 && !needcopy; i--) {
		// these checks handle cases of
		//  a) multi-dimensional (ndims > 2) arrays, as well as simpler 1- and 2-dimensional cases
		//  b) transposed arrays, where _strides[] elements go in non-descending order
		//  c) flipped arrays, where some of _strides[] elements are negative
		if ((i == ndims - 1 && (size_t) _strides[i] != elemsize)
				|| (i < ndims - 1 && _strides[i] < _strides[i + 1]))
			needcopy = true;
	}

	if (ismultichannel && _strides[1] != (npy_intp) elemsize * _sizes[2])
		needcopy = true;

	if (needcopy) {

		if (needcast) {
			o = PyArray_Cast(oarr, new_typenum);
			oarr = (PyArrayObject*) o;
		} else {
			oarr = PyArray_GETCONTIGUOUS(oarr);
			o = (PyObject*) oarr;
		}

		_strides = PyArray_STRIDES(oarr);
	}

	for (int i = 0; i < ndims; i++) {
		size[i] = (int) _sizes[i];
		step[i] = (size_t) _strides[i];
	}

	// handle degenerate case
	if (ndims == 0) {
		size[ndims] = 1;
		step[ndims] = elemsize;
		ndims++;
	}

	if (ismultichannel) {
		ndims--;
		type |= CV_MAKETYPE(0, size[2]);
	}

	if (ndims > 2 && !allowND) {
		failmsg("%s has more than 2 dimensions");
	} else {

		m = Mat(ndims, size, type, PyArray_DATA(oarr), step);
		m.u = g_numpyAllocator.allocate((PyObject*)o, ndims, size, type, step);
		m.addref();

		if (!needcopy) {
			Py_INCREF(o);
		}
	}
	m.allocator = &g_numpyAllocator;
}
return m;

}

PyObject* NDArrayConverter::toNDArray(const cv::Mat& m) { if (!m.data) Py_RETURN_NONE; Mat temp, p = (Mat) &m; if (!p->u || p->allocator != &g_numpyAllocator) { temp.allocator = &g_numpyAllocator; ERRWRAP2(m.copyTo(temp)); p = &temp; } std::cout<u->refcount<<std::endl; std::cout<u->userdata<<std::endl; PyObject* o = (PyObject*) p->u->userdata; Py_INCREF(o); return o;

}

}

hanxiumeng avatar Jan 18 '21 14:01 hanxiumeng

@hanxiumeng your code doesn't work either, leads to the same error could you share the modified conversion.cc file? did you get it to work with opencv 3?

mobiiin avatar Jul 15 '21 09:07 mobiiin