0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSL2でOllamaを動かした際のメモ

0
Posted at

下記の記事を参考
https://zenn.dev/toki_mwc/articles/d1ebbd634ff488

環境構築

DockerコンテナでOllamaを動かすこととした。
WSL2とDockerのインストールは割愛

マシンスペックは以下、

  • CPU: AMD Ryzen 9 9900X
  • Memory: 64GB
  • GPU: Geforce RTX 5700Ti

NVIDIA Container Toolkitのインストール

WSLからGPUを認識させるため、NVIDIA Container Toolkitをインストールする
下記の記事を参考
https://zenn.dev/holliy/articles/e1ac7f2f806c35

WSLからGPUを識別↓

$ nvidia-smi
Sat Aug 26 12:47:19 2025
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.247.01             Driver Version: 580.88       CUDA Version: 13.0     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | 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 5070 Ti     On  | 00000000:01:00.0  On |                  N/A |
|  0%   34C    P8              13W / 300W |    937MiB / 16303MiB |      1%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

途中、dockerがrootlessモードだったことを忘れていたため、dockerコンテナからGPUを認識しなかった。
docekrを権限付きで実行すれば問題ない。

OllamaのdockerイメージをPull

$ sudo docker pull ollama/ollama

Ollamaの実行

dockerコンテナを起動

$ sudo docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

モデルの実行

モデルにgpt-oss:20bを選択

$ sudo docker exec -it ollama ollama run gpt-oss:20b
pulling manifest
pulling b112e727c6f1: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏  13 GB
pulling fa6710a93d78: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏ 7.2 KB
pulling f60356777647: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏  11 KB
pulling d8ba2f9a17b3: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏   18 B
pulling 55c108d8e936: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏  489 B
verifying sha256 digest
writing manifest
success
>>> konichiha
Thinking...
User writes "konichiha". Likely greeting in Japanese? Should respond in Japanese: "こんにちは!". Maybe ask what they want. Probably respond politely.
...done thinking.

こんにちは!何かお手伝いできることがあれば教えてくださいね。

こんな簡単なのかと少し感動した。

gpt-oss:120bも試してみた

結論:gpt-oss:120bはメモリが不足しているため、実行できなかった。

$ sudo docker exec -it ollama ollama run gpt-oss:120b
pulling manifest
pulling 90a618fe6ff2: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏  65 GB
pulling fa6710a93d78: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏ 7.2 KB
pulling f60356777647: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏  11 KB
pulling d8ba2f9a17b3: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏   18 B
pulling e7233df9dcc9: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████▏  490 B
verifying sha256 digest
writing manifest
success
Error: 500 Internal Server Error: model requires more system memory (48.6 GiB) than is available (37.1 GiB)

Hostマシンのメモリが64GBなので、デフォルトで30GB程度しか使えない。
WSLのメモリ使用上限を設定を変えるか、メモリを増設するか、、、

$ sudo docker stats --no-stream
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O         PIDS
ddfb79829a28   ollama    0.00%     199.4MiB / 30.15GiB   0.65%     80.5GB / 1.14GB   77.1GB / 79.1GB   31

Hostマシンのメモリを128GBに増設して動作することを確認。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?