我有一个 C++ 应用程序,它加载 Kaldi ASR 模型。如果模型很小,则该应用程序能够加载模型并在命令行以及 Debian 12 下的 systemd 服务中运行。
但是,当我加载更大的 Kaldi ASR 模型时,服务无法加载,但它可以从命令行正常运行。我真的很困惑,作为服务运行时应用的限制是什么。服务文件中没有指定内存限制。
以下是服务文件:
[Unit]
Description=kaldiasr-english
Wants=network-online.target
After=syslog.target local-fs.target network.target network-online.target
[Service]
; service
Type=simple
PIDFile=/var/log/kaldiasr-english.pid
PermissionsStartOnly=true
; blank ExecStart= line flushes the list
Environment="LD_LIBRARY_PATH=/usr/local/lib"
ExecStart=kaldiasr 8010 60 English vosk-model-en-us-0.22
TimeoutSec=45s
Restart=on-failure
; exec
WorkingDirectory=/home/test
User=test
Group=test
LimitCORE=infinity
LimitNOFILE=100000
LimitNPROC=60000
;LimitSTACK=240
LimitRTPRIO=infinity
LimitRTTIME=7000000
IOSchedulingClass=realtime
IOSchedulingPriority=2
CPUSchedulingPolicy=rr
CPUSchedulingPriority=89
UMask=0007
[Install]
WantedBy=multi-user.target
Kaldi的日志如下:
Apr 27 22:03:00 staging-svr2 kaldiasr[1399961]: LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo vosk-model-en-us-0.22/graph/phones/word_boundary.int
Apr 27 22:03:00 staging-svr2 kaldiasr[1399961]: LOG (VoskAPI:ReadDataFiles():model.cc:315) Loading subtract G.fst model from vosk-model-en-us-0.22/rescore/G.fst
Apr 27 22:03:03 staging-svr2 kaldiasr[1399961]: LOG (VoskAPI:ReadDataFiles():model.cc:317) Loading CARPA model from vosk-model-en-us-0.22/rescore/G.carpa
Apr 27 22:03:03 staging-svr2 kaldiasr[1399961]: LOG (VoskAPI:ReadDataFiles():model.cc:323) Loading RNNLM model from vosk-model-en-us-0.22/rnnlm/final.raw
Apr 27 22:03:07 staging-svr2 systemd[1]: kaldiasr-english.service: Main process exited, code=killed, status=9/KILL
Apr 27 22:03:07 staging-svr2 systemd[1]: kaldiasr-english.service: Failed with result 'signal'.
Apr 27 22:03:07 staging-svr2 systemd[1]: kaldiasr-english.service: Consumed 8.088s CPU time.
Apr 27 22:03:07 staging-svr2 systemd[1]: kaldiasr-english.service: Scheduled restart job, restart counter is at 2.
Apr 27 22:03:07 staging-svr2 systemd[1]: Stopped kaldiasr-english.service - asr-english.
Apr 27 22:03:07 staging-svr2 systemd[1]: kaldiasr-english.service: Consumed 8.088s CPU time.
Apr 27 22:03:07 staging-svr2 systemd[1]: Started kaldiasr-english.service - asr-english.