forked from linkedin/dr-elephant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* linkedin#606 Integrated TonY GPU metrics to Dr. Elephant; linkedin#605
fixed NPE in TonYUtils * removed unused imports * Added number GPU requested metric; Updated nvidia-smi doc link * Addressed reviewer's comment (cherry picked from commit be6d03a)
- Loading branch information
Showing
10 changed files
with
332 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
app/com/linkedin/drelephant/tony/heuristics/TaskGPUHeuristic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Copyright 2019 LinkedIn Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.linkedin.drelephant.tony.heuristics; | ||
|
||
import com.linkedin.drelephant.analysis.Heuristic; | ||
import com.linkedin.drelephant.analysis.HeuristicResult; | ||
import com.linkedin.drelephant.analysis.HeuristicResultDetails; | ||
import com.linkedin.drelephant.analysis.Severity; | ||
import com.linkedin.drelephant.configurations.heuristic.HeuristicConfigurationData; | ||
import com.linkedin.drelephant.tony.data.TonyApplicationData; | ||
import com.linkedin.drelephant.tony.data.TonyTaskData; | ||
import com.linkedin.drelephant.tony.util.TonyUtils; | ||
import com.linkedin.drelephant.util.Utils; | ||
import com.linkedin.tony.Constants; | ||
import com.linkedin.tony.TonyConfigurationKeys; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.log4j.Logger; | ||
|
||
|
||
/** | ||
* For each type of task (e.g.: worker, ps), this heuristic checks the GPU utilization across all tasks of that type | ||
* and compares against some thresholds. The final severity is the highest severity across all task types. | ||
*/ | ||
public class TaskGPUHeuristic implements Heuristic<TonyApplicationData> { | ||
private static final Logger _LOGGER = Logger.getLogger(TaskGPUHeuristic.class); | ||
private static final String[] MAX_METRICS_TO_APPLY = { | ||
Constants.MAX_GPU_UTILIZATION, | ||
Constants.MAX_GPU_FB_MEMORY_USAGE, | ||
Constants.MAX_GPU_MAIN_MEMORY_USAGE}; | ||
private static final String[] AVG_METRICS_TO_APPLY = { | ||
Constants.AVG_GPU_UTILIZATION, | ||
Constants.AVG_GPU_FB_MEMORY_USAGE, | ||
Constants.AVG_GPU_MAIN_MEMORY_USAGE | ||
}; | ||
|
||
private HeuristicConfigurationData _heuristicConfData; | ||
|
||
/** | ||
* Constructor for {@link TaskGPUHeuristic}. | ||
* @param heuristicConfData the configuration for this heuristic | ||
*/ | ||
public TaskGPUHeuristic(HeuristicConfigurationData heuristicConfData) { | ||
this._heuristicConfData = heuristicConfData; | ||
} | ||
|
||
@Override | ||
public HeuristicResult apply(TonyApplicationData data) { | ||
_LOGGER.debug("Applying TaskGPUHeuristic"); | ||
Map<String, Map<Integer, TonyTaskData>> taskMap = data.getTaskMap(); | ||
Configuration conf = data.getConfiguration(); | ||
|
||
Set<String> taskTypes = com.linkedin.tony.util.Utils.getAllJobTypes(conf); | ||
Severity finalSeverity = Severity.NONE; | ||
List<HeuristicResultDetails> details = new ArrayList<>(); | ||
|
||
for (String taskType : taskTypes) { | ||
details.add(new HeuristicResultDetails("Number of " + taskType + " tasks", | ||
Integer.toString(taskMap.get(taskType).size()))); | ||
|
||
// get number of GPU resource requested, if any | ||
int numGPUsRequested = conf.getInt(TonyConfigurationKeys.getResourceKey(taskType, Constants.GPUS), 0); | ||
if (numGPUsRequested > 0) { | ||
details.add(new HeuristicResultDetails("Number of GPUs requested per " + taskType + " tasks", | ||
Integer.toString(numGPUsRequested))); | ||
} | ||
|
||
// get global max gpu utilization metrics | ||
for (String maxMetricToApply : MAX_METRICS_TO_APPLY) { | ||
double maxMetric = TonyUtils.getMaxMetricForTaskTypeAndMetricName(taskMap, taskType, maxMetricToApply); | ||
|
||
if (maxMetric <= 0 || Double.isNaN(maxMetric)) { | ||
details.add(new HeuristicResultDetails(maxMetricToApply + " in any " + taskType + " task", "Unknown")); | ||
continue; | ||
} | ||
details.add(new HeuristicResultDetails(maxMetricToApply + " in any " + taskType + " task", | ||
String.format("%.2f", maxMetric) + "%")); | ||
} | ||
|
||
// get global average gpu utilization metrics | ||
for (String avgMetricToApply : AVG_METRICS_TO_APPLY) { | ||
double avgMetric = TonyUtils.getAvgMetricForTaskTypeAndMetricName(taskMap, taskType, avgMetricToApply); | ||
|
||
if (avgMetric <= 0 || Double.isNaN(avgMetric)) { | ||
details.add(new HeuristicResultDetails(avgMetricToApply + " in any " + taskType + " task", "Unknown")); | ||
continue; | ||
} | ||
details.add(new HeuristicResultDetails(avgMetricToApply + " in any " + taskType + " task", | ||
String.format("%.2f", avgMetric) + "%")); | ||
} | ||
|
||
// compare to threshold and update severity | ||
// TODO: pass all metrics collected as not severe for now, update heuristic when collected enough data to | ||
// determine the appropriate threshold. | ||
} | ||
|
||
return new HeuristicResult(_heuristicConfData.getClassName(), _heuristicConfData.getHeuristicName(), finalSeverity, | ||
0, details); | ||
} | ||
|
||
@Override | ||
public HeuristicConfigurationData getHeuristicConfData() { | ||
return _heuristicConfData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@* | ||
* Copyright 2019 LinkedIn Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*@ | ||
<p> | ||
This heuristic shows GPU utilization and GPU memory utilization for each task type. | ||
Try to optimize your GPU utilization! | ||
</p> | ||
<p> | ||
GPU_UTILIZATION shows the percent of time over the past sample period during which one or more kernels was executing | ||
on the GPU. | ||
</p> | ||
<p> | ||
GPU_FB_MEMORY_USAGE shows the on-board frame buffer memory usage in percentage. Note, reported total memory is | ||
affected by ECC (error-correcting code) state. If ECC is enabled the total available memory is decreased by several | ||
percent, due to the requisite parity bits. The driver may also reserve a small amount of memory for internal use, even | ||
without active work on the GPU. | ||
</p> | ||
<p> | ||
GPU_MAIN_MEMORY_USAGE aka BAR1 memory usage shows the percentage of memory used to map the FB (device memory) so that | ||
it can be directly accessed by CPU. | ||
</p> | ||
<p> | ||
Above metrics are collected via nvidia-smi tools installed on the host, for more detailed information please visit | ||
<a href="https://developer.nvidia.com/nvidia-system-management-interface">nvidia-smi manual</a>. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.