MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / reportGpuMemory

Function reportGpuMemory

samples/common/sampleInference.cpp:1161–1177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1159namespace
1160{
1161size_t reportGpuMemory()
1162{
1163 static size_t prevFree{0};
1164 size_t free{0};
1165 size_t total{0};
1166 size_t newlyAllocated{0};
1167 cudaCheck(cudaMemGetInfo(&free, &total));
1168 sample::gLogInfo << "Free GPU memory = " << free / 1024.0_MiB << " GiB";
1169 if (prevFree != 0)
1170 {
1171 newlyAllocated = (prevFree - free);
1172 sample::gLogInfo << ", newly allocated GPU memory = " << newlyAllocated / 1024.0_MiB << " GiB";
1173 }
1174 sample::gLogInfo << ", total GPU memory = " << total / 1024.0_MiB << " GiB" << std::endl;
1175 prevFree = free;
1176 return newlyAllocated;
1177}
1178} // namespace
1179
1180//! Returns true if deserialization is slower than expected or fails.

Callers 1

timeDeserializeFunction · 0.85

Calls 1

cudaCheckFunction · 0.85

Tested by

no test coverage detected