如何解冻用户的内存限制?
How to unfreeze a user's memory limit?
这两天遇到一个奇怪的问题
STAR
from https://github.com/alexdobin/STAR 是一个用于构建后缀数组索引的程序。我已经使用这个程序很多年了。它工作正常,直到最近。
这几天,当我运行STAR
的时候,总会被杀。
root@localhost:STAR --runMode genomeGenerate --runThreadN 10 --limitGenomeGenerateRAM 31800833920 --genomeDir star_GRCh38 --genomeFastaFiles GRCh38.fa --sjdbGTFfile GRCh38.gtf --sjdbOverhang 100
.
.
.
Killed
root@localhost:STAR --runMode genomeGenerate --runThreadN 10 --genomeDir star_GRCh38 --genomeFastaFiles GRCh38.fa --sjdbGTFfile GRCh38.gtf --sjdbOverhang 100
Jun 03 10:15:08 ..... started STAR run
Jun 03 10:15:08 ... starting to generate Genome files
Jun 03 10:17:24 ... starting to sort Suffix Array. This may take a long time...
Jun 03 10:17:51 ... sorting Suffix Array chunks and saving them to disk...
Killed
一个月前,具有相同输入和相同参数的相同命令 运行s OK。它确实需要一些内存,但不会很多。
我试过这个程序最近发布的3个版本,都失败了。所以我不认为这是 STAR
程序的问题,而是我的服务器配置的问题。
我也尝试过 运行 这个程序作为 root
和普通用户,每个人都不走运。
我怀疑我的服务器内存使用有限制。
但不知内存是怎么限制的?我想知道是否有人可以给我一些提示。
谢谢!
童
以下是我的调试过程和系统信息。
命令 dmesg -T| grep -E -i -B5 'killed process'
显示它是 Out of memory
问题。
但是在STAR
程序被杀死之前,top
只显示5%
内存的命令被这个程序占用了。
[一 6 1 23:43:00 2020] [40479] 1002 40479 101523 18680 112 487 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] [40480] 1002 40480 101526 18681 112 486 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] [40481] 1002 40481 101529 18682 112 485 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] [40482] 1002 40482 101531 18673 111 493 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] Out of memory: Kill process 33822 (STAR) score 36 or sacrifice child
[一 6 1 23:43:00 2020] Killed process 33822 (STAR) total-vm:23885188kB, anon-rss:10895128kB, file-rss:4kB, shmem-rss:0kB
[三 6 3 10:02:13 2020] [12296] 1002 12296 101652 18681 113 486 0 /anaconda2/bin/
[三 6 3 10:02:13 2020] [12330] 1002 12330 101679 18855 112 486 0 /anaconda2/bin/
[三 6 3 10:02:13 2020] [12335] 1002 12335 101688 18682 112 486 0 /anaconda2/bin/
[三 6 3 10:02:13 2020] [12365] 1349 12365 30067 1262 11 0 0 bash
[三 6 3 10:02:13 2020] Out of memory: Kill process 7713 (STAR) score 40 or sacrifice child
[三 6 3 10:02:13 2020] Killed process 7713 (STAR) total-vm:19751792kB, anon-rss:12392428kB, file-rss:0kB, shmem-rss:0kB
--
[三 6月 3 10:42:17 2020] [ 4697] 1002 4697 101526 18681 112 486 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] [ 4698] 1002 4698 101529 18682 112 485 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] [ 4699] 1002 4699 101532 18680 112 487 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] [ 4701] 1002 4701 101534 18673 110 493 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] Out of memory: Kill process 21097 (STAR) score 38 or sacrifice child
[三 6月 3 10:42:17 2020] Killed process 21097 (STAR) total-vm:19769500kB, anon-rss:11622928kB, file-rss:884kB, shmem-rss:0kB
命令free -hl
显示我有足够的内存。
total used free shared buff/cache available
Mem: 251G 10G 11G 227G 229G 12G
Low: 251G 240G 11G
High: 0B 0B 0B
Swap: 29G 29G 0B
同样如 ulimit -a
所示,未设置虚拟内存限制。
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 1030545
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1030545
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
这里是我的Centos和Kernel的版本(hostnamectl
输出):
hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-server
Chassis: server
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.26.2.el7.x86_64
Architecture: x86-64
此处显示cat /etc/security/limits.conf
的内容:
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
* soft nofile 65536
* hard nofile 65536
#@intern hard as 162400000
#@intern hard nproc 150
# End of file
按照建议,我更新了 df -h
:
的输出
Filesystem All Used Available (Used)% Mount
devtmpfs 126G 0 126G 0% /dev
tmpfs 126G 1.3M 126G 1% /dev/shm
tmpfs 126G 4.0G 122G 4% /run
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/mapper/cl-root 528G 271G 257G 52% /
/dev/sda1 492M 246M 246M 51% /boot
tmpfs 26G 0 26G 0% /run/user/0
tmpfs 26G 0 26G 0% /run/user/1002
tmpfs 26G 0 26G 0% /run/user/1349
tmpfs 26G 0 26G 0% /run/user/1855
ls -a /dev/shm/
. ..
grep Shmem /proc/meminfo
Shmem: 238640272 kB
几个 tmpfs
消耗 126G
内存。我正在用谷歌搜索这个,但仍然不确定应该做什么?
那是共享内存的问题,因为程序异常终止。
ipcrm
用于清除所有共享内存,然后STAR running
即可。
$ ipcrm
.....
$ free -h
total used free shared buff/cache available
Mem: 251G 11G 226G 3.9G 14G 235G
Swap: 29G 382M 29G
看起来问题出在共享内存上:共享对象占用了 227G 内存。
共享内存文件是持久的。查看 /dev/shm
和任何其他 tmpfs
挂载,看看是否有可以删除的大文件以释放更多物理内存(RAM+swap)。
$ ls -l /dev/shm
...
$ df -h | grep '^Filesystem\|^tmpfs'
...
When I run a program called STAR, it will always be killed.
它可能有一些memory leak。即使是旧程序也可能有残留的错误,它们可能会出现在一些非常特殊的情况下。
检查strace(1) or ltrace(1) and pmap(1). Learn also to query /proc/
, see proc(5), top(1), htop(1). See LinuxAteMyRam and read about memory over-commitment and virtual address space and perhaps a textbook on operating systems。
如果您有权访问 STAR
的源代码,请考虑使用所有警告和调试信息重新编译它(使用 GCC, you would pass -Wall -Wextra -g
to gcc
or g++
) then use valgrind and/or some address sanitizer。如果您没有合法访问源代码的权限STAR
,联系向您提供它的实体(个人或组织)。
您可能对此感兴趣 draft report and by the Clang static analyzer or Frama-C (or coding your own GCC plugin)。
So I do not think it is the question of STAR program but my server configuration.
我建议使用 valgrind
或 gdb
并检查您的 /proc/
以验证该乐观假设。
这两天遇到一个奇怪的问题
STAR
from https://github.com/alexdobin/STAR 是一个用于构建后缀数组索引的程序。我已经使用这个程序很多年了。它工作正常,直到最近。
这几天,当我运行STAR
的时候,总会被杀。
root@localhost:STAR --runMode genomeGenerate --runThreadN 10 --limitGenomeGenerateRAM 31800833920 --genomeDir star_GRCh38 --genomeFastaFiles GRCh38.fa --sjdbGTFfile GRCh38.gtf --sjdbOverhang 100
.
.
.
Killed
root@localhost:STAR --runMode genomeGenerate --runThreadN 10 --genomeDir star_GRCh38 --genomeFastaFiles GRCh38.fa --sjdbGTFfile GRCh38.gtf --sjdbOverhang 100
Jun 03 10:15:08 ..... started STAR run
Jun 03 10:15:08 ... starting to generate Genome files
Jun 03 10:17:24 ... starting to sort Suffix Array. This may take a long time...
Jun 03 10:17:51 ... sorting Suffix Array chunks and saving them to disk...
Killed
一个月前,具有相同输入和相同参数的相同命令 运行s OK。它确实需要一些内存,但不会很多。
我试过这个程序最近发布的3个版本,都失败了。所以我不认为这是 STAR
程序的问题,而是我的服务器配置的问题。
我也尝试过 运行 这个程序作为 root
和普通用户,每个人都不走运。
我怀疑我的服务器内存使用有限制。
但不知内存是怎么限制的?我想知道是否有人可以给我一些提示。
谢谢!
童
以下是我的调试过程和系统信息。
命令 dmesg -T| grep -E -i -B5 'killed process'
显示它是 Out of memory
问题。
但是在STAR
程序被杀死之前,top
只显示5%
内存的命令被这个程序占用了。
[一 6 1 23:43:00 2020] [40479] 1002 40479 101523 18680 112 487 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] [40480] 1002 40480 101526 18681 112 486 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] [40481] 1002 40481 101529 18682 112 485 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] [40482] 1002 40482 101531 18673 111 493 0 /anaconda2/bin/
[一 6 1 23:43:00 2020] Out of memory: Kill process 33822 (STAR) score 36 or sacrifice child
[一 6 1 23:43:00 2020] Killed process 33822 (STAR) total-vm:23885188kB, anon-rss:10895128kB, file-rss:4kB, shmem-rss:0kB
[三 6 3 10:02:13 2020] [12296] 1002 12296 101652 18681 113 486 0 /anaconda2/bin/
[三 6 3 10:02:13 2020] [12330] 1002 12330 101679 18855 112 486 0 /anaconda2/bin/
[三 6 3 10:02:13 2020] [12335] 1002 12335 101688 18682 112 486 0 /anaconda2/bin/
[三 6 3 10:02:13 2020] [12365] 1349 12365 30067 1262 11 0 0 bash
[三 6 3 10:02:13 2020] Out of memory: Kill process 7713 (STAR) score 40 or sacrifice child
[三 6 3 10:02:13 2020] Killed process 7713 (STAR) total-vm:19751792kB, anon-rss:12392428kB, file-rss:0kB, shmem-rss:0kB
--
[三 6月 3 10:42:17 2020] [ 4697] 1002 4697 101526 18681 112 486 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] [ 4698] 1002 4698 101529 18682 112 485 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] [ 4699] 1002 4699 101532 18680 112 487 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] [ 4701] 1002 4701 101534 18673 110 493 0 /anaconda2/bin/
[三 6月 3 10:42:17 2020] Out of memory: Kill process 21097 (STAR) score 38 or sacrifice child
[三 6月 3 10:42:17 2020] Killed process 21097 (STAR) total-vm:19769500kB, anon-rss:11622928kB, file-rss:884kB, shmem-rss:0kB
命令free -hl
显示我有足够的内存。
total used free shared buff/cache available
Mem: 251G 10G 11G 227G 229G 12G
Low: 251G 240G 11G
High: 0B 0B 0B
Swap: 29G 29G 0B
同样如 ulimit -a
所示,未设置虚拟内存限制。
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 1030545
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1030545
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
这里是我的Centos和Kernel的版本(hostnamectl
输出):
hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-server
Chassis: server
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.26.2.el7.x86_64
Architecture: x86-64
此处显示cat /etc/security/limits.conf
的内容:
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
* soft nofile 65536
* hard nofile 65536
#@intern hard as 162400000
#@intern hard nproc 150
# End of file
按照建议,我更新了 df -h
:
Filesystem All Used Available (Used)% Mount
devtmpfs 126G 0 126G 0% /dev
tmpfs 126G 1.3M 126G 1% /dev/shm
tmpfs 126G 4.0G 122G 4% /run
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/mapper/cl-root 528G 271G 257G 52% /
/dev/sda1 492M 246M 246M 51% /boot
tmpfs 26G 0 26G 0% /run/user/0
tmpfs 26G 0 26G 0% /run/user/1002
tmpfs 26G 0 26G 0% /run/user/1349
tmpfs 26G 0 26G 0% /run/user/1855
ls -a /dev/shm/
. ..
grep Shmem /proc/meminfo
Shmem: 238640272 kB
几个 tmpfs
消耗 126G
内存。我正在用谷歌搜索这个,但仍然不确定应该做什么?
那是共享内存的问题,因为程序异常终止。
ipcrm
用于清除所有共享内存,然后STAR running
即可。
$ ipcrm
.....
$ free -h
total used free shared buff/cache available
Mem: 251G 11G 226G 3.9G 14G 235G
Swap: 29G 382M 29G
看起来问题出在共享内存上:共享对象占用了 227G 内存。
共享内存文件是持久的。查看 /dev/shm
和任何其他 tmpfs
挂载,看看是否有可以删除的大文件以释放更多物理内存(RAM+swap)。
$ ls -l /dev/shm
...
$ df -h | grep '^Filesystem\|^tmpfs'
...
When I run a program called STAR, it will always be killed.
它可能有一些memory leak。即使是旧程序也可能有残留的错误,它们可能会出现在一些非常特殊的情况下。
检查strace(1) or ltrace(1) and pmap(1). Learn also to query /proc/
, see proc(5), top(1), htop(1). See LinuxAteMyRam and read about memory over-commitment and virtual address space and perhaps a textbook on operating systems。
如果您有权访问 STAR
的源代码,请考虑使用所有警告和调试信息重新编译它(使用 GCC, you would pass -Wall -Wextra -g
to gcc
or g++
) then use valgrind and/or some address sanitizer。如果您没有合法访问源代码的权限STAR
,联系向您提供它的实体(个人或组织)。
您可能对此感兴趣 draft report and by the Clang static analyzer or Frama-C (or coding your own GCC plugin)。
So I do not think it is the question of STAR program but my server configuration.
我建议使用 valgrind
或 gdb
并检查您的 /proc/
以验证该乐观假设。