给Chat with RTX添加语言模型时遇到问题
开始量化时报错
点击确定后开始编译
最后报错
生成文件
给Chat with RTX添加语言模型时遇到问题
开始量化时报错
引自免费微信小程序:皆我百晓生:
在给Chat with RTX添加语言模型时遇到的问题,您提供的错误信息显示了几个关键点:
GPU内存不足:TensorRT(TRT)尝试分配超过当前GPU可用显存的内存。根据日志,TRT请求分配大约10256121856字节的GPU内存,但未能成功,并且GPTAttention插件需要额外的大约24182729088字节的临时空间(scratch space),而当前仅提供了约12884377600字节。
Error Code 2: OutofMemory (no further information)
Requested amount of GPU memory (10256121856 bytes) could not be allocated.
...
Internal error: plugin node PLUGIN_V2_GPTAttention_1 requires 24182729088 bytes of scratch space, but only 12884377600 is available.
解决方案建议:日志提示可以通过增加workspace size来解决这个问题,即通过IBuilderConfig::setMemoryPoolLimit()
来增大TensorRT引擎构建时使用的显存池大小。
Try increasing the workspace size with IBuilderConfig:: setMemoryPoolLimit().
为了修正这个错误,请在构建TensorRT引擎时调整workspace大小以适应模型的需求。在您的Python脚本中,找到创建TensorRT IBuilderConfig
对象的部分,并设置合适的内存限制。例如:
# 假设builder是已创建的nvinfer1.IBuilder对象
config = builder.create_builder_config()
config.set_flag(nvinfer1.BuilderFlag.GPU_FALLBACK)
config.max_workspace_size = some_large_enough_value_in_bytes # 设置足够大的workspace大小
# 然后用配置来构建引擎
engine = builder.build_engine(network, config)
# 检查引擎是否成功构建
assert engine is not None, f"Failed to build engine for rank {cur_rank}"
请确保您为workspace size设置了一个大于GPTAttention所需空间的值,并且不超过实际GPU显存总量。如果GPU显存不足以容纳模型,则可能需要考虑使用较小批次大小、减少模型规模或在具有更大显存的GPU上运行。