Mac OSでOllama server (5)一周まわって公式版のollamaに挑戦
llama.cppでサーバーを構築していたが、一点、問題が発生した。サーバー実行中に動的にモデルを変更できないという問題だ。バッチ処理で複数モデルで変えたいのでこれは今回の用途には致命的。ということで一周まわってollamaに戻ってきた。今回は公式サイトでの配付版です。
取りあえず。MacOS版のインストールコマンドでインストール、適当なモデルをダウンロード
curl -fsSL https://ollama.com/install.sh | sh
ollama run gemma4:e4b
「システム設定」→「一般」→「ログイン項目。。。」で自動起動を停止。
~/Library/LaunchAgents/com.ollama.server.plist を作る。
中身は
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ollama.server</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Ollama.app/Contents/Resources/ollama</string>
<string>serve</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>OLLAMA_HOST</key>
<string>0.0.0.0:11434</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/ollama.stdout.log</string>
<key>StandardErrorPath</key>
<string>/tmp/ollama.stderr.log</string>
</dict>
</plist>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ollama.server</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Ollama.app/Contents/Resources/ollama</string>
<string>serve</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>OLLAMA_HOST</key>
<string>0.0.0.0:11434</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/ollama.stdout.log</string>
<key>StandardErrorPath</key>
<string>/tmp/ollama.stderr.log</string>
</dict>
</plist>
launchctl load ~/Library/LaunchAgents/com.ollama.server.plist
できどうして、終了させても、コンソールから終了させても再度起動してくる。
# サービスを停止・解除
launchctl unload ~/Library/LaunchAgents/com.ollama.server.plist
# 完全に自動起動を無効化する
launchctl unload -w ~/Library/LaunchAgents/com.ollama.server.plist
取りあえず、ユーザーがデスクトップにログインしている間はサービスとして動いている。
コメント
コメントを投稿