[GH-ISSUE #890] [Bug] 0ut of memory: Killed process 2583(python) #643

Open
opened 2026-10-29 14:42:19 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @qufujun on GitHub (Mar 14, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/890

检查清单

  • 1. 我已经搜索过相关问题,但未能获得预期的帮助
  • 2. 该问题在最新版本中尚未修复
  • 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性
  • 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭
  • 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭

问题描述

加载DeepSeek-R1-Q4_K_M量化文件gguf的时候报错,之前512G内存的时候,加载到blk23的时候就内存溢出,后来增加到1T内存的时候,加载到blk42的时候还是报内存溢出,错误描述:
0ut of memory: Killed process 2583(python)
tal-ym:1481207384kB,anon-rss:1044530552kB,file-rss:2335124kB, shmem-rss:46
72kB,UID:0 pgtables:2593200kB oom score adj:0

oom reaper: reaped process 2583(python),now
anon-rss:0kB,file-rss:64784kB.
shmem-rss:4672kB

复现步骤

git clone https://github.com/kvcache-ai/ktransformers.git
cd ktransformers
git submodule init
git submodule update
export USE_NUMA=1
make dev_install # or sh ./install.sh
python ./ktransformers/local_chat.py --model_path /root/DeepSeek-R1/ --gguf_path /root/DeepSeek-R1/DeepSeek-R1-Q4_K_M/ --cpu_infer 65 --max_new_tokens 1000

环境信息

环境是:
OS:Ubuntu 22.04 LTS

CPU:INTEL(R) XEON(R) GOLD 6530 * 2

MEMORY:1TB DDR5 4800MHz

GPU:GTX 3090 24G

nvcc:
Cuda compilation tools, release 12.6, V12.6.85
Build cuda_12.6.r12.6/compiler.35059454_0

VIDIA-SMI 570.124.06 Driver Version: 570.124.06 CUDA Version: 12.8

Name: ktransformers
Version: 0.2.3.post1+cu126torch26fancy

Originally created by @qufujun on GitHub (Mar 14, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/890 ### 检查清单 - [x] 1. 我已经搜索过相关问题,但未能获得预期的帮助 - [x] 2. 该问题在最新版本中尚未修复 - [x] 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性 - [x] 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭 - [x] 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭 ### 问题描述 加载DeepSeek-R1-Q4_K_M量化文件gguf的时候报错,之前512G内存的时候,加载到blk23的时候就内存溢出,后来增加到1T内存的时候,加载到blk42的时候还是报内存溢出,错误描述: 0ut of memory: Killed process 2583(python) tal-ym:1481207384kB,anon-rss:1044530552kB,file-rss:2335124kB, shmem-rss:46 72kB,UID:0 pgtables:2593200kB oom score adj:0 oom reaper: reaped process 2583(python),now anon-rss:0kB,file-rss:64784kB. shmem-rss:4672kB ### 复现步骤 git clone https://github.com/kvcache-ai/ktransformers.git cd ktransformers git submodule init git submodule update export USE_NUMA=1 make dev_install # or sh ./install.sh python ./ktransformers/local_chat.py --model_path /root/DeepSeek-R1/ --gguf_path /root/DeepSeek-R1/DeepSeek-R1-Q4_K_M/ --cpu_infer 65 --max_new_tokens 1000 ### 环境信息 环境是: OS:Ubuntu 22.04 LTS CPU:INTEL(R) XEON(R) GOLD 6530 * 2 MEMORY:1TB DDR5 4800MHz GPU:GTX 3090 24G nvcc: Cuda compilation tools, release 12.6, V12.6.85 Build cuda_12.6.r12.6/compiler.35059454_0 VIDIA-SMI 570.124.06 Driver Version: 570.124.06 CUDA Version: 12.8 Name: ktransformers Version: 0.2.3.post1+cu126torch26fancy
Author
Owner

@Atream commented on GitHub (Mar 15, 2025):

After enabling USE_NUMA, double the memory space is required. Through actual testing, it has been confirmed that a system with 1TB of memory can run normally. Additionally, mmap will occupy a portion of the memory. It is recommended to check the system settings related to mmap. Future versions will further optimize memory usage, and systems with multiple NUMA nodes will no longer require larger memory.
开启USE_NUMA后需要两倍的内存空间,经实际测试,1T内存是可以正常运行的,同时还会有mmap占据部分内存,建议检查系统有关mmap的设置。后续版本会进一步优化内存占用,多numa不再需要更大的内存。

<!-- gh-comment-id:2726443724 --> @Atream commented on GitHub (Mar 15, 2025): After enabling USE_NUMA, double the memory space is required. Through actual testing, it has been confirmed that a system with 1TB of memory can run normally. Additionally, mmap will occupy a portion of the memory. It is recommended to check the system settings related to mmap. Future versions will further optimize memory usage, and systems with multiple NUMA nodes will no longer require larger memory. 开启USE_NUMA后需要两倍的内存空间,经实际测试,1T内存是可以正常运行的,同时还会有mmap占据部分内存,建议检查系统有关mmap的设置。后续版本会进一步优化内存占用,多numa不再需要更大的内存。
Author
Owner

@merries711 commented on GitHub (Mar 15, 2025):

如何检查mmap设置,网上的资料基本都是提及mmap()函数和原理。

重启系统后,内存使用1.8GB左右,空闲1020GB左右,
运行双插槽install.sh后的ktransformers(0.2.3.post1+cu126torch26fancy)
加载gguf的时候,感觉很异常,速度很慢。

在同样的硬件软件环境下,使用单插槽的方式进行install.sh后,加载guff就正常,模型可以正常运行。

双插槽安装之前,USR_NUMA变量已经正确设置,libnuma-dev也提前安装好了。

$ apt list --installed | grep libnuma

libnuma-dev/jammy,now 2.0.14-3ubuntu2 amd64 [installed]
libnuma1/jammy,now 2.0.14-3ubuntu2 amd64 [installed,automatic]


numactl -Hardware 显示系统有4个 NUMA node(s) ,每个node 大概分配了252GB内存,
不知道是不是这个原因导致的,kt为每个NUMA node加载全部的模型文件?

<!-- gh-comment-id:2726779853 --> @merries711 commented on GitHub (Mar 15, 2025): 如何检查mmap设置,网上的资料基本都是提及mmap()函数和原理。 重启系统后,内存使用1.8GB左右,空闲1020GB左右, 运行双插槽install.sh后的ktransformers(0.2.3.post1+cu126torch26fancy) 加载gguf的时候,感觉很异常,速度很慢。 在同样的硬件软件环境下,使用单插槽的方式进行install.sh后,加载guff就正常,模型可以正常运行。 双插槽安装之前,USR_NUMA变量已经正确设置,libnuma-dev也提前安装好了。 $ apt list --installed | grep libnuma libnuma-dev/jammy,now 2.0.14-3ubuntu2 amd64 [installed] libnuma1/jammy,now 2.0.14-3ubuntu2 amd64 [installed,automatic] ----------------------------------------------------------------------------- numactl -Hardware 显示系统有4个 NUMA node(s) ,每个node 大概分配了252GB内存, 不知道是不是这个原因导致的,kt为每个NUMA node加载全部的模型文件?
Author
Owner

@FrySong commented on GitHub (Mar 21, 2025):

如何检查mmap设置,网上的资料基本都是提及mmap()函数和原理。

重启系统后,内存使用1.8GB左右,空闲1020GB左右, 运行双插槽install.sh后的ktransformers(0.2.3.post1+cu126torch26fancy) 加载gguf的时候,感觉很异常,速度很慢。

在同样的硬件软件环境下,使用单插槽的方式进行install.sh后,加载guff就正常,模型可以正常运行。

双插槽安装之前,USR_NUMA变量已经正确设置,libnuma-dev也提前安装好了。

$ apt list --installed | grep libnuma

libnuma-dev/jammy,now 2.0.14-3ubuntu2 amd64 [installed] libnuma1/jammy,now 2.0.14-3ubuntu2 amd64 [installed,automatic]

numactl -Hardware 显示系统有4个 NUMA node(s) ,每个node 大概分配了252GB内存, 不知道是不是这个原因导致的,kt为每个NUMA node加载全部的模型文件?

应该是的, 我是INTEL(R) XEON(R) PLATINUM 8581C, 有4个节点, 配了1T的5600 DRAM, 也是疯狂被爆内存.

<!-- gh-comment-id:2743301770 --> @FrySong commented on GitHub (Mar 21, 2025): > 如何检查mmap设置,网上的资料基本都是提及mmap()函数和原理。 > > 重启系统后,内存使用1.8GB左右,空闲1020GB左右, 运行双插槽install.sh后的ktransformers(0.2.3.post1+cu126torch26fancy) 加载gguf的时候,感觉很异常,速度很慢。 > > 在同样的硬件软件环境下,使用单插槽的方式进行install.sh后,加载guff就正常,模型可以正常运行。 > > 双插槽安装之前,USR_NUMA变量已经正确设置,libnuma-dev也提前安装好了。 > > $ apt list --installed | grep libnuma > > libnuma-dev/jammy,now 2.0.14-3ubuntu2 amd64 [installed] libnuma1/jammy,now 2.0.14-3ubuntu2 amd64 [installed,automatic] > > numactl -Hardware 显示系统有4个 NUMA node(s) ,每个node 大概分配了252GB内存, 不知道是不是这个原因导致的,kt为每个NUMA node加载全部的模型文件? 应该是的, 我是INTEL(R) XEON(R) PLATINUM 8581C, 有4个节点, 配了1T的5600 DRAM, 也是疯狂被爆内存.
Author
Owner

@SugarmanZhu commented on GitHub (Apr 8, 2025):

把NUMA Node减少到两个就可以了
Intel CPU可以在BIOS里关掉NUMA Sub Cluster

<!-- gh-comment-id:2787016763 --> @SugarmanZhu commented on GitHub (Apr 8, 2025): 把NUMA Node减少到两个就可以了 Intel CPU可以在BIOS里关掉NUMA Sub Cluster
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/ktransformers#643
No description provided.