how to control GPU memory usage by restrict KV cache allocation?
Hi there:
The tensorrt-llm tends to use as much memory for KV cache as it could in startup, but we're planing to run multiple trtllm instances or multiple models. How do I restrict the memory usage for each trtllm instance?
For example, we got an A100 with 80G memory, and try to split it to 2 40Gs for 2 models.
You can control that by setting kv_cache_free_gpu_mem_fraction. The number should between 0 ~ 1. When the number is close to 1, it will allocate more memory for kv cache.
You can control that by setting
kv_cache_free_gpu_mem_fraction. The number should between 0 ~ 1. When the number is close to 1, it will allocate more memory for kv cache.
That's working, thanks!
Hi @byshiue @forrestjgq , would you kindly tell me, where should I use this parameter? Cannot see it neither in trtllm-build parameters, nor in ModelRunnerCpp.from_dir params, nor in build_config of the model. Am I missing something or there is no support for this parameter when using the Cpp version? Thanks!
It is a runtime parameter and set here https://github.com/NVIDIA/TensorRT-LLM/blob/main/tensorrt_llm/runtime/model_runner_cpp.py#L169-L172
Thank you!
You can control that by setting
kv_cache_free_gpu_mem_fraction. The number should between 0 ~ 1. When the number is close to 1, it will allocate more memory for kv cache.
Hey there, I tried to set this parameter in a triton server instance serving a LLaMa3 8B. Going from 0.1 to 0.9 results in no change at all.
From nvidia-smi I still se 17847Mib fully booked. Both with 0.1 and 0.9.
Moreover I expect that a quantized version of the same model results in two different GPUs RAM footprints. Instead, I still see the same ~18gb booked.
How can I manage the ram footprint of the models?