Skip to content

Commit

Permalink
fix(api): show VRAM percent in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 6, 2023
1 parent 7a3a81a commit 39b9741
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/onnx_web/utils.py
Expand Up @@ -97,10 +97,12 @@ def run_gc(devices: Optional[List[DeviceParams]] = None):
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
mem_free, mem_total = torch.cuda.mem_get_info()
mem_pct = (1 - (mem_free / mem_total)) * 100
logger.debug(
"remaining CUDA VRAM usage: %s of %s",
"CUDA VRAM usage: %s of %s (%.2f%%)",
(mem_total - mem_free),
mem_total,
mem_pct,
)


Expand Down
4 changes: 3 additions & 1 deletion api/onnx_web/worker/pool.py
Expand Up @@ -291,7 +291,9 @@ def recycle(self):
logger.debug("shutting down worker for device %s", device)
worker.join(self.join_timeout)
if worker.is_alive():
logger.error("leaking worker for device %s could not be shut down", device)
logger.error(
"leaking worker for device %s could not be shut down", device
)

self.leaking[:] = [dw for dw in self.leaking if dw[1].is_alive()]

Expand Down

0 comments on commit 39b9741

Please sign in to comment.