@@ -22,18 +22,6 @@ class ocl_error : public ov::Exception {
22
22
23
23
#define OCL_ERR_MSG_FMT (error ) (" [GPU] " + std::string(error.what()) + std::string(" , error code: " ) + std::to_string(error.err()))
24
24
25
-
26
- // / WA: Force exit. Any opencl api call can be hang after CL_OUT_OF_RESOURCES.
27
- inline void force_exit () {
28
- std::cerr << " [GPU] force exit.\n "
29
- << " \t Due to the driver bug any subsequent OpenCL API call will cause application hang, "
30
- << " so GPU plugin can't finish correctly.\n "
31
- << " \t Please try to update the driver or reduce memory consumption "
32
- << " (use smaller batch size, less streams, lower precision, etc)"
33
- << " to avoid CL_OUT_OF_RESOURCES exception" << std::endl;
34
- std::_Exit (-1 );
35
- }
36
-
37
25
inline bool is_device_available (const device_info& info) {
38
26
ocl_device_detector detector;
39
27
auto devices = detector.get_available_devices (nullptr , nullptr );
@@ -46,22 +34,32 @@ inline bool is_device_available(const device_info& info) {
46
34
return false ;
47
35
}
48
36
49
- inline void rethrow_or_exit (std::string message, cl_int error, const device_info& info) {
37
+ inline void rethrow (std::string message, cl_int error, const device_info& info) {
50
38
if (error != CL_OUT_OF_RESOURCES) {
51
39
OPENVINO_THROW (message);
52
40
}
53
41
// For CL_OUT_OF_RESOURCES exception there are 2 possible cases:
54
- // 1. Real out of resource which means that plugin must exit
42
+ // 1. Real out of resource
55
43
// 2. Device is lost during application run, plugin may throw an exception
56
44
if (is_device_available (info)) {
57
- force_exit ();
45
+ std::stringstream ss;
46
+ ss << " [GPU] CL_OUT_OF_RESOURCES exception.\n "
47
+ << " \t Due to a driver bug, any subsequent OpenCL API call may cause the application to hang, "
48
+ << " so the GPU plugin may be unable to finish correctly.\n "
49
+ << " \t The CL_OUT_OF_RESOURCES error typically occurs in two cases:\n "
50
+ << " \t 1. An actual lack of memory for the current inference.\n "
51
+ << " \t 2. An out-of-bounds access to GPU memory from a kernel.\n "
52
+ << " \t For case 1, you may try adjusting some model parameters (e.g., using a smaller batch size, lower inference precision, fewer streams, etc.)"
53
+ << " to reduce the required memory size. For case 2, please submit a bug report to the OpenVINO team.\n "
54
+ << " \t Additionally, please try updating the driver to the latest version.\n " ;
55
+ OPENVINO_THROW (ss.str ());
58
56
} else {
59
57
OPENVINO_THROW (message);
60
58
}
61
59
}
62
60
63
- inline void rethrow_or_exit (const cl::Error& error, const device_info& info) {
64
- rethrow_or_exit (OCL_ERR_MSG_FMT (error), error.err (), info);
61
+ inline void rethrow (const cl::Error& error, const device_info& info) {
62
+ rethrow (OCL_ERR_MSG_FMT (error), error.err (), info);
65
63
}
66
64
67
65
} // namespace ocl
0 commit comments