I tried to do some preprocess with a C shared library during training, but got an BUS ERROR. ( The reason why I want to use a shared library instead of coding in python is I don’t want to code the same thing in two different language. In addition, I want to maintain the consistency between training and deployment. I found there is a deployment in skimage, but its result is different with mine. Figuring out the difference in the source code of skimage would cost too much time. )
ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory.
This error should result from my .so library, because this code could work if the .so part was disabled. This shared library works individually, either.
All preprocess finished in a dataloader, I think there shouldn’t be any gpu issue involved and I didn’t sent img to cuda inside dataloader. I used nn.DataParallel to distribute data to multiple GPUs.
Below is how I loaded the library.
try: loaded_lib = ctypes.cdll.LoadLibrary( kwargs['libs_path'] ) print("Successfully loaded ", loaded_lib) except Exception as e: print(e) exit() self.function_c = loaded_lib.function_c self.function_c.argtypes = [ ndpointer(ctypes.c_ubyte, flags = "C_CONTIGUOUS"), ctypes.c_int, ctypes.c_int, ctypes.c_int, ndpointer(ctypes.c_float, flags = "C_CONTIGUOUS") ]
I didn’t use openmp or pthread in my C++ code but opencv, and I enabled openmp and pthread when I compiled it.
Does anyone has any idea?