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

Function AvailableGPUMemory

tensorflow/core/grappler/devices.cc:69–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69int64 AvailableGPUMemory(int gpu_id) {
70#if GOOGLE_CUDA
71 // Look up the device, to see its attributes.
72 se::Platform* gpu_platform = GPUMachineManager();
73 CHECK_LT(gpu_id, gpu_platform->VisibleDeviceCount());
74 se::StreamExecutor* se = gpu_platform->ExecutorForDevice(gpu_id).ValueOrDie();
75 int64 total_memory, available_memory;
76 CHECK(se->DeviceMemoryUsage(&available_memory, &total_memory));
77
78 return available_memory;
79#else
80 return 0;
81#endif
82}
83
84int GetNumAvailableLogicalCPUCores() { return port::NumSchedulableCPUs(); }
85

Callers

nothing calls this directly

Calls 4

GPUMachineManagerFunction · 0.85
VisibleDeviceCountMethod · 0.45
ExecutorForDeviceMethod · 0.45
DeviceMemoryUsageMethod · 0.45

Tested by

no test coverage detected