From 32ebdde271f97a45f1084141bf1451250228d183 Mon Sep 17 00:00:00 2001
From: lixiaoquan <radioheads@163.com>
Date: Sat, 10 Nov 2018 03:46:52 +0800
Subject: [PATCH] [OPENCL] Make use of cpu device when gpu device doesn't
 exist. (#2076)

---
 src/runtime/opencl/opencl_device_api.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/runtime/opencl/opencl_device_api.cc b/src/runtime/opencl/opencl_device_api.cc
index d5177fd95..6bb0948bc 100644
--- a/src/runtime/opencl/opencl_device_api.cc
+++ b/src/runtime/opencl/opencl_device_api.cc
@@ -245,6 +245,10 @@ void OpenCLWorkspace::Init(const std::string& type_key, const std::string& devic
       continue;
     }
     std::vector<cl_device_id> devices_matched = cl::GetDeviceIDs(platform_id, device_type);
+    if ((devices_matched.size() == 0) && (device_type == "gpu")) {
+      LOG(WARNING) << "Using CPU OpenCL device";
+      devices_matched = cl::GetDeviceIDs(platform_id, "cpu");
+    }
     if (devices_matched.size() > 0) {
       this->type_key = type_key;
       this->platform_id = platform_id;
-- 
GitLab