Mark Ku's Blog

背景說明

過去使用 Azure Open AI 來優化 SEO,但由於 Azure Open AI 每月僅有 $150 美金的額度,常在月底因 MSDN 額度不足而被停用。因此,我們開始尋找其他替代方案,最終選擇了 Facebook 開源的 Ollama。

安裝及設定

首先,建立 Docker Compose 檔案 (GPU 版本) - docker-compose.yml

2025/06/01 更新

version: '3.8'
services:
  ollama:
    image: ollama/ollama:latest
    ports:
      - 11434:11434
    volumes:
      - .:/code
      - ./ollama/ollama:/root/.ollama
    container_name: ollama
    pull_policy: always
    tty: true
    restart: always
    networks:
      - ollama-docker
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    depends_on:
      - ollama
    ports:
      - 8088:8080
    environment:
      - 'OLLAMA_API=http://ollama:11434/api'
    extra_hosts:
      - host.docker.internal:host-gateway
    restart: unless-stopped
    networks:
      - ollama-docker

networks:
  ollama-docker:
    external: false

建立啟動容器應用

docker compose up -d

訪問 loclahost:8080

image
image

設定>下載及安裝模型

image
image

安裝 Linux 子系統 (Windows PowerShell)

wsl --version
wsl --update
wsl --install
wsl --list
image
image

接著,開啟 Ubuntu

image
image

在 Ubuntu 中執行以下命令

在 Ubuntu 中,執行以下命令來配置 NVIDIA 容器工具包:

sudo apt-get update
sudo apt-get install -y nvidia-cuda-toolkit nvidia-container-toolkit

在 Docker 中設定支援 GPU

 * 確保 Docker「**啟用 WSL2 整合**」
 * 打開 Docker Desktop → Settings → Resources → WSL integration → 打開 Ubuntu
 * Docker 新版 Enable GPU support** (預設啟用) => 這就不用設定了
 * Docker enging 設定
image
image
"runtimes": {
    "nvidia": {
      "path": "nvidia-container-runtime",
      "runtimeArgs": []
    }
  }

測試 GPU 整合

確認 GPU 整合是否成功: image

docker run --gpus all nvidia/cuda:11.5.2-base-ubuntu20.04 nvidia-smi

如何確定 Ollama 使用GPU 做運算,回到宿主機執行以下指令

docker exec -it ollama /bin/bash
ollama ps
image
image

實測結果

硬體規格: CPU 13900K + Nvidia TUF RTX 3080 + 64 GB + WIN 11

將先前給 Azure Open AI 產生SEO 的 prompt,去餵給Ollama 。

You are an SEO expert. Based on the page description provided below, generate an SEO-optimized title, meta description, and keywords. Ensure that the title is engaging and concise, the meta description summarizes the product effectively while enticing users to learn more, and the keywords are relevant to the product's features and market segment. Additionally, translate all content into the language specified by the given language code.
Company:Your company Desc ...
Ecommerce Page Description: Case: NZXT H5 Flow Gaming Gehäuse - Schwarz Processor: AMD Ryzen 5 5600X Processor (6x 3.7GHz/32MB L3 Cache) Memory: 16GB DDR4/3200MHz Memory(G.Skill ,Corsair,Kingston) Storage: Video Card: NVIDIA GeForce RTX 3050 - 8GB GDDR6X (VR-Ready) Motherboard: ASRock B450 PRO 4 ATX USB 3.1, SATA3, 1x M.2
Translate Target Language Code: en
FormatInstructions: Only the title, description and keywords of the json structure are returned. example :{"title":"","description":"","keywords":""} Please delete any other unnecessary information. Such as python code, Python Flask API, etc. Give me json result. Do not send back any other information such as python code, Python Flask API, etc.

性能比較

  • CPU 版:1 分 10 秒 ~ 1 分 30 秒
  • NVIDIA RTX MSI 2060 OG GPU 版: 30 秒左右
  • NVIDIA RTX TUF 3080 GPU 版:不到 3 秒

參考資料

作者

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。閱讀更多

覺得這篇有幫助?

作者做的免費工具、每日 Podcast 與電子報,都在這裡。

Mark Ku · 本文採用 CC BY 4.0 授權,轉載請註明作者並附上原文連結。

留言

訂閱電子報

訂閱後即時收到新文章通知,不錯過任何技術分享。

提交即表示同意接收電子報,隨時可

熱門文章

View all
Mark Ku
··597

Oracle Cloud 永久免費方案 Linux 主機及固定 IP :0 元打造雲端解決方案

Oracle Cloud 永久免費方案 Linux 主機及固定 IP :0 元打造雲端解決方案
Mark Ku
··469

告別 Postman 收費陷阱!開源 Git 原生 API 測試神器 Bruno 實戰指南

告別 Postman 收費陷阱!開源 Git 原生 API 測試神器 Bruno 實戰指南
Mark Ku
··327

一款免費開源類似於 Notion 類知識庫系統 — Outline Wiki 佈署與備份全攻略

一款免費開源類似於 Notion 類知識庫系統 — Outline Wiki 佈署與備份全攻略
Mark Ku
··239

打造高效 API 管理平台:從 0 開始部署 Kong Gateway - Part 1

打造高效 API 管理平台:從 0 開始部署 Kong Gateway - Part 1
Mark Ku
··233

訓練自己的 AI 語音:硬體門檻、開源模型比較與 LoRA 微調

訓練自己的 AI 語音:硬體門檻、開源模型比較與 LoRA 微調
Mark Ku
··220

在 Ubuntu 上設置 Samba 來共享資料夾,讓 Windows 11 用戶可以存取

在 Ubuntu 上設置 Samba 來共享資料夾,讓 Windows 11 用戶可以存取

讀者也在看

2024 Computex 心得  - AI PC 元年

Mark Ku

·3 min read·28

2025 淺談AI 趨勢

Mark Ku

·5 min read

開源AI微調工具 - LLAMA Factory 環境建置

Mark Ku

·5 min read·27

AI 時代的舊系統重構翻新策略

Mark Ku

·7 min read·82

開源AI微調工具 - LLAMA Factory 模型微調

Mark Ku

·2 min read