# Docker 镜像

用于在 CLORE.AI 上部署 AI 工作负载的即用型 Docker 镜像。

{% hint style="success" %}
直接在此处部署这些镜像 [CLORE.AI 市场](https://clore.ai/marketplace).
{% endhint %}

## 快速部署参考

### 最受欢迎

| 任务             | 镜像                                   | 端口        |
| -------------- | ------------------------------------ | --------- |
| 与 AI 聊天        | `ollama/ollama`                      | 22, 11434 |
| 类似 ChatGPT 的界面 | `ghcr.io/open-webui/open-webui`      | 22, 8080  |
| 图像生成           | `universonic/stable-diffusion-webui` | 22, 7860  |
| 基于节点的图像生成      | `yanwk/comfyui-boot`                 | 22, 8188  |
| LLM API 服务器    | `vllm/vllm-openai`                   | 22, 8000  |

***

## 语言模型

### Ollama

**通用 LLM 运行器 - 运行任何模型的最简单方法。**

```
镜像：ollama/ollama
端口：22/tcp, 11434/http
命令：ollama serve
```

**部署后：**

```bash
# SSH 登录到服务器
ssh -p <port> root@<proxy>

# 拉取并运行模型
ollama pull llama3.2
ollama run llama3.2
```

**环境变量：**

```
OLLAMA_HOST=0.0.0.0
OLLAMA_MODELS=/root/.ollama/models
```

***

### 打开 WebUI

**Ollama 的类似 ChatGPT 界面。**

```
镜像：ghcr.io/open-webui/open-webui:ollama
端口：22/tcp, 8080/http
```

包含内置 Ollama。通过 HTTP 端口访问。

**独立（连接到现有 Ollama）：**

```
镜像：ghcr.io/open-webui/open-webui:main
端口：22/tcp, 8080/http
环境：OLLAMA_BASE_URL=http://localhost:11434
```

***

### vLLM

**具有 OpenAI 兼容 API 的高性能 LLM 服务。**

```
镜像：vllm/vllm-openai:latest
端口：22/tcp, 8000/http
命令：python -m vllm.entrypoints.openai.api_server --model meta-llama/Meta-Llama-3.1-8B-Instruct --host 0.0.0.0
```

**对于更大模型（多 GPU）：**

```bash
python -m vllm.entrypoints.openai.api_server \
    --model meta-llama/Meta-Llama-3.1-70B-Instruct \
    --tensor-parallel-size 2 \
    --host 0.0.0.0
```

**环境变量：**

```
HUGGING_FACE_HUB_TOKEN=<your-token>  # 用于受限模型
```

***

### Text Generation Inference (TGI)

**HuggingFace 的生产级 LLM 服务器。**

```
镜像：ghcr.io/huggingface/text-generation-inference:latest
端口：22/tcp, 8080/http
命令：--model-id meta-llama/Meta-Llama-3.1-8B-Instruct
```

**环境变量：**

```
HUGGING_FACE_HUB_TOKEN=<your-token>
MAX_INPUT_LENGTH=4096
MAX_TOTAL_TOKENS=8192
```

***

## 图像生成

### Stable Diffusion WebUI（AUTOMATIC1111）

**最受欢迎的带扩展的 SD 界面。**

```
镜像：universonic/stable-diffusion-webui:latest
端口：22/tcp, 7860/http
```

**对于低显存（8GB 或更低）：**

```bash
./webui.sh --listen --medvram --xformers
```

**用于 API 访问：**

```bash
./webui.sh --listen --xformers --api
```

***

### ComfyUI

**面向高级用户的基于节点的工作流。**

```
镜像：yanwk/comfyui-boot:cu126-slim
端口：22/tcp, 8188/http
环境：CLI_ARGS=--listen 0.0.0.0
```

**替代镜像：**

```
# 含常用扩展
镜像：ai-dock/comfyui:latest

# 精简版
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
```

**手动安装命令：**

```bash
git clone https://github.com/comfyanonymous/ComfyUI && cd ComfyUI && pip install -r requirements.txt && python main.py --listen 0.0.0.0
```

***

### - 将重光图像转换为 3D

**简化的 SD 界面，类似 Midjourney。**

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp, 7865/http
命令：git clone https://github.com/lllyasviel/Fooocus && cd Fooocus && pip install -r requirements.txt && python launch.py --listen
```

***

### FLUX

**最新的高质量图像生成。**

使用带 FLUX 节点的 ComfyUI：

```
镜像：yanwk/comfyui-boot:cu126-slim
端口：22/tcp, 8188/http
```

或通过 Diffusers：

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

```python
# SSH 后
pip install diffusers transformers accelerate
python << 'EOF'
from diffusers import FluxPipeline
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
pipe.enable_model_cpu_offload()
image = pipe("A cat", num_inference_steps=4).images[0]
image.save("output.png")
EOF
```

***

## 视频生成

### Stable Video Diffusion

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

```bash
pip install diffusers transformers accelerate
python << 'EOF'
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_video
pipe = StableVideoDiffusionPipeline.from_pretrained(
    "stabilityai/stable-video-diffusion-img2vid-xt",
    variant="fp16"
)
pipe.to("cuda")
image = load_image("input.png")
frames = pipe(image, num_frames=25).frames[0]
export_to_video(frames, "output.mp4", fps=7)
EOF
```

***

### AnimateDiff

与 ComfyUI 一起使用：

```
镜像：yanwk/comfyui-boot:cu126-slim
端口：22/tcp, 8188/http
```

通过 ComfyUI 管理器安装 AnimateDiff 节点。

***

## 音频与语音

### Whisper（转录）

```
镜像：onerahmet/openai-whisper-asr-webservice:latest
端口：22/tcp, 9000/http
环境：ASR_MODEL=large-v3
```

**API 用法：**

```bash
curl -X POST "http://localhost:9000/asr" \
    -F "audio_file=@audio.mp3" \
    -F "task=transcribe"
```

***

### Bark（文本转语音）

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

```bash
pip install bark
python << 'EOF'
from bark import SAMPLE_RATE, generate_audio, preload_models
from scipy.io.wavfile import write as write_wav
preload_models()
audio = generate_audio("Hello, this is a test.")
write_wav("output.wav", SAMPLE_RATE, audio)
EOF
```

***

### Stable Audio

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

```bash
pip install stable-audio-tools
# 需要 HF 令牌以访问模型
```

***

## 视觉模型

### LLaVA

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

```bash
pip install llava
python -m llava.serve.cli --model-path liuhaotian/llava-v1.6-34b
```

***

### Llama 3.2 Vision

使用 Ollama：

```
镜像：ollama/ollama
端口：22/tcp, 11434/http
```

```bash
ollama pull llama3.2-vision
ollama run llama3.2-vision "describe this image" --images photo.jpg
```

***

## 开发与训练

### PyTorch 基础

**用于自定义设置和训练。**

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

包含：CUDA 12.1、cuDNN 8、PyTorch 2.1

***

### Jupyter Lab

**用于机器学习的交互式笔记本。**

```
镜像：jupyter/pytorch-notebook:cuda12-pytorch-2.1
端口：22/tcp, 8888/http
```

或使用带 Jupyter 的 PyTorch 基础：

```bash
pip install jupyterlab
jupyter lab --ip=0.0.0.0 --allow-root --no-browser
```

***

### Kohya 训练

**用于 LoRA 和模型微调。**

```
镜像：pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
端口：22/tcp
```

```bash
git clone https://github.com/kohya-ss/sd-scripts
cd sd-scripts
pip install -r requirements.txt
# 使用训练脚本
```

***

## 基础镜像参考

### NVIDIA 官方

| 镜像                                       | CUDA | 模型变体       |
| ---------------------------------------- | ---- | ---------- |
| `nvidia/cuda:12.1.0-devel-ubuntu22.04`   | 12.1 | CUDA 开发    |
| `nvidia/cuda:12.1.0-runtime-ubuntu22.04` | 12.1 | 仅 CUDA 运行时 |
| `nvidia/cuda:11.8.0-devel-ubuntu22.04`   | 11.8 | 遗留兼容性      |

### PyTorch 官方

| 镜像                                             | PyTorch | CUDA |
| ---------------------------------------------- | ------- | ---- |
| `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel`  | 2.5     | 12.4 |
| `pytorch/pytorch:2.0.1-cuda11.7-cudnn8-devel`  | 2.0     | 11.7 |
| `pytorch/pytorch:1.13.1-cuda11.6-cudnn8-devel` | 1.13    | 11.6 |

### HuggingFace

| 镜像                                              | 用途                     |
| ----------------------------------------------- | ---------------------- |
| `huggingface/transformers-pytorch-gpu`          | Transformers + PyTorch |
| `ghcr.io/huggingface/text-generation-inference` | TGI 服务器                |

***

## 使用环境变量进行 SSH 和 Jupyter 访问：

### 常用变量

| 变量                       | 4s                | 示例             |
| ------------------------ | ----------------- | -------------- |
| `HUGGING_FACE_HUB_TOKEN` | 用于受限模型的 HF API 令牌 | `hf_xxx`       |
| `CUDA_VISIBLE_DEVICES`   | GPU 选择            | `0,1`          |
| `TRANSFORMERS_CACHE`     | 模型缓存目录            | `/root/.cache` |

### Ollama 变量

| 变量                    | 4s    | 默认值                |
| --------------------- | ----- | ------------------ |
| `OLLAMA_HOST`         | 绑定地址  | `127.0.0.1`        |
| `OLLAMA_MODELS`       | 模型目录  | `~/.ollama/models` |
| `OLLAMA_NUM_PARALLEL` | 并行请求数 | `1`                |

### vLLM 变量

| 变量                       | 4s                  |
| ------------------------ | ------------------- |
| `VLLM_ATTENTION_BACKEND` | 注意力实现               |
| `VLLM_USE_MODELSCOPE`    | 使用 ModelScope 而非 HF |

***

## 端口参考

| 端口    | 协议   | 服务                       |
| ----- | ---- | ------------------------ |
| 22    | TCP  | SSH                      |
| 7860  | HTTP | Gradio（SD WebUI、Fooocus） |
| 7865  | HTTP | Fooocus 替代项              |
| 8000  | HTTP | vLLM API                 |
| 8080  | HTTP | Open WebUI、TGI           |
| 8188  | HTTP | ComfyUI                  |
| 8888  | HTTP | Jupyter                  |
| 9000  | HTTP | Whisper API              |
| 11434 | TCP  | Ollama API               |

***

## 提示

### 持久存储

挂载卷以在重启之间保留数据：

```bash
docker run -v /data/models:/root/.cache/huggingface ...
```

### GPU 选择

对于多 GPU 系统：

```bash
docker run --gpus '"device=0,1"' ...
# 或
CUDA_VISIBLE_DEVICES=0,1
```

### 内存管理

如果显存不足：

1. 使用更小的模型
2. 启用 CPU 卸载
3. 减少批量大小
4. 使用量化模型（GGUF Q4）

## 使用以下方式支付

* [GPU 对比](https://docs.clore.ai/guides/guides_v2-zh/ru-men/gpu-comparison) - 选择合适的 GPU
* [模型兼容性](https://docs.clore.ai/guides/guides_v2-zh/ru-men/model-compatibility) - 哪些能在哪里运行
* [快速入门指南](https://docs.clore.ai/guides/guides_v2-zh/quickstart) - 5 分钟快速上手


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/ru-men/docker-images.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
