remove CPU from default candidate list while GPUs more than 2 (#11753)
This commit is contained in:
@@ -123,6 +123,36 @@ void AutoSchedule::init(const ScheduleContext::Ptr& sContext) {
|
||||
std::list<DeviceInformation> validDevices =
|
||||
_autoSContext->_plugin->GetValidDevice(_autoSContext->_devicePriorities, _loadContext[ACTUALDEVICE].networkPrecision);
|
||||
|
||||
// check if device priority is enabled
|
||||
bool enableDevicePriority =
|
||||
std::find_if(std::begin(validDevices), std::end(validDevices), [](DeviceInformation& di) {
|
||||
return di.devicePriority > 0;
|
||||
}) != std::end(validDevices);
|
||||
|
||||
// for the case of -d "AUTO" or "AUTO: -xxx"
|
||||
if (!enableDevicePriority) {
|
||||
std::list<DeviceInformation>::iterator itCPUDevice;
|
||||
int GPUNums = 0, CPUNums = 0;
|
||||
for (auto it = validDevices.begin(); it != validDevices.end(); it++) {
|
||||
if (it->deviceName.find("GPU") != std::string::npos) {
|
||||
GPUNums++;
|
||||
}
|
||||
|
||||
if (it->deviceName.find("CPU") == 0) {
|
||||
CPUNums++;
|
||||
itCPUDevice = it;
|
||||
}
|
||||
}
|
||||
|
||||
// remove CPU from default candidate list for Cumulative Throughput mode
|
||||
if (GPUNums >= 2 && CPUNums > 0) {
|
||||
validDevices.erase(itCPUDevice);
|
||||
LOG_INFO("[AUTOPLUGIN]:GPUNums:%d, remove CPU from default candidate list for "
|
||||
"CUMULATIVE_THROUGHPUT",
|
||||
GPUNums);
|
||||
}
|
||||
}
|
||||
|
||||
std::string deviceName = "MULTI:";
|
||||
for (auto& device : validDevices) {
|
||||
deviceName += device.deviceName;
|
||||
|
||||
Reference in New Issue
Block a user