在Ubuntu 22.04上,当某个请求导致ollama陷入无限循环时,可以通过以下方法来确认调试标志是否设置正确:
- 首先,确保在环境变量中设置了正确的值。在
~/.bashrc
文件中添加以下内容:
export OLLAMA_DEBUG=
export OLLAMA_DEBUG=1
set | grep OLLAMA
OLLAMA_DEBUG=1
然后运行source ~/.bashrc
使更改生效。
- 在
ollama.service
文件的[Service]
部分添加以下内容:
Environment="OLLAMA_DEBUG=
[Unit]
Description=Ollama Service
After=network-online.target
[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/home/……:/snap/bin OLLAMA_DEBUG=1"
[Install]
WantedBy=default.target
"
- 重新启动服务器:
sudo systemctl restart ollama.service
- 检查日志。在终端中运行以下命令:
journalctl -u ollama.service --since "$(date -d '1 hour ago' +'%Y-%m-%dT%H:%M:%S')" --until "$(date +'%Y-%m-%dT%H:%M:%S')" | grep -i debug
这将显示过去一小时内所有包含“debug”关键字的日志条目。如果调试标志设置正确,你应该能看到更多的日志输出。
5条答案
按热度按时间u5i3ibmn1#
循环是否尊重
systemd
的 RestartSec=3 设置?您可以通过更改
ollama.service
文件并将ExecStart=ollama serve
设置为运行 Package 脚本来诊断,例如保持进程运行或转储其环境变量。要查看正在运行的进程的环境并检查调试标志,只需从 procfs 读取:
编辑:而不是花时间在 systemd 的不便和开销上,您可以杀死服务并直接运行
sudo -u ollama /usr/local/bin/ollama serve
,然后在单独的终端窗口中运行模型时监控日志输出。g0czyy6m2#
啊,这太棒了,直接运行它。a) 正确设置环境变量;b) 现在我可以看到
level=DEBUG
在日志中。我想我还不清楚如何修改 ollama.service 以正确设置环境变量。f4t66c6m3#
这非常有趣,似乎
instructor
正在生成提示,甚至mistral:7b
也无法应对,但更有趣的是,以一种导致ollama呕吐的方式。我让ollama
在这里卡住,完全不返回。它一直这样做,直到我杀死它,阻塞线程和套接字。
iqjalb3h4#
你好,@boxabirds,你是否偶然使用了JSON模式?抱歉你遇到了这个问题。
zaqlnxep5#
Environment="PATH=/home/……:/snap/bin OLLAMA_DEBUG=1"
OLLAMA_DEBUG
needs to be on its ownEnvironment
line