「Mac/インストール/ollama」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→ollamaサーバ起動) |
(→localhostで公開する場合) |
||
| 行5: | 行5: | ||
ollama serve | ollama serve | ||
| − | === | + | ===localhost外で公開する場合=== |
export OLLAMA_HOST=0.0.0.0 | export OLLAMA_HOST=0.0.0.0 | ||
ollama serve | ollama serve | ||
2026年3月10日 (火) 07:41時点における最新版
目次
ollamaインストール
brew install ollama
ollamaサーバ起動
ollama serve
localhost外で公開する場合
export OLLAMA_HOST=0.0.0.0 ollama serve
ログイン時に起動
brew services start ollama
gpt-ossのモデルを動かす
$ ollama run gpt-oss:20b >>> こんにちは Thinking... The user says "こんにちは". That's Japanese greeting "Hello". Should respond politely, maybe in Japanese. Simple greeting. Probably respond with "こんにちは!今日はどうされましたか?" or something. The user might just say hello. So respond. ...done thinking. こんにちは!今日はどんなご用件でしょうか?何かお手伝いできることがあれば教えてくださいね。 >>> Send a message (/? for help)
mac-intelのメモリ32GB程度だと、レスポンスに1分以上かかる。
モデルリスト表示
% ollama list NAME ID SIZE MODIFIED gpt-oss:20b 17052f91a42e 13 GB 23 seconds ago gpt-oss:120b a951a23b46a1 65 GB 20 hours ago deepseek-coder:latest 3ddd2d3fc8d2 776 MB 24 hours ago deepseek-coder:6.7b ce298d984115 3.8 GB 24 hours ago gpt-oss:latest 17052f91a42e 13 GB 2 weeks ago
gpt-oss:latest は、サイズが13GBなので、20Bのgpt-ossが入ってることがわかる。120Bではない。120Bは、65GBある。
モデルのインストールパス
~/.ollama/models/manifests/registry.ollama.ai/library/<モデル名>/<バージョン>/
インストールに必要なメモリ
最低16GB程度は必要。
httpアクセス
デフォルトでは以下が起動してる
http://localhost:11434
Ollama is running
curlサンプル
リクエスト
% curl http://localhost:11434/api/generate -d '{
"model": "gpt-oss",
"prompt": "こんにちは!"
}'
レスポンス
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.6297Z","response":"","thinking":"User","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.642052Z","response":"","thinking":" says","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.653944Z","response":"","thinking":" \"","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.666045Z","response":"","thinking":"こんにちは","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.678172Z","response":"","thinking":"!","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.690023Z","response":"","thinking":"\"","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.701849Z","response":"","thinking":" (","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.713882Z","response":"","thinking":"Hello","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.725683Z","response":"","thinking":"!).","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.737732Z","response":"","thinking":" Need","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.749662Z","response":"","thinking":" to","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.762579Z","response":"","thinking":" respond","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.773642Z","response":"","thinking":" politely","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.785467Z","response":"","thinking":".","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.797319Z","response":"","thinking":" Provide","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.80919Z","response":"","thinking":" greeting","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.820969Z","response":"","thinking":".","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.832962Z","response":"","thinking":" Let's","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.844998Z","response":"","thinking":" ask","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.856901Z","response":"","thinking":" how","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.868945Z","response":"","thinking":" can","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.881168Z","response":"","thinking":" help","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.893326Z","response":"","thinking":".","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.977468Z","response":"こんにちは","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:22.990969Z","response":"!","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.014597Z","response":"🌸","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.026746Z","response":" \n","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.038947Z","response":"何","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.050976Z","response":"か","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.063168Z","response":"お","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.075635Z","response":"手","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.088004Z","response":"伝","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.100341Z","response":"い","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.112858Z","response":"でき","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.125925Z","response":"る","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.139937Z","response":"こと","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.153531Z","response":"があります","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.16605Z","response":"か","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.17869Z","response":"?","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.191311Z","response":"質問","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.203878Z","response":"や","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.216107Z","response":"相談","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.22991Z","response":"、","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.243029Z","response":"情報","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.255405Z","response":"の","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.268102Z","response":"検索","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.280793Z","response":"など","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.293252Z","response":"、","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.305921Z","response":"何","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.31814Z","response":"でも","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.330533Z","response":"どう","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.343084Z","response":"ぞ","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.355432Z","response":"!","done":false}
{"model":"gpt-oss","created_at":"2025-08-25T18:12:23.36765Z","response":"","done":true,"done_reason":"stop","context":[200006,17360,200008,3575,553,17554,162016,11,261,4410,6439,2359,22203,656,7788,17527,558,87447,100594,25,220,1323,19,12,3218,198,6576,3521,25,220,1323,20,12,3062,12,2109,279,30377,289,25,14093,279,2,13888,18403,25,8450,11,49159,11,1721,13,21030,2804,413,7360,395,1753,3176,13,200007,200006,1428,200008,95839,3393,200007,200006,173781,200005,35644,200008,1844,5003,392,95839,3393,1,350,13225,50148,19792,316,9570,167705,13,51441,64790,13,41021,3810,1495,665,1652,13,200007,200006,173781,200005,17196,200008,95839,3393,64364,116,4066,13811,7128,8930,6034,117934,3826,78673,6996,53217,164454,7128,4802,193023,19160,147983,1395,47357,3385,88225,73045,1395,13811,45996,85545,111317,3393],"total_duration":3907852375,"load_duration":2981784458,"prompt_eval_count":69,"prompt_eval_duration":150688458,"eval_count":64,"eval_duration":774894417}
- macM4の128GBだと1秒。
- macIntelの32BGだと90秒。
phpサンプル
<?php
$input = $argv[1] ?? "こんにちは";
$url = "http://localhost:11434/api/generate";
$data = [
"model" => "gpt-oss",
"prompt" => $input,
"stream" => false
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode($data),
]);
$response = curl_exec($ch);
echo print_r($response,1);
実行
php ollama.php こんにちは
レスポンス
こんにちは!🌸
gpt-oss-120bを動かす
ollama run gpt-oss:120b
