cuDNN error: CUDNN_STATUS_EXECUTION_FAILED

I am trying to inference an object detection model . I am having multiple camera with the same use case so I use multi threading to handle it.

I have an Object Model() . This contains initialization of any model based on the parameter.

I do have the following function inside to handle the pre-processing of the raw images, mainly for model inference.

 def preprocess(self, image):
    try:
        torch.cuda.synchronize()
        self.im = letterbox(self.im0, (640, 640), stride=self.stride)[0]  # padded resize
        self.im = self.im.transpose((2, 0, 1))[::-1]  # HWC to CHW, BGR to RGB
        self.im = np.ascontiguousarray(self.im)  # contiguous
        self.im = torch.from_numpy(self.im).to(self.DEVICE).float()  # uint8 to fp16/32
        self.im /= 255  # 0 - 255 to 0.0 - 1.0
        if len(self.im.shape) == 3:
            self.im = self.im[None]  # expand for batch dimension
        return self.im
    except Exception as e:
        torch.cuda.synchronize()
        self.logger.print_function_error(f"ModelInference - Error in preprocess(); {e}")
        self.logger.print_function_error(f"ModelInference - traceback {traceback.format_exc()}")
        raise  # Re-raise exception to handle it later if needed
        return None
        

and the predictor

def predict(self, image):
    try:
        im = self.preprocess(image)
        self.pred = self.model(im)
        self.pred = non_max_suppression(self.pred, self.conf_thres, self.iou_thres, self.classes, self.agnostic_nms, max_det=self.max_det)
    except Exception as e:
        self.logger.print_function_error(f"ModelInference - Error in predictObj(); {e}")
        self.logger.print_function_error(f"ModelInference - traceback {traceback.format_exc()}")
        return None  # Return None or appropriate value in case of error
    return self.detectionsBoxV3()

Now when I call this object in the main thread and execute it, I do not have any issues

When I create multiple objects of the Model() and run it in different threads , initially it works seamlessly . After sometime i get this error

2024-09-20 16:43:13,534 - ERROR - ModelInference - Error in predictObj(); cuDNN error: CUDNN_STATUS_MAPPING_ERROR
2024-09-20 16:43:13,535 - ERROR - ModelInference - traceback Traceback (most recent call last):
  File "/home/test/Project/Module/Side/ModelInference.py", line 214, in predict
    self.pred = self.model(im)
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/Project/Module/models/yolo.py", line 209, in forward
    return self._forward_once(x, profile, visualize)  # single-scale inference, train
  File "/home/test/Project/Module/models/yolo.py", line 121, in _forward_once
    x = m(x)  # run
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/Project/Module/models/common.py", line 167, in forward
    return self.cv3(torch.cat((self.m(self.cv1(x)), self.cv2(x)), 1))
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/container.py", line 217, in forward
    input = module(input)
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/Project/Module/models/common.py", line 120, in forward
    return x + self.cv2(self.cv1(x)) if self.add else self.cv2(self.cv1(x))
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/Project/Module/models/common.py", line 59, in forward_fuse
    return self.act(self.conv(x))
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 463, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/home/test/env/python_files/auto/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: cuDNN error: CUDNN_STATUS_MAPPING_ERROR

even after thread handling to stop and restart on its own, I get a constant the below error until I restart the program

2024-09-21 10:16:21,356 - ERROR - ModelInference - Error in predictObj(); CUDA error: misaligned address
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật