在运行chatglm-4v-9b的时候出现了报错
ValueError: No available memory for the cache blocks. Try increasing `gpu_memory_utilization` when initializing the engine.
我的服务器的大小大概在30G
这是模型运行期间占用的内存大小
Memory profiling results: total_gpu_memory=31.73GiB
initial_memory_usage=26.64GiB peak_torch_memory=26.45GiB
memory_usage_post_profile=26.69GiB non_torch_memory=0.74GiB
kv_cache_size=3.91GiB gpu_memory_utilization=0.9
可以看出来基本占满了,gpu_memory_utilization默认开到了0.9,这个参数的高低代表了在使用GPU时,分配给模型和缓存的内存比例。果将 gpu_memory_utilization 设置为较高的值,这意味着模型可以使用更多的GPU内存。这通常会提高模型的性能,因为可以缓存更多的数据和中间结果,从而加快计算速度。虽然高的 gpu_memory_utilization 可以提高性能,但如果设置得过高,可能会导致GPU内存不足(OOM)错误,尤其是在处理大型模型或数据集时。
所以一开始我把数字改小,从0.9改到0.6,再改到0.3、0.1、甚至是0.05,都没有区别。所以我干脆反方向操作,把内存比例开大,改成0.95的时候,通了。