当前位置: 首页 > news >正文

国内Ubuntu环境Docker部署CosyVoice

国内Ubuntu环境Docker部署CosyVoice


本文旨在记录在 国内 CosyVoice项目在 Ubuntu 环境下如何使用 docker+min-conda进行一键部署。
源项目地址:
https://github.com/FunAudioLLM/CosyVoice

如果想要使用 docker+python 进行部署,可以参考我另一篇博客中的dockerfile进行修改。
https://blog.csdn.net/qq_36991535/article/details/144872382?spm=1001.2014.3001.5502

你只需要将在 git clone 的项目根目录下创建 docker 文件夹,然后将本文的文件放到docker文件夹内; model_download.py 放到项目根目录下;最后进入docker文件夹,使用docker compose -f compose.yaml up 命令即可一键部署。

文件一览:

  • Dockerfile
  • compose.yaml
  • requirements.txt
  • start.sh
  • model_download.py

效果,端口8888
在这里插入图片描述

Dockerfile

FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04ARG VENV_NAME="cosyvoice"
ENV VENV=$VENV_NAME
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8ENV DEBIAN_FRONTEN=noninteractive
ENV PYTHONUNBUFFERED=1
SHELL ["/bin/bash", "--login", "-c"]RUN apt-get update -y --fix-missing
RUN apt-get install -y git build-essential curl wget ffmpeg unzip git git-lfs sox libsox-dev && \apt-get clean && \git lfs install# ==================================================================
# conda install and conda forge channel as default
# ------------------------------------------------------------------
# Install miniforge
RUN wget --quiet https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O ~/miniforge.sh && \/bin/bash ~/miniforge.sh -b -p /opt/conda && \rm ~/miniforge.sh && \ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \echo "source /opt/conda/etc/profile.d/conda.sh" >> /opt/nvidia/entrypoint.d/100.conda.sh && \echo "source /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \echo "conda activate ${VENV}" >> /opt/nvidia/entrypoint.d/110.conda_default_env.sh && \echo "conda activate ${VENV}" >> $HOME/.bashrcENV PATH /opt/conda/bin:$PATHRUN conda config --add channels conda-forge && \conda config --set channel_priority strict
# ------------------------------------------------------------------
# ~conda
# ==================================================================RUN conda create -y -n ${VENV} python=3.8
ENV CONDA_DEFAULT_ENV=${VENV}
ENV PATH /opt/conda/bin:/opt/conda/envs/${VENV}/bin:$PATHWORKDIR /workspace
COPY ./requirements.txt ./ENV PYTHONPATH="${PYTHONPATH}:/workspace/CosyVoice:/workspace/CosyVoice/third_party/Matcha-TTS"# RUN git clone --recursive https://github.com/FunAudioLLM/CosyVoice.gitRUN conda activate ${VENV} && conda install -y -c conda-forge pynini==2.1.5
# RUN conda activate ${VENV} && cd CosyVoice && pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com
RUN conda activate ${VENV} && pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.comWORKDIR /workspace/CosyVoice

compose.yaml

services:cosyvoice:container_name: cosyvoiceimage: cosyvoice:1.0restart: alwaysports:- 8888:8888environment:- TZ=Asia/Tokyo- NVIDIA_VISIBLE_DEVICES=allvolumes:- ../../CosyVoice:/workspace/CosyVoice# command: tail -f /dev/nullcommand: sh -c "docker/start.sh"deploy:resources:reservations:devices:- driver: nvidiacapabilities: [gpu]

requirements.txt

# --extra-index-url https://download.pytorch.org/whl/cu121
--extra-index-url https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/wheel/cu121/
--extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ # https://github.com/microsoft/onnxruntime/issues/21684
conformer==0.3.2
deepspeed==0.14.2; sys_platform == 'linux'
diffusers==0.27.2
gdown==5.1.0
gradio==4.32.2
grpcio==1.57.0
grpcio-tools==1.57.0
huggingface-hub==0.25.2
hydra-core==1.3.2
HyperPyYAML==1.2.2
inflect==7.3.1
librosa==0.10.2
lightning==2.2.4
matplotlib==3.7.5
modelscope==1.15.0
networkx==3.1
omegaconf==2.3.0
onnx==1.16.0
onnxruntime-gpu==1.18.0; sys_platform == 'linux'
onnxruntime==1.18.0; sys_platform == 'darwin' or sys_platform == 'windows'
openai-whisper==20231117
protobuf==4.25
pydantic==2.7.0
rich==13.7.1
soundfile==0.12.1
tensorboard==2.14.0
tensorrt-cu12==10.0.1; sys_platform == 'linux'
tensorrt-cu12-bindings==10.0.1; sys_platform == 'linux'
tensorrt-cu12-libs==10.0.1; sys_platform == 'linux'
torch==2.3.1
torchaudio==2.3.1
transformers==4.40.1
uvicorn==0.30.0
wget==3.2
fastapi==0.111.0
fastapi-cli==0.0.4
WeTextProcessing==1.0.3
matcha

start.sh

#! /bin/bash
python3 model_download.py
python3 webui.py --port 8888 --model_dir pretrained_models/CosyVoice-300M

model_download.py

# SDK模型下载
from modelscope import snapshot_download
snapshot_download('iic/CosyVoice2-0.5B', local_dir='pretrained_models/CosyVoice2-0.5B')
snapshot_download('iic/CosyVoice-300M', local_dir='pretrained_models/CosyVoice-300M')
snapshot_download('iic/CosyVoice-300M-25Hz', local_dir='pretrained_models/CosyVoice-300M-25Hz')
snapshot_download('iic/CosyVoice-300M-SFT', local_dir='pretrained_models/CosyVoice-300M-SFT')
snapshot_download('iic/CosyVoice-300M-Instruct', local_dir='pretrained_models/CosyVoice-300M-Instruct')
snapshot_download('iic/CosyVoice-ttsfrd', local_dir='pretrained_models/CosyVoice-ttsfrd')

http://www.mrgr.cn/news/82432.html

相关文章:

  • C++STL中iomanip的使用与细节
  • 手机投屏到电视的3种选择:无线本地投屏,无线远程投屏,AirPlay投屏
  • redis7基础篇2 redis的哨兵模式2
  • 《Rust权威指南》学习笔记(五)
  • Elasticsearch:Lucene 2024 年回顾
  • UE5失真材质
  • 国内Ubuntu环境Docker部署Stable Diffusion入坑记录
  • 多模态论文笔记——Coca
  • 多模态论文笔记——CogVLM和CogVLM2(副)
  • redis的集群模式与ELK基础
  • 如何从文档创建 RAG 评估数据集
  • .Net Core配置系统
  • U8G2库使用案例(stm32)
  • 计算机网络原理(谢希仁第八版)第4章课后习题答案
  • Java-list均分分割到多个子列表
  • Unity+Hybridclr发布WebGL记录
  • [Hive]七 Hive 内核
  • springboot3+vue项目实践-黑马
  • 大模型WebUI:Gradio全解系列10——Additional Features:补充特性(下)
  • 【开源社区openEuler实践】qemu
  • UML之泛化、特化和继承
  • YOLO11改进 | 卷积模块 | ECCV2024 小波卷积
  • Linux下部署Redis集群 - 一主二从三哨兵模式
  • mysql 事物隔离级别 与mvcc
  • 【go每日一题】golang异常、错误 {源码、实践、总结}
  • 数据挖掘——支持向量机分类器