llamafactory

longkeyy/llamafactory Docker Image

支持NVIDIA CUDA、华为Ascend NPU、AMD ROCm等多硬件后端的模型训练与推理Docker镜像,提供Web UI和OpenAI兼容API访问。

下载次数: 0状态:社区镜像维护者:longkeyy仓库类型:镜像最近更新:
下载命令
点击查看

🐳 LlamaFactory Docker Image Usage Guide

longkeyy/llamafactory is a versatile Docker image supporting multiple hardware backends for model training and inference, including NVIDIA CUDA, Huawei Ascend NPU, and AMD ROCm. It offers both Web UI and OpenAI-compatible API access.


🔖 Available Tags and Environments

TagBackendDescriptionRecommended For
cuda, latestNVIDIA CUDAStandard version for NVIDIA GPUsMachines with CUDA GPUs
npuAscend NPUBuilt for Huawei Ascend NPUsAscend 310/910 setups
rocmAMD ROCmCompatible with AMD ROCm GPUsMachines with AMD GPUs

Note: latest always points to the latest cuda image.


🚀 Quick Start

CUDA Version (NVIDIA GPU)

bash
docker run -it --gpus all \
  --shm-size 16g \
  --ipc host \
  -p 7860:7860 -p 8000:8000 \
  -v $PWD/hf_cache:/root/.cache/huggingface \
  -v $PWD/ms_cache:/root/.cache/modelscope \
  -v $PWD/om_cache:/root/.cache/openmind \
  -v $PWD/data:/app/data \
  -v $PWD/output:/app/output \
  --restart unless-stopped \
  longkeyy/llamafactory:cuda-0.9.2

NPU Version (Huawei Ascend)

Make sure the necessary Ascend drivers and devices are mounted.

bash
docker run -it \
  --shm-size 16g \
  --ipc host \
  --device /dev/davinci0 \
  --device /dev/davinci_manager \
  --device /dev/devmm_svm \
  --device /dev/hisi_hdc \
  -v /usr/local/dcmi:/usr/local/dcmi \
  -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
  -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
  -v /etc/ascend_install.info:/etc/ascend_install.info \
  -v $PWD/hf_cache:/root/.cache/huggingface \
  -v $PWD/ms_cache:/root/.cache/modelscope \
  -v $PWD/om_cache:/root/.cache/openmind \
  -v $PWD/data:/app/data \
  -v $PWD/output:/app/output \
  -p 7860:7860 -p 8000:8000 \
  longkeyy/llamafactory:npu-0.9.2

ROCm Version (AMD GPU)

bash
docker run -it \
  --shm-size 16g \
  --ipc host \
  --device /dev/kfd \
  --device /dev/dri \
  -v $PWD/hf_cache:/root/.cache/huggingface \
  -v $PWD/ms_cache:/root/.cache/modelscope \
  -v $PWD/om_cache:/root/.cache/openmind \
  -v $PWD/data:/app/data \
  -v $PWD/output:/app/output \
  -v $PWD/saves:/app/saves \
  -p 7860:7860 -p 8000:8000 \
  --restart unless-stopped \
  longkeyy/llamafactory:rocm-0.9.2

📄 Docker Compose Setup

docker-compose.yml (Multi-backend)

yaml
version: '3.8'

services:
  llamafactory-cuda:
    image: longkeyy/llamafactory:cuda-0.9.2
    container_name: llamafactory-cuda
    ports:
      - "7860:7860"
      - "8000:8000"
    volumes:
      - ./hf_cache:/root/.cache/huggingface
      - ./ms_cache:/root/.cache/modelscope
      - ./om_cache:/root/.cache/openmind
      - ./data:/app/data
      - ./output:/app/output
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    shm_size: "16gb"
    ipc: host
    tty: true
    restart: unless-stopped
    profiles: ["cuda"]

  llamafactory-npu:
    image: longkeyy/llamafactory:npu-0.9.2
    container_name: llamafactory-npu
    ports:
      - "7860:7860"
      - "8000:8000"
    volumes:
      - ./hf_cache:/root/.cache/huggingface
      - ./ms_cache:/root/.cache/modelscope
      - ./om_cache:/root/.cache/openmind
      - ./data:/app/data
      - ./output:/app/output
      - /usr/local/dcmi:/usr/local/dcmi
      - /usr/local/bin/npu-smi:/usr/local/bin/npu-smi
      - /usr/local/Ascend/driver:/usr/local/Ascend/driver
      - /etc/ascend_install.info:/etc/ascend_install.info
    devices:
      - /dev/davinci0
      - /dev/davinci_manager
      - /dev/devmm_svm
      - /dev/hisi_hdc
    shm_size: "16gb"
    ipc: host
    tty: true
    stdin_open: true
    restart: unless-stopped
    profiles: ["npu"]

  llamafactory-rocm:
    image: longkeyy/llamafactory:rocm-0.9.2
    container_name: llamafactory-rocm
    ports:
      - "7860:7860"
      - "8000:8000"
    volumes:
      - ./hf_cache:/root/.cache/huggingface
      - ./ms_cache:/root/.cache/modelscope
      - ./om_cache:/root/.cache/openmind
      - ./data:/app/data
      - ./output:/app/output
      - ./saves:/app/saves
    devices:
      - /dev/kfd:/dev/kfd
      - /dev/dri:/dev/dri
    shm_size: "16gb"
    ipc: host
    tty: true
    stdin_open: true
    restart: unless-stopped
    profiles: ["rocm"]

Run with a Specific Backend

bash
# CUDA
docker compose --profile cuda up -d

# NPU
docker compose --profile npu up -d

# ROCm
docker compose --profile rocm up -d

📁 Mounted Volumes

Host PathContainer PathDescription
./hf_cache/root/.cache/huggingfaceHuggingFace model cache
./ms_cache/root/.cache/modelscopeModelScope model cache
./om_cache/root/.cache/openmindOpenMind cache
./data/app/dataDataset directory
./output/app/outputOutput directory
./saves (ROCm only)/app/savesModel save directory

🌐 Access Points

  • Web UI: http://localhost:7860
  • API Endpoint: http://localhost:8000

✅ Best Practices

  • Use --restart unless-stopped for service resilience.
  • Images include llamafactory-cli webui as the default command.
  • Extend builds with optional components via Dockerfile ARGs if needed.

📦 Image Size Overview

TagSize
cuda~42.9 GB
npu~34.6 GB
rocm~76.6 GB

Happy experimenting with LlamaFactory! 🦙

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 llamafactory 镜像标签

docker pull docker.xuanyuan.run/longkeyy/llamafactory:<标签>

DockerHub 原生拉取命令

docker pull longkeyy/llamafactory:<标签>
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载在线技术支持专业版保障服务可用付费会员免广告