mirror of
https://github.com/slackr31337/wyoming-piper-gpu.git
synced 2026-10-21 02:22:32 +02:00
CUDA 11.8 CUDNN 8
Tested and working
This commit is contained in:
+57
-44
@@ -1,89 +1,104 @@
|
||||
##########################################
|
||||
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 AS build
|
||||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 AS build
|
||||
|
||||
ARG TARGETARCH=linux_x86_64
|
||||
ARG WYOMING_PIPER_VERSION="1.5.2"
|
||||
ARG ONNXRUNTIME_VERSION="1.20.1"
|
||||
ARG PIPER_VERSION="1.2.0"
|
||||
ARG PIPER_PHONEMIZE_VERSION="1.1.0"
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN \
|
||||
apt-get update && apt-get upgrade -y &&\
|
||||
apt-get update &&\
|
||||
apt-get install -y --no-install-recommends \
|
||||
wget \
|
||||
curl \
|
||||
vim \
|
||||
git \
|
||||
patch \
|
||||
python3 \
|
||||
python3-dev \
|
||||
python3-venv \
|
||||
python3-pip \
|
||||
ca-certificates \
|
||||
git \
|
||||
build-essential \
|
||||
cmake \
|
||||
ca-certificates \
|
||||
pkg-config
|
||||
|
||||
RUN \
|
||||
mkdir -p /app/lib &&\
|
||||
cd /tmp && wget -q https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}.tgz &&\
|
||||
tar xzf onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}.tgz &&\
|
||||
cp -rfv /tmp/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}/lib/lib* /app/lib &&\
|
||||
cp -rfv /tmp/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}/include/* /usr/local/include/
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY patches/* /tmp/
|
||||
RUN \
|
||||
git clone https://github.com/rhasspy/piper.git /build &&\
|
||||
cd /build && patch -p0 --forward < /tmp/piper_CMakeLists.patch
|
||||
|
||||
RUN ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION} cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install
|
||||
RUN cmake --build build --config Release
|
||||
RUN cmake --install build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY run.sh .
|
||||
COPY patches/* /tmp/
|
||||
|
||||
RUN \
|
||||
mkdir -p /app/lib /app/share /app/include/piper-phonemize &&\
|
||||
python3 -m venv /app &&\
|
||||
mkdir /app/piper && cp -rfv /build/install/* /app/piper/ &&\
|
||||
chmod 755 /app/piper/piper /app/piper/espeak-ng
|
||||
|
||||
RUN /app/piper/piper --help
|
||||
|
||||
COPY requirements.txt /app/
|
||||
COPY run.sh /app/
|
||||
|
||||
RUN \
|
||||
. /app/bin/activate && \
|
||||
/app/bin/python3 -m pip install --no-cache-dir \
|
||||
-r /app/requirements.txt \
|
||||
&&\
|
||||
\
|
||||
/app/bin/python3 -m pip install --no-cache-dir --force-reinstall --no-deps \
|
||||
"piper-tts==${PIPER_VERSION}" &&\
|
||||
\
|
||||
wget -q https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/piper_phonemize-${PIPER_PHONEMIZE_VERSION}-cp310-cp310-manylinux_2_28_x86_64.whl \
|
||||
-O /tmp/piper_phonemize-${PIPER_PHONEMIZE_VERSION}-py3-none-any.whl &&\
|
||||
\
|
||||
/app/bin/python3 -m pip install --no-cache-dir --force-reinstall --no-deps \
|
||||
/tmp/piper_phonemize-${PIPER_PHONEMIZE_VERSION}-py3-none-any.whl &&\
|
||||
\
|
||||
wget -q https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-amd64.tar.gz -O -| \
|
||||
tar -zxvf - -C /app &&\
|
||||
\
|
||||
mv /app/etc/* /app/share/ &&\
|
||||
mv /app/lib/espeak-ng-data /app/share/ &&\
|
||||
mv /app/include/*.hpp /app/include/piper-phonemize/ &&\
|
||||
mv /app/include/cpu_provider_factory.h /app/include/piper-phonemize/ &&\
|
||||
mv /app/include/provider_options.h /app/include/piper-phonemize/ &&\
|
||||
\
|
||||
LATEST_PIPER_VERSION=$(wget -q "https://api.github.com/repos/rhasspy/piper/releases/latest" -O -|awk '/tag_name/{print $4;exit}' FS='[""]') && \
|
||||
\
|
||||
wget "https://github.com/rhasspy/piper/releases/download/${LATEST_PIPER_VERSION}/piper_${TARGETARCH}.tar.gz" -O -|tar -zxvf - -C /usr/share &&\
|
||||
\
|
||||
/app/bin/python3 -m pip install --no-cache-dir \
|
||||
"wyoming-piper @ https://github.com/rhasspy/wyoming-piper/archive/refs/tags/v${WYOMING_PIPER_VERSION}.tar.gz"
|
||||
|
||||
|
||||
WORKDIR /work
|
||||
|
||||
RUN git clone https://github.com/rhasspy/piper.git .
|
||||
|
||||
RUN cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install -DPIPER_PHONEMIZE_DIR=/app
|
||||
RUN cmake --build build --config Release
|
||||
RUN cmake --install build
|
||||
|
||||
RUN /work/install/piper --help
|
||||
|
||||
RUN mkdir -p /app/piper && \
|
||||
mv /work/install/lib*.so* /app/lib/ &&\
|
||||
cp -rf /work/install/* /app/piper/
|
||||
|
||||
RUN \
|
||||
wget -q https://github.com/microsoft/onnxruntime/releases/download/v1.14.1/onnxruntime-linux-x64-gpu-1.14.1.tgz -O - | \
|
||||
tar -zxvf - -C /tmp/ &&\
|
||||
cp /tmp/onnxruntime-linux-x64-gpu-1.14.1/lib/* /app/lib/
|
||||
|
||||
RUN \
|
||||
cd /app/lib/python3.10/site-packages/wyoming_piper/; \
|
||||
for file in /tmp/wyoming_piper*.diff;do patch -p0 --forward < $file;done; \
|
||||
cp /build/install/lib*.so* /app/lib/
|
||||
for file in /tmp/wyoming_piper*.diff;do patch -p0 --forward < $file;done;
|
||||
|
||||
##########################################
|
||||
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 AS dist
|
||||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 AS dist
|
||||
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
ENV PATH="/bin:$PATH"
|
||||
|
||||
RUN \
|
||||
mkdir -p /data /app &&\
|
||||
apt-get update && apt-get upgrade -y &&\
|
||||
apt-get update &&\
|
||||
apt-get install -y --no-install-recommends \
|
||||
wget \
|
||||
curl \
|
||||
vim \
|
||||
python3 \
|
||||
python3-dev \
|
||||
python3-venv \
|
||||
python3-pip \
|
||||
ca-certificates
|
||||
|
||||
@@ -92,8 +107,6 @@ RUN rm -rf /root/.cache/pip /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY --from=build /app .
|
||||
|
||||
RUN ln -s /app/piper/espeak-ng-data /usr/share/espeak-ng-data
|
||||
|
||||
EXPOSE 10200
|
||||
|
||||
ENTRYPOINT ["bash", "/app/run.sh"]
|
||||
@@ -9,11 +9,17 @@ https://github.com/rhasspy/wyoming-piper
|
||||
|
||||
docker pull ghcr.io/slackr31337/wyoming-piper-gpu:latest
|
||||
|
||||
Use environment variable to set piper voice
|
||||
|
||||
PIPER_VOICE="en_US-lessac-medium"
|
||||
PIPER_LENGTH="1.0"
|
||||
PIPER_NOISE="0.667"
|
||||
PIPER_NOISEW="0.333"
|
||||
PIPER_SPEAKER="0"
|
||||
PIPER_SILENCE="1.2"
|
||||
# Use environment variable to set piper voice
|
||||
|
||||
> PIPER_VOICE="en_US-lessac-medium"
|
||||
>
|
||||
> PIPER_LENGTH="1.0"
|
||||
>
|
||||
> PIPER_NOISE="0.667"
|
||||
>
|
||||
> PIPER_NOISEW="0.333"
|
||||
>
|
||||
> PIPER_SPEAKER="0"
|
||||
>
|
||||
> PIPER_SILENCE="1.2"
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
"""
|
||||
From https://github.com/rhasspy/piper/issues/24
|
||||
"""
|
||||
|
||||
import torch
|
||||
import os
|
||||
|
||||
def print_cuda_details():
|
||||
|
||||
if torch.cuda.is_available():
|
||||
# GPU device details
|
||||
device_id = torch.cuda.current_device()
|
||||
device_name = torch.cuda.get_device_name(device_id)
|
||||
total_memory = torch.cuda.get_device_properties(device_id).total_memory / (1024**3) # GB
|
||||
memory_allocated = torch.cuda.memory_allocated(device_id) / (1024**3) # GB
|
||||
memory_cached = torch.cuda.memory_reserved(device_id) / (1024**3) # GB
|
||||
multiprocessors = torch.cuda.get_device_properties(device_id).multi_processor_count
|
||||
|
||||
# CUDA and PyTorch versions
|
||||
cuda_version = torch.version.cuda
|
||||
pytorch_version = torch.__version__
|
||||
|
||||
# Device properties
|
||||
device_properties = torch.cuda.get_device_properties(device_id)
|
||||
compute_capability = device_properties.major, device_properties.minor
|
||||
|
||||
# Display the details with improved formatting
|
||||
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
|
||||
print(f"")
|
||||
print("Checking CUDA information within the python environment...")
|
||||
print(f"")
|
||||
|
||||
print("###########################################################")
|
||||
print(f"CUDA Available: TRUE")
|
||||
print(f"Using GPU: {device_name}")
|
||||
print("###########################################################")
|
||||
print(f"")
|
||||
|
||||
print(f"CUDA Version: {cuda_version}")
|
||||
print(f"PyTorch Version: {pytorch_version}")
|
||||
print(f"Device ID: {device_id}")
|
||||
print(f"Total Memory: {total_memory:.2f} GB")
|
||||
print(f"Memory Allocated: {memory_allocated:.2f} GB")
|
||||
print(f"Memory Cached: {memory_cached:.2f} GB")
|
||||
print(f"Multiprocessors: {multiprocessors}")
|
||||
print(f"Compute Capability: {compute_capability[0]}.{compute_capability[1]}")
|
||||
print(f"")
|
||||
|
||||
# Device Name
|
||||
print(f"CUDA Device Name: {torch.cuda.get_device_name(device_id)}")
|
||||
print(f"")
|
||||
|
||||
# CUDA Path (from environment variables)
|
||||
cuda_path = os.getenv('CUDA_PATH', 'Not set')
|
||||
print(f"CUDA Path: {cuda_path}")
|
||||
|
||||
# CUDA Toolkit Directory (check via environment variable if available)
|
||||
cuda_toolkit_dir = os.getenv('CUDA_HOME', 'Not set')
|
||||
print(f"CUDA Toolkit Dir: {cuda_toolkit_dir}")
|
||||
|
||||
# Environment Variables
|
||||
print(f"\n")
|
||||
print("=================================================")
|
||||
print("--- Below are OS SYSTEM Environment Variables ---")
|
||||
print(" not just whats available within the python VENV")
|
||||
print("=================================================")
|
||||
print(f"")
|
||||
|
||||
print(f"{'CUDA_HOME:':<25} {os.environ.get('CUDA_HOME', 'Not set')}")
|
||||
print(f"")
|
||||
|
||||
print(f"{'CUDA_VISIBLE_DEVICES:':<25} {os.environ.get('CUDA_VISIBLE_DEVICES', 'Not set')}")
|
||||
print(f"")
|
||||
|
||||
print(f"{'LD_LIBRARY_PATH:':<25} {os.environ.get('LD_LIBRARY_PATH', 'Not set')}")
|
||||
print(f"")
|
||||
|
||||
print(f"{'PATH:':<25} {os.environ.get('PATH', 'Not set')}")
|
||||
print(f"")
|
||||
|
||||
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
|
||||
else:
|
||||
print("##############################################################")
|
||||
print("CUDA is NOT available! You may need to reinstall Pytorch/Torch")
|
||||
print("Falling back to using CPU.")
|
||||
print("##############################################################")
|
||||
print(f"")
|
||||
|
||||
# Provide details for CPU-based configurations
|
||||
print(f"PyTorch Version: {torch.__version__}")
|
||||
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
|
||||
|
||||
# Call the function to print details
|
||||
print_cuda_details()
|
||||
@@ -1,16 +0,0 @@
|
||||
--- CMakeLists.txt 2025-01-12 11:49:52.100425655 -0500
|
||||
+++ CMakeLists.txt.patched 2025-01-12 11:50:56.033517774 -0500
|
||||
@@ -60,11 +60,12 @@
|
||||
|
||||
if(NOT DEFINED PIPER_PHONEMIZE_DIR)
|
||||
set(PIPER_PHONEMIZE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pi")
|
||||
+ set(ONNXRUNTIME_VERSION "$ENV{ONNXRUNTIME_VERSION}")
|
||||
ExternalProject_Add(
|
||||
piper_phonemize_external
|
||||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/p"
|
||||
URL "https://github.com/rhasspy/piper-phonemize/archive/refs/heads/master.zip"
|
||||
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR}
|
||||
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR} -DONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION}
|
||||
)
|
||||
add_dependencies(piper piper_phonemize_external)
|
||||
add_dependencies(test_piper piper_phonemize_external)
|
||||
@@ -1,9 +1,9 @@
|
||||
--- process.py 2025-01-12 12:08:32.699567820 -0500
|
||||
+++ process.py.patched 2025-01-12 12:28:28.568004323 -0500
|
||||
--- process.py 2025-01-12 14:43:19.398599231 -0500
|
||||
+++ process.patched 2025-01-12 14:44:38.795966270 -0500
|
||||
@@ -148,6 +148,15 @@
|
||||
if self.args.noise_w:
|
||||
piper_args.extend(["--noise-w", str(self.args.noise_w)])
|
||||
|
||||
|
||||
+ if self.args.sentence_silence:
|
||||
+ piper_args.extend(["--sentence-silence", str(self.args.sentence_silence)])
|
||||
+
|
||||
@@ -15,4 +15,4 @@
|
||||
+
|
||||
_LOGGER.debug(
|
||||
"Starting piper process: %s args=%s", self.args.piper, piper_args
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
piper-tts>=1.2.0
|
||||
onnxruntime-gpu==1.20.1
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LD_LIBRARY_PATH=/app/lib/:/usr/local/cuda-12.3/targets/x86_64-linux/lib:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=/app/lib/:/usr/local/cuda-11.8/targets/x86_64-linux/lib:$LD_LIBRARY_PATH
|
||||
|
||||
# Run wyoming-piper server
|
||||
source /app/bin/activate
|
||||
@@ -16,6 +16,4 @@ source /app/bin/activate
|
||||
--max-piper-procs "${PIPER_PROCS:-1}" \
|
||||
--data-dir /data \
|
||||
--download-dir /data \
|
||||
"$@"
|
||||
|
||||
# --use-cuda crashes with onnxruntime 1.20.1
|
||||
--use-cuda "$@"
|
||||
|
||||
Reference in New Issue
Block a user