From f7903b53d0fdb6cf478eea244c84cd414cc01fcf Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Mon, 20 Feb 2023 21:47:12 -0600 Subject: [PATCH] chore(docs): describe memory profiling --- docs/dev-test.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/dev-test.md b/docs/dev-test.md index 4eb977df..42906231 100644 --- a/docs/dev-test.md +++ b/docs/dev-test.md @@ -7,6 +7,7 @@ - [API Development](#api-development) - [Style](#style) - [Models and Pipelines](#models-and-pipelines) + - [Memory Profiling](#memory-profiling) - [GUI Development](#gui-development) - [Updating Github Pages](#updating-github-pages) - [Watch mode](#watch-mode) @@ -31,6 +32,19 @@ whenever reasonably possible. Most pipeline stages will have a corresponding load function somewhere, like `upscale_stable_diffusion` and `load_stable_diffusion`. The load function should compare its parameters and reuse the existing pipeline when that is possible without causing memory access errors. Most logging from the load function should be `debug` level. +### Memory Profiling + +To track memory usage and leaks, run the API under `fil`: + +```shell +> fil-profile run -m flask --app=onnx_web.serve run --host=0.0.0.0 + +> fil-profile run -m waitress --listen=0.0.0.0:5000 onnx_web.serve:app +``` + +Using `memray` will break the CUDA bridge or driver somehow, and prevents hardware acceleration from working. That +makes it extremely time consuming to test any kind of memory leak. + ## GUI Development Run `make ci` to run lint, the tests, and build the bundle.