MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetTFGPUDeviceName

Function GetTFGPUDeviceName

addons/triton/tensorflow_backend_tf.cc:310–332  ·  view source on GitHub ↗

Get the device name in model session given a non-negative device_id.

Source from the content-addressed store, hash-verified

308
309// Get the device name in model session given a non-negative device_id.
310TRITONTF_Error*
311GetTFGPUDeviceName(
312 std::string* device_name, tensorflow::Session* session, const int device_id)
313{
314 if (device_id >= 0) {
315 std::vector<tensorflow::DeviceAttributes> devices;
316 RETURN_IF_TF_ERROR(session->ListDevices(&devices));
317 for (const auto& d : devices) {
318 if (d.device_type() == "GPU" || d.device_type() == "gpu") {
319 // Session seems to be aware of all devices on the system,
320 // thus need to filter out the correct full name for the device
321 tensorflow::DeviceNameUtils::ParsedName parsed;
322 if (tensorflow::DeviceNameUtils::ParseFullName(d.name(), &parsed)) {
323 if (parsed.id == device_id) {
324 *device_name = d.name();
325 break;
326 }
327 }
328 }
329 }
330 }
331 return nullptr;
332}
333
334//
335// TensorImpl

Calls 3

nameMethod · 0.65
ListDevicesMethod · 0.45
device_typeMethod · 0.45

Tested by

no test coverage detected