{"id":29873140,"url":"https://github.com/adt109119/llamacpp-distributed-inference","last_synced_at":"2026-05-23T17:03:30.363Z","repository":{"id":305903510,"uuid":"1022875620","full_name":"ADT109119/llamacpp-distributed-inference","owner":"ADT109119","description":"一個基於 llama.cpp 的分佈式 LLM 推理程式，讓您能夠利用區域網路內的多台電腦協同進行大型語言模型的分佈式推理，使用 Electron 的製作跨平台桌面應用程式操作 UI。","archived":false,"fork":false,"pushed_at":"2025-07-22T14:47:40.000Z","size":304,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-22T16:30:10.328Z","etag":null,"topics":["distributed-inference","distributed-llm","gguf","llamacpp","llm","llm-inference","rpc"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ADT109119.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-20T03:15:26.000Z","updated_at":"2025-07-22T14:47:43.000Z","dependencies_parsed_at":"2025-07-22T16:40:33.423Z","dependency_job_id":null,"html_url":"https://github.com/ADT109119/llamacpp-distributed-inference","commit_stats":null,"previous_names":["adt109119/llamacpp-distributed-inference"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ADT109119/llamacpp-distributed-inference","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2Fllamacpp-distributed-inference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2Fllamacpp-distributed-inference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2Fllamacpp-distributed-inference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2Fllamacpp-distributed-inference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ADT109119","download_url":"https://codeload.github.com/ADT109119/llamacpp-distributed-inference/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2Fllamacpp-distributed-inference/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267951760,"owners_count":24171096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-inference","distributed-llm","gguf","llamacpp","llm","llm-inference","rpc"],"created_at":"2025-07-30T22:16:05.288Z","updated_at":"2026-04-16T18:33:37.963Z","avatar_url":"https://github.com/ADT109119.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 分佈式 LLM 推理桌面應用程式\n\n一個基於 [llama.cpp](https://github.com/ggml-org/llama.cpp) 的分佈式 LLM 推理程式，讓您能夠利用區域網路內的多台電腦協同進行大型語言模型的分佈式推理，使用 Electron 的製作跨平台桌面應用程式操作 UI。\n\n![](banner.png)\n\n## 功能特色\n\n- 🖥️ **現代化介面**: 簡潔專業的深色/明亮模式切換\n- 🌐 **智能節點發現**: 自動偵測 + 手動添加，支援定時廣播\n- ⚡ **高效分佈式推理**: 本機API伺服器 + 遠程RPC節點協同計算\n- 📁 **智能模型管理**: 自動掃描 GGUF 格式模型，支援 GPU 層數調整\n- 📊 **實時監控**: 多標籤日誌系統，自動滾動，狀態即時更新\n- 🔧 **專業工具**: 節點連接檢查、本機IP顯示、手動節點管理\n- 🚀 **跨平台**: 支援 Windows、macOS 和 Linux，統一體驗\n\n![](image.png)\n\n## 系統需求\n\n- Node.js 18+ \n- 支援的作業系統：Windows 10+、macOS 10.15+、Ubuntu 18.04+\n- 至少 8GB RAM（取決於模型大小）\n- 可選：NVIDIA GPU（用於 GPU 加速）\n\n## 🚀 快速開始\n\n### 方法一：下載預編譯版本（推薦）\n\n1. **下載應用程式**\n   - 前往本專案的 [Releases 頁面](../../releases)\n   - 下載對應您作業系統的預編譯版本\n   - Windows: `llamacpp-distributed-inference-win.zip`\n   - macOS: `llamacpp-distributed-inference-mac.zip` (尚無)\n   - Linux: `llamacpp-distributed-inference-linux.zip` (尚無)\n\n2. **解壓縮並啟動**\n   ```bash\n   # Windows\n   解壓縮後雙擊 ./分佈式 LLM 推理器.exe\n   ```\n\n3. **添加模型檔案**\n   - 將 `.gguf` 格式的模型檔案放入 `models/` 資料夾\n   - 可從 [Hugging Face](https://huggingface.co/models?library=gguf) 下載\n\n### 方法二：手動編譯版本\n\n1. **下載專案源碼**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd llamacpp-distributed-inference\n   ```\n\n2. **安裝依賴**\n   ```bash\n   npm install\n   ```\n\n3. **準備 llama.cpp 二進位檔案**\n   - 前往 [llama.cpp Releases](https://github.com/ggerganov/llama.cpp/releases)\n   - 下載對應平台的編譯版本\n   - 解壓縮並將以下檔案放入對應的 `bin/` 資料夾：\n     - Windows: `rpc-server.exe`, `llama-server.exe` → `bin/windows/`\n     - macOS: `rpc-server`, `llama-server` → `bin/macos/`\n     - Linux: `rpc-server`, `llama-server` → `bin/linux/`\n\n4. **準備模型檔案**\n   - 將 `.gguf` 格式的模型檔案放入 `models/` 資料夾\n\n5. **啟動應用程式**\n   ```bash\n   # Windows\n   start.bat\n   \n   # macOS/Linux\n   ./start.sh\n   ```\n\n## 安裝步驟（開發環境）\n\n### 開發環境\n\n1. **克隆專案**\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd llamacpp-distributed-inference\n   ```\n\n2. **安裝依賴**\n   ```bash\n   npm install\n   ```\n\n3. **準備模型檔案**\n   - 將 `.gguf` 格式的模型檔案放入 `models/` 資料夾\n   - 可從 [Hugging Face](https://huggingface.co/models?library=gguf) 下載\n\n4. **確認二進位檔案**\n   - 確保 `bin/` 資料夾包含對應平台的執行檔\n   - 檔案需自行至 https://github.com/ggml-org/llama.cpp/releases 下載\n   - Windows: `rpc-server.exe`, `llama-server.exe`\n   - Linux/macOS: `rpc-server`, `llama-server`\n\n### 生產環境（打包後）\n\n打包後的應用程式結構：\n```\napp/\n├── resources/\n│   ├── bin/               # llama.cpp 執行檔\n│   │   ├── windows/\n│   │   ├── linux/\n│   │   └── macos/\n│   └── app/\n│       ├── src/\n│       ├── models/        # 模型資料夾\n│       └── node_modules/\n```\n\n**重要說明**：\n- 打包時會自動排除 `.gguf` 檔案以減少安裝包大小\n- 用戶需要手動將模型檔案放入安裝後的 `models/` 資料夾\n- 應用程式會自動檢測並載入 `models/` 資料夾中的 `.gguf` 檔案\n\n## 使用方法\n\n### 開發模式\n```bash\nnpm run dev\n```\n\n### 生產模式\n```bash\nnpm start\n```\n\n### 打包應用程式\n```bash\nnpm run build\n```\n\n## 使用說明\n\n### 🚀 **快速開始**\n\n1. **啟動應用程式**\n   - 自動啟動 RPC 伺服器（端口 50052）\n   - 顯示本機所有網路介面 IP\n   - 開始 mDNS 節點發現（每30秒自動搜尋）\n\n2. **節點管理**\n   - **自動發現**: 等待其他節點自動出現\n   - **手動添加**: 點擊 \"+\" 按鈕手動添加節點 IP\n   - **連接檢查**: 點擊 WiFi 圖示驗證節點連接\n   - **節點選擇**: 使用開關選擇參與計算的遠程節點\n\n3. **模型配置**\n   - 從下拉選單選擇 GGUF 模型\n   - 調整 GPU 層數滑動條（-ngl 參數）\n   - 設定並行請求數（-np 參數，預設1）\n   - 設定 API Key（可選，用於保護服務）\n   - 自定義模型路徑（點擊資料夾圖示）\n\n4. **啟動分散式推理**\n   - 點擊「啟動 API 伺服器」\n   - 本機自動作為 API 伺服器參與計算\n   - 選中的遠程節點作為 RPC 計算節點\n   - 服務在 `http://localhost:8080` 啟動\n\n### 📊 **節點架構說明**\n\n```\n┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐\n│   本機 (API)    │    │  遠程節點 (RPC) │    │  遠程節點 (RPC) │\n│  127.0.0.1      │◄──►│  192.168.1.101  │    │  192.168.1.102  │\n│  端口: 8080     │    │  端口: 50052    │    │  端口: 50052    │\n│  [自動參與]     │    │  [可選擇]       │    │  [可選擇]       │\n└─────────────────┘    └─────────────────┘    └─────────────────┘\n```\n\n### 🔧 **進階功能**\n\n#### **主題切換**\n- 點擊右上角月亮/太陽圖示\n- 支援明亮模式（預設）和深色模式\n- 設定自動保存\n\n#### **模型路徑管理**\n- 點擊資料夾圖示設定自定義模型路徑\n- 支援瀏覽器選擇資料夾\n- 一鍵開啟模型資料夾\n- 自動創建預設 models 資料夾\n\n#### **並行請求控制**\n- 滑動條調整並行請求數（1-16）\n- 提高 API 伺服器吞吐量\n- 根據硬體配置優化性能\n\n#### **節點連接檢查**\n- 每個節點都有 WiFi 圖示檢查按鈕\n- 自動檢查 RPC 服務（端口 50052）\n- 顯示連接狀態氣泡提示\n- 定時廣播發現新節點（每30秒）\n\n#### **實時日誌監控**\n- **系統日誌**: 應用程式操作和狀態\n- **RPC 日誌**: RPC 伺服器運行日誌  \n- **API 日誌**: API 伺服器運行日誌\n- 自動滾動到最新訊息\n- 多標籤切換，顏色區分訊息類型\n\n### 🌐 **API 使用**\n\n#### **OpenAI 相容 API**\n```bash\ncurl -X POST http://localhost:8080/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  -d '{\n    \"model\": \"gpt-3.5-turbo\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"max_tokens\": 100,\n    \"temperature\": 0.7\n  }'\n```\n\n#### **健康檢查**\n```bash\ncurl http://localhost:8080/health\n```\n\n#### **模型資訊**\n```bash\ncurl http://localhost:8080/v1/models\n```\n\n## 網路設定\n\n### 🔥 **防火牆設定**\n確保以下端口開放：\n- **50052**: RPC 伺服器通訊端口（必須）\n- **8080**: API 伺服器端口（必須）\n- **5353**: mDNS 服務發現端口（建議）\n\n### 🌐 **網路需求**\n- **可信內網**: **必須在完全可信的內部網路中運行**\n- **網路隔離**: **嚴禁連接到公共網路或不安全網路**\n- **同一網段**: 所有節點必須在相同的區域網路內\n- **mDNS 支援**: 大部分家用路由器預設支援\n- **穩定連接**: 建議使用有線網路以獲得最佳性能\n\n### 💡 **效能建議**\n- **GPU 加速**: 設定適當的 GPU 層數（-ngl）\n- **記憶體管理**: 確保每個節點有足夠 RAM\n- **網路頻寬**: 節點間通訊需要穩定頻寬\n- **負載平衡**: 合理分配計算任務到各節點\n\n### ⚠️ **效能限制**\n- **木桶效應**: 整體推論速度取決於節點中最慢的裝置\n- **瓶頸風險**: 如果有一個裝置特別慢，例如加入了一個僅有CPU沒有GPU的裝置，任務很可能會都卡在那個裝置上\n- **建議**: 使用性能相近的設備組成分散式網路，避免性能差異過大\n\n## 故障排除\n\n## 🔧 故障排除\n\n### ❓ **常見問題**\n\n#### **1. 節點發現問題**\n- **自動發現失敗**: \n  - 檢查防火牆是否開放端口 5353\n  - 確認路由器支援 mDNS 廣播\n  - 使用手動添加功能作為替代方案\n- **節點連接失敗**:\n  - 使用連接檢查功能驗證節點狀態\n  - 確認目標設備已啟動此程式\n  - 檢查網路連通性\n\n#### **2. 模型相關問題**\n- **模型載入失敗**:\n  - 確認檔案格式為 `.gguf`\n  - 檢查檔案完整性和權限\n  - 確保有足夠磁碟空間\n- **記憶體不足**:\n  - 選擇較小的量化模型（如 Q4_K_M）\n  - 調整 GPU 層數設定\n  - 增加更多節點分散負載\n\n#### **3. 服務啟動問題**\n- **API 伺服器啟動失敗**:\n  - 檢查端口 8080 是否被佔用\n  - 查看 API 日誌獲取詳細錯誤\n  - 確認模型檔案路徑正確\n- **RPC 伺服器問題**:\n  - 檢查端口 50052 是否可用\n  - 查看 RPC 日誌排查問題\n  - 重新啟動應用程式\n\n#### **4. 效能優化**\n- **推理速度慢**:\n  - 增加 GPU 層數（如果有 GPU）\n  - 添加更多計算節點\n  - 使用更快的網路連接\n- **網路延遲高**:\n  - 使用有線網路連接\n  - 確保節點在同一網段\n  - 檢查網路頻寬使用情況\n\n### 🔍 **除錯工具**\n\n#### **內建除錯功能**\n- **連接檢查**: 點擊 WiFi 圖示測試節點連接\n- **實時日誌**: 查看詳細的系統運行日誌\n- **狀態監控**: 即時顯示服務器和節點狀態\n- **本機IP顯示**: 確認網路配置正確\n\n#### **命令行工具**\n```bash\n# 檢查端口佔用\nnetstat -an | grep :8080\nnetstat -an | grep :50052\n\n# 測試網路連通性\nping 192.168.1.101\ntelnet 192.168.1.101 50052\n\n# 檢查 mDNS 服務\n# Windows: 使用 Bonjour Browser\n# macOS: dns-sd -B _llm-cluster._tcp\n# Linux: avahi-browse -rt _llm-cluster._tcp\n```\n\n### 📋 **日誌系統**\n應用程式提供完整的日誌監控：\n- **系統日誌**: 節點發現、連接狀態、操作記錄\n- **RPC 日誌**: RPC 伺服器啟動、連接、錯誤訊息\n- **API 日誌**: API 伺服器運行、請求處理、推理日誌\n- **自動滾動**: 新訊息自動滾動到底部\n- **顏色區分**: 成功(綠)、錯誤(紅)、資訊(藍)\n\n### 🎯 **最佳實踐**\n\n#### **部署建議**\n1. **網路規劃**: 使用千兆乙太網路連接所有節點\n2. **硬體配置**: 確保每個節點有足夠的 RAM 和 GPU\n3. **模型選擇**: 根據總記憶體選擇合適的模型大小\n4. **負載測試**: 使用少量節點測試後再擴展\n\n#### **安全建議**\n\u003e ⚠️ **重要提醒**: 以下建議僅能降低風險，但無法完全消除 RPC 通訊的安全隱患\n\n1. **網路隔離**: \n   - **必須**: 在完全隔離的內網中運行\n   - **禁止**: 連接到公共網路或不可信網路\n2. **API Key**: 設定強密碼的 API Key 保護 HTTP 介面\n3. **防火牆**: 嚴格限制 50052 和 8080 端口的存取來源\n4. **監控**: 持續監控網路流量和節點狀態\n5. **定期檢查**: 確認所有參與節點都是可信設備\n\n#### **維護建議**\n1. **定期更新**: 保持應用程式和模型的最新版本\n2. **備份配置**: 備份重要的設定和 API Key\n3. **效能監控**: 關注記憶體使用和網路流量\n4. **故障恢復**: 準備節點故障的應對方案\n\n## 技術架構\n\n- **前端**: HTML + CSS + JavaScript\n- **後端**: Electron (Node.js)\n- **推理引擎**: llama.cpp\n- **服務發現**: mDNS (bonjour-service)\n- **設定儲存**: electron-store\n\n## 開發\n\n### 專案結構\n```\n├── src/\n│   ├── main/           # Electron 主進程\n│   ├── preload/        # 預載腳本\n│   └── renderer/       # 前端介面\n├── bin/                # llama.cpp 二進位檔\n├── models/             # 模型檔案\n└── package.json\n```\n\n## ⚠️ **重要警語與使用限制**\n\n### 🚨 **安全警告**\n- **RPC 通訊安全隱患**: 本專案的 RPC 通訊**未加密且缺乏身份驗證**，存在安全風險\n- **僅限可信網路**: **請僅在完全可信的網路環境中使用**（如家庭內網、隔離的實驗室網路）\n- **禁止公網使用**: **嚴禁在公共網路或不安全的網路環境中運行**，你的電腦很可能會被爆破\n\n### 🎯 **適用場景**\n- ✅ **個人使用**: 個人單機 VRAM 不足，但想跑大一點的模型，且確定只有個人使用，不會部署成服務\n- ✅ **個人學習和研究**: 在家庭網路中進行 LLM 實驗\n- ✅ **概念驗證 (PoC)**: 演示分佈式推理的基本概念\n- ✅ **教育用途**: 學習分佈式計算和 LLM 部署\n- ✅ **原型開發**: 快速驗證分佈式推理想法\n\n### ❌ **不適用場景**\n- ❌ **生產環境部署**: 缺乏企業級安全和穩定性保證\n- ❌ **商業用途**: 未經充分的安全審計和壓力測試\n- ❌ **公共服務**: 不適合對外提供服務\n\n### 🏭 **生產環境建議**\n如需在生產環境中部署 LLM 推理伺服器，建議使用更成熟的解決方案，以獲得更高的安全性與更好的推理效能：\n- **[vLLM](https://github.com/vllm-project/vllm)**: 高效能的 LLM 推理引擎\n- **[Text Generation Inference](https://github.com/huggingface/text-generation-inference)**: Hugging Face 的推理服務\n- **[TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM)**: NVIDIA 的優化推理引擎\n- **[OpenLLM](https://github.com/bentoml/OpenLLM)**: 企業級 LLM 部署平台\n\n---\n\n### 貢獻指南\n1. Fork 專案\n2. 創建功能分支\n3. 提交變更\n4. 發送 Pull Request\n\n## 支援\n\n如有問題或建議，請提交 Issue 或聯繫本人 2.jerry32262686@gmail.com。\n\n## ⚖️ 授權與免責聲明\n\n### 授權\nApache 2.0 License\n\n### 免責聲明\n- 本軟體僅供學習、研究和個人使用\n- 開發者不對因使用本軟體而導致的任何損失或安全問題承擔責任\n- 使用者需自行承擔網路安全風險\n- 在使用前請詳細閱讀並理解所有安全警告\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadt109119%2Fllamacpp-distributed-inference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadt109119%2Fllamacpp-distributed-inference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadt109119%2Fllamacpp-distributed-inference/lists"}