0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LLM推論マシンの環境構築メモ(ollama open-webui ubuntu2204)

Posted at

ChatGPTのようなユーザーインターフェースでLLMを使う。

テスト環境(ubuntu2204 RTX3060 12G)

docker-compose.yamlの下に、二つのdockerfile(ollama,open-webui)を配置して二つのコンテナが起動するタイプ。
稼働時は、docker-composeをupして、外部のブラウザからアクセスする。

フォルダ構造

project/
├── docker-compose.yaml
├── ollama/
│   └── Dockerfile
└── open-webui/
    └── Dockerfile

1. 各サービス用の Dockerfile

【ollama/Dockerfile】


# ollama/Dockerfile
FROM ollama/ollama
# コンテナ起動時のデータ永続化用ボリューム
VOLUME /root/.ollama
# ポート11434を公開
EXPOSE 11434

# ※ GPUを使用する場合、docker-compose側で runtime や device_requests の設定を追加してください。

【open-webui/Dockerfile】


# open-webui/Dockerfile
FROM ghcr.io/open-webui/open-webui:main
# データ永続化用ボリュームの指定
VOLUME /app/backend/data
# コンテナ内でバックエンドがリッスンするポートを公開
EXPOSE 8080

2. docker-compose.yaml

以下の docker-compose.yaml では、各サービスを起動する設定と、ボリューム、ポート、環境変数などを指定しています。

version: "3.8"

services:
  ollama:
    # 既存イメージを利用する場合は image を使用できます。
    # カスタムビルドする場合は、以下の build オプションのコメントを解除してください。
    # build: ./ollama
    image: ollama/ollama
    container_name: ollama
    volumes:
      - ollama_data:/root/.ollama
    ports:
      - "11434:11434"
    # NVIDIA GPUを利用する場合は、以下のオプションを有効にしてください(Docker環境に依存します)。
    # runtime: nvidia
    # または device_requests を利用する場合(Docker Compose v2.4以降)
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: all
    #           capabilities: [gpu]

  open-webui:
    # カスタムビルドする場合は、以下の build オプションのコメントを解除してください。
    # build: ./open-webui
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: always
    environment:
      - WEBUI_AUTH=False  # 新規ユーザー登録画面をスキップ
    volumes:
      - open_webui_data:/app/backend/data
    ports:
      - "3000:8080"
    extra_hosts:
      - "host.docker.internal:host-gateway"

volumes:
  ollama_data:
  open_webui_data:

コンテナの構築

vs-codeでプロジェクトフォルダを開く。docker関係の拡張をインストール。
docker-compose.yamlを右クリックして、upを選択。

image.png

コンテナが起動したら、http://localhost:3000/にアクセスするととりあえず、チャットできる画面になる。

モデルのダウンロード

この段階では、使えるLLMがダウンロードされていないので、ollamaコンテナの中でダウンロードを実施する。
vs-codeなら以下の図のように、コンテナ内のターミナルを起動する。
image.png

ollama pullコマンドを使って、例えば以下のようにモデルをダウンロードする。GPUメモリ12Gでも以下のものは動きました。

ollama pull deepseek-r1
#サイズ指定ないものは7b
ollama pull deepseek-r1:32b
ollama pull hf.co/mmnga/cyberagent-DeepSeek-R1-Distill-Qwen-32B-Japanese-gguf

ダウンロードされる様子。
image.png

ブラウザでアクセスしてチャットする

再度、http://localhost:3000/にアクセス 以下のような画面で操作できる。
image.png

利用可能モデル

ollama公式一覧
https://github.com/ollama/ollama?tab=readme-ov-file#model-library
https://ollama.com/library?sort=popular

huggingface gguf形式とjapanでフィルターするなど。gguf形式だと変換せずに利用可能。
https://huggingface.co/mmnga/cyberagent-DeepSeek-R1-Distill-Qwen-32B-Japanese-gguf
https://huggingface.co/models?library=gguf&sort=trending&search=japan

参考ページ

https://zenn.dev/karaage0703/articles/c271ca65b91bdb
https://zenn.dev/laniakea/articles/63531b0f8d4d32
https://github.com/ollama/ollama
https://github.com/open-webui/open-webui

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?