在一个进程中实例化并调用接口处理图像时报错如下:
THCudaCheck FAIL file=C:\w\1\s\windows\pytorch\torch/csrc/generic/StorageSharing.cpp line=245 error=71 : operation not supported
Traceback (most recent call last):
File "", line 1, in
File "G:\venvs\py364\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "G:\venvs\py364\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
提供接口的类:
class DetectPerson(object):
def __init__(self):
self.det_model = Darknet(current_dir + "/data/yolov3.cfg")
self.det_model.load_weights(current_dir + '/data/yolov3.weights')
self.det_model.net_info['height'] = opt.inp_dim
self.det_inp_dim = int(self.det_model.net_info['height'])
assert self.det_inp_dim % 32 == 0
assert self.det_inp_dim > 32
self.det_model.cuda()
self.det_model.eval()
......
def detect_person(self, frame):
"""
将传入的原始图像经过神经网络算出图像中的人并标记返回
:param frame: 原始图像
:return: 标记人体的图
"""
......
return frame
调用的进程代码:
class VideoDetect(Process):
def __init__(self, queue_list):
super(VideoDetect, self).__init__()
self.queue_list = queue_list
**self.detect_person = DetectPerson()** # 此处实例化报错如上
......
# 运行进程
def run(self):
**self.detect_person = DetectPerson()** # 此处实例化可以正常运行
while True:
cam_id, frame = self.queue_list.get()
frame = self.detect_person.detect_person(frame)
......
先解决然后在这记录下这个问题,有空还需再研究下,有了解原因的小伙伴还望不吝赐教哈哈