Ollama(公式サイト https://ollama.com/)は PC で手軽にローカルの大規模言語モデル (LLM) を利用するためのフレームワークです.Chat-GPT などの生成AIと似た仕組みを自身の環境で構築して利用することができます.
ここでは Windows の PowerShell を用いてインストールする方法を示します.MacOS へのインストールや詳細情報は Ollama ダウンロードページを参照してください.
インストールするには PowerShell を管理者モードで起動し,次のコマンドを実行するだけです.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> irm https://ollama.com/install.ps1 | iex ⏎
>>> Downloading Ollama for Windows...
######################################## 100.0%
>>> Installing Ollama...
>>> Install complete. Run 'ollama' from the command line.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog>
なお,irm と iex コマンドレットはそれぞれ Invoke-RestMethod と Invoke-Expression のエイリアス(別名)です.Invoke-Expression (iex) はローカルコンピューターでコマンドまたは式を実行します.上のコマンドは install.ps1 をダウンロードして,即実行しているだけです.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> get-alias irm ⏎ CommandType Name Version Source ----------- ---- ------- ------ Alias irm -> Invoke-RestMethod (py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> get-alias iex ⏎ CommandType Name Version Source ----------- ---- ------- ------ Alias iex -> Invoke-Expression (py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog>
インストールができたので,そのバージョンを確認します.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> ollama --version ⏎
ollama version is 0.40.5
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog>
実行コマンドは ollama run モデル名 です.モデル名には様々な学習済みモデルを指定することができますが,PCのスペック(特にGPUのメモリサイズ)に応じたモデルを指定することが重要です.例えば,qwen3:8b というモデルを指定して実行してみます.最初の実行時にはモデルのダウンロードが行われるため,プロンプト (>>>) が表示されるまで時間を要します.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> ollama run qwen3:8b ⏎
pulling manifest
pulling a3de86cd1c13: 100% ▕█████████████████████████████████████▏ 5.2 GB
pulling 05a61d37b084: 100% ▕█████████████████████████████████████▏ 487 B
verifying sha256 digest
writing manifest
success
>>> Send a message (/? for help)
別のターミナルを起動して GPU の状況を確認します.llama-server.exe が起動し,学習済みモデルが GPU のメモリに載っていることが分かります.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> nvidia-smi -l 3 ⏎ Sat Oct 17 11:34:01 2026 +-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 610.91 KMD Version: 610.91 CUDA UMD Version: 13.3 | +-----------------------------------------+------------------------+----------------------+ | GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+========================+======================| | 0 NVIDIA GeForce RTX 4060 ... WDDM | 00000000:01:00.0 Off | N/A | | N/A 41C P8 1W / 135W | 5425MiB / 8188MiB | 0% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+ +-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | 0 N/A N/A 12152 C ...a\lib\ollama\llama-server.exe N/A | +-----------------------------------------------------------------------------------------+
「こんにちは」や「はじめまして」という簡単なプロンプトを入力してみます.実行時に nvidia-smi -l 3 の画面を確認し,GPUの利用率 (GPU-Util) が上昇していることも確認すると良いでしょう.
>>> こんにちは ⏎ Thinking... Alright, the user greeted me with "こんにちは" which means "Hello" in Japanese. I should respond in Japanese to keep the conversation flowing naturally. I need to make sure my response is friendly and open-ended to encourage further interaction. Maybe start with a simple greeting and ask how I can assist them today. I should also check if there's any specific context or previous conversation that might influence the response, but since this is the first message, it's just a general greeting. Using a polite and welcoming tone is important here. Something like "こんにちは!今日もよろしくお願いします。何かお手伝いできることがありますか?" which translates to "Hello! Please take care today. Is there anything I can help you with?" That should cover it. Let me make sure there are no grammar mistakes and that the response sounds natural in Japanese. ...done thinking. こんにちは!今日もよろしくお願いします。何かお手伝いできることがありますか? >>> はじめまして ⏎ Thinking... Okay, the user said "はじめまして" which means "Nice to meet you" in Japanese. I should respond politely. Let me check the previous conversation. The user greeted me with "こんにちは" and I replied with a greeting and offered help. Now they're introducing themselves. I need to acknowledge their introduction and keep the tone friendly. Maybe add an emoji to keep it warm. Also, make sure to use proper Japanese and keep the response concise. Let memake sure there's no error in the response. ...done thinking. はじめまして!私たちはこれからお話しできるのをとても楽しみにしています。何かご希望があれば、いつでもお気軽にお知らせくださいね!✨ >>> /bye ⏎ (py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog>
インストール済みのモデルを一覧で表示するには次のコマンドを実行します.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> ollama list ⏎
NAME ID SIZE MODIFIED
deepseek-r1:8b 6995872bfe4c 5.2 GB 2 weeks ago
qwen3:14b bdbd181c33f2 9.3 GB 2 weeks ago
llama3.1:8b 46e0c10c039e 4.9 GB 2 weeks ago
gemma3:4b 68ceab7e468a 3.4 GB 2 weeks ago
qwen3:8b 500a1f067a9f 5.2 GB 2 weeks ago
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog>
ダウンロード済みのモデルを再び指定して実行した場合はダウンロードが必要ないため,初回よりもより速くプロンプトが表示されます.
(py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog> ollama run qwen3:8b ⏎ >>> こんにちは ⏎ Thinking... Okay, the user said "こんにちは" which means "Hello" in Japanese. I should respond in Japanese to keep the conversation friendly. Let me make sure I use the proper greeting. Maybe start with "こんにちは!" and then ask how I can assist them. Keep it simple and welcoming. Let me check for any grammar mistakes. Looks good. Ready to respond. ...done thinking. こんにちは!お手伝いできることありますか?😊 >>> /bye ⏎ (py313watchdog) PS C:\Users\rinsaka\Documents\python\watchdog>
LLM の動作を確認できたので,次のページではワーカープログラムからプロンプトを送信します.