comfyui-client icon indicating copy to clipboard operation
comfyui-client copied to clipboard

Emptying/cleaning VRAM

Open arthurwolf opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

My program runs workflows all day long. After a while, VRAM usage at rest increases, and the entire thing seems to become sluggish. Doing the right click -> clean up vram thing seems to fix the issue. Right now I have to do that manually every few hours though.

Describe the solution you'd like

Some easy way to call the "clean vram" method, or a more general way to do API calls manually and some information about how to do this specific call.

Thanks a lot for considering this issue.

(Amazing project btw).

arthurwolf avatar Jan 08 '25 18:01 arthurwolf

Firstly, ComfyUI actually provides an API for cleaning memory (/free endpoint for releasing models/memory). API Documentation - Built-in Routes

Additionally, the class Client {} instance in this library actually wraps this API.

Apologies, I hadn't realized this wasn't mentioned in the README before you pointed it out... I will add documentation about this shortly.

If you need documentation on the Client object, you can check the auto-generated docs here: Client API Documentation

Usage example:

import { Client } from "@stable-canvas/comfyui-client";
const client = new Client();

await client.free({ unload_models: true, free_memory: true });

BTW, I’ve thought of one potential issue: if you’re using a custom node library that has a memory leak or bug where memory can’t be properly released, calling this API might not fully free the memory. That said, in most cases, this should suffice.

zhzLuke96 avatar Jan 09 '25 12:01 zhzLuke96

I was secretly hoping this was implemented but not documented, I'm really glad that's the case. Thanks a ton for the information, i'll be testing this over the weekend.

On Thu, Jan 9, 2025 at 1:25 PM len @.***> wrote:

Firstly, ComfyUI actually provides an API for cleaning memory (/free endpoint for releasing models/memory).

API Documentation - Built-in Routes https://docs.comfy.org/essentials/comms_routes#built-in-routes

Additionally, the class Client {} instance in this library actually wraps this API.

Apologies, I hadn't realized this wasn't mentioned in the README before you pointed it out... I will add documentation about this shortly.

If you need documentation on the Client object, you can check the auto-generated docs here: Client API Documentation https://stablecanvas.github.io/comfyui-client/classes/Client.html

Usage example:

import { Client } from @.***/comfyui-client";const client = new Client(); await client.free({ unload_models: true, free_memory: true });

BTW, I’ve thought of one potential issue: if you’re using a custom node library that has a memory leak or bug where memory can’t be properly released, calling this API might not fully free the memory. That said, in most cases, this should suffice.

— Reply to this email directly, view it on GitHub https://github.com/StableCanvas/comfyui-client/issues/18#issuecomment-2580031098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2SFKGQ6SEE2OXNSSVD6T2JZTFNAVCNFSM6AAAAABU2ROL7KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOBQGAZTCMBZHA . You are receiving this because you authored the thread.Message ID: @.***>

--

勇気とユーモア

arthurwolf avatar Jan 09 '25 22:01 arthurwolf