Skip to content

Commit 98b51d9

Browse files
authored
CUDA 11.8 CUDNN 8
Tested and working
1 parent 3154d7b commit 98b51d9

File tree

7 files changed

+169
-76
lines changed

7 files changed

+169
-76
lines changed

Dockerfile

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,104 @@
11
##########################################
2-
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 AS build
2+
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 AS build
33

44
ARG TARGETARCH=linux_x86_64
55
ARG WYOMING_PIPER_VERSION="1.5.2"
6-
ARG ONNXRUNTIME_VERSION="1.20.1"
6+
ARG PIPER_VERSION="1.2.0"
7+
ARG PIPER_PHONEMIZE_VERSION="1.1.0"
78

8-
ENV LANG C.UTF-8
9+
ENV LANG=C.UTF-8
910
ENV DEBIAN_FRONTEND=noninteractive
1011

1112
RUN \
12-
apt-get update && apt-get upgrade -y &&\
13+
apt-get update &&\
1314
apt-get install -y --no-install-recommends \
1415
wget \
1516
curl \
1617
vim \
17-
git \
1818
patch \
1919
python3 \
2020
python3-dev \
2121
python3-venv \
2222
python3-pip \
23+
ca-certificates \
24+
git \
2325
build-essential \
2426
cmake \
25-
ca-certificates \
2627
pkg-config
2728

28-
RUN \
29-
mkdir -p /app/lib &&\
30-
cd /tmp && wget -q https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}.tgz &&\
31-
tar xzf onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}.tgz &&\
32-
cp -rfv /tmp/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}/lib/lib* /app/lib &&\
33-
cp -rfv /tmp/onnxruntime-linux-x64-gpu-${ONNXRUNTIME_VERSION}/include/* /usr/local/include/
34-
35-
WORKDIR /build
29+
WORKDIR /app
3630

31+
COPY run.sh .
3732
COPY patches/* /tmp/
33+
3834
RUN \
39-
git clone https://github.com/rhasspy/piper.git /build &&\
40-
cd /build && patch -p0 --forward < /tmp/piper_CMakeLists.patch
35+
mkdir -p /app/lib /app/share /app/include/piper-phonemize &&\
36+
python3 -m venv /app &&\
37+
. /app/bin/activate && \
38+
\
39+
/app/bin/python3 -m pip install --no-cache-dir --force-reinstall --no-deps \
40+
"piper-tts==${PIPER_VERSION}" &&\
41+
\
42+
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 \
43+
-O /tmp/piper_phonemize-${PIPER_PHONEMIZE_VERSION}-py3-none-any.whl &&\
44+
\
45+
/app/bin/python3 -m pip install --no-cache-dir --force-reinstall --no-deps \
46+
/tmp/piper_phonemize-${PIPER_PHONEMIZE_VERSION}-py3-none-any.whl &&\
47+
\
48+
wget -q https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-amd64.tar.gz -O -| \
49+
tar -zxvf - -C /app &&\
50+
\
51+
mv /app/etc/* /app/share/ &&\
52+
mv /app/lib/espeak-ng-data /app/share/ &&\
53+
mv /app/include/*.hpp /app/include/piper-phonemize/ &&\
54+
mv /app/include/cpu_provider_factory.h /app/include/piper-phonemize/ &&\
55+
mv /app/include/provider_options.h /app/include/piper-phonemize/ &&\
56+
\
57+
LATEST_PIPER_VERSION=$(wget -q "https://api.github.com/repos/rhasspy/piper/releases/latest" -O -|awk '/tag_name/{print $4;exit}' FS='[""]') && \
58+
\
59+
wget "https://github.com/rhasspy/piper/releases/download/${LATEST_PIPER_VERSION}/piper_${TARGETARCH}.tar.gz" -O -|tar -zxvf - -C /usr/share &&\
60+
\
61+
/app/bin/python3 -m pip install --no-cache-dir \
62+
"wyoming-piper @ https://github.com/rhasspy/wyoming-piper/archive/refs/tags/v${WYOMING_PIPER_VERSION}.tar.gz"
4163

42-
RUN ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION} cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install
43-
RUN cmake --build build --config Release
44-
RUN cmake --install build
4564

46-
WORKDIR /app
65+
WORKDIR /work
4766

48-
RUN \
49-
python3 -m venv /app &&\
50-
mkdir /app/piper && cp -rfv /build/install/* /app/piper/ &&\
51-
chmod 755 /app/piper/piper /app/piper/espeak-ng
67+
RUN git clone https://github.com/rhasspy/piper.git .
68+
69+
RUN cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install -DPIPER_PHONEMIZE_DIR=/app
70+
RUN cmake --build build --config Release
71+
RUN cmake --install build
5272

53-
RUN /app/piper/piper --help
73+
RUN /work/install/piper --help
5474

55-
COPY requirements.txt /app/
56-
COPY run.sh /app/
75+
RUN mkdir -p /app/piper && \
76+
mv /work/install/lib*.so* /app/lib/ &&\
77+
cp -rf /work/install/* /app/piper/
5778

5879
RUN \
59-
. /app/bin/activate && \
60-
/app/bin/python3 -m pip install --no-cache-dir \
61-
-r /app/requirements.txt \
62-
&&\
63-
\
64-
/app/bin/python3 -m pip install --no-cache-dir \
65-
"wyoming-piper @ https://github.com/rhasspy/wyoming-piper/archive/refs/tags/v${WYOMING_PIPER_VERSION}.tar.gz"
80+
wget -q https://github.com/microsoft/onnxruntime/releases/download/v1.14.1/onnxruntime-linux-x64-gpu-1.14.1.tgz -O - | \
81+
tar -zxvf - -C /tmp/ &&\
82+
cp /tmp/onnxruntime-linux-x64-gpu-1.14.1/lib/* /app/lib/
6683

6784
RUN \
6885
cd /app/lib/python3.10/site-packages/wyoming_piper/; \
69-
for file in /tmp/wyoming_piper*.diff;do patch -p0 --forward < $file;done; \
70-
cp /build/install/lib*.so* /app/lib/
86+
for file in /tmp/wyoming_piper*.diff;do patch -p0 --forward < $file;done;
7187

7288
##########################################
73-
FROM nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04 AS dist
89+
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 AS dist
7490

7591
ENV PYTHONUNBUFFERED=1
92+
ENV PATH="/bin:$PATH"
7693

7794
RUN \
7895
mkdir -p /data /app &&\
79-
apt-get update && apt-get upgrade -y &&\
96+
apt-get update &&\
8097
apt-get install -y --no-install-recommends \
8198
wget \
8299
curl \
83100
vim \
84101
python3 \
85-
python3-dev \
86-
python3-venv \
87102
python3-pip \
88103
ca-certificates
89104

@@ -92,8 +107,6 @@ RUN rm -rf /root/.cache/pip /var/lib/apt/lists/*
92107
WORKDIR /app
93108
COPY --from=build /app .
94109

95-
RUN ln -s /app/piper/espeak-ng-data /usr/share/espeak-ng-data
96-
97110
EXPOSE 10200
98111

99112
ENTRYPOINT ["bash", "/app/run.sh"]

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ https://github.com/rhasspy/wyoming-piper
99

1010
docker pull ghcr.io/slackr31337/wyoming-piper-gpu:latest
1111

12-
Use environment variable to set piper voice
13-
14-
PIPER_VOICE="en_US-lessac-medium"
15-
PIPER_LENGTH="1.0"
16-
PIPER_NOISE="0.667"
17-
PIPER_NOISEW="0.333"
18-
PIPER_SPEAKER="0"
19-
PIPER_SILENCE="1.2"
12+
13+
# Use environment variable to set piper voice
14+
15+
> PIPER_VOICE="en_US-lessac-medium"
16+
>
17+
> PIPER_LENGTH="1.0"
18+
>
19+
> PIPER_NOISE="0.667"
20+
>
21+
> PIPER_NOISEW="0.333"
22+
>
23+
> PIPER_SPEAKER="0"
24+
>
25+
> PIPER_SILENCE="1.2"

checkCUDA.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
"""
2+
From https://github.com/rhasspy/piper/issues/24
3+
"""
4+
5+
import torch
6+
import os
7+
8+
def print_cuda_details():
9+
10+
if torch.cuda.is_available():
11+
# GPU device details
12+
device_id = torch.cuda.current_device()
13+
device_name = torch.cuda.get_device_name(device_id)
14+
total_memory = torch.cuda.get_device_properties(device_id).total_memory / (1024**3) # GB
15+
memory_allocated = torch.cuda.memory_allocated(device_id) / (1024**3) # GB
16+
memory_cached = torch.cuda.memory_reserved(device_id) / (1024**3) # GB
17+
multiprocessors = torch.cuda.get_device_properties(device_id).multi_processor_count
18+
19+
# CUDA and PyTorch versions
20+
cuda_version = torch.version.cuda
21+
pytorch_version = torch.__version__
22+
23+
# Device properties
24+
device_properties = torch.cuda.get_device_properties(device_id)
25+
compute_capability = device_properties.major, device_properties.minor
26+
27+
# Display the details with improved formatting
28+
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
29+
print(f"")
30+
print("Checking CUDA information within the python environment...")
31+
print(f"")
32+
33+
print("###########################################################")
34+
print(f"CUDA Available: TRUE")
35+
print(f"Using GPU: {device_name}")
36+
print("###########################################################")
37+
print(f"")
38+
39+
print(f"CUDA Version: {cuda_version}")
40+
print(f"PyTorch Version: {pytorch_version}")
41+
print(f"Device ID: {device_id}")
42+
print(f"Total Memory: {total_memory:.2f} GB")
43+
print(f"Memory Allocated: {memory_allocated:.2f} GB")
44+
print(f"Memory Cached: {memory_cached:.2f} GB")
45+
print(f"Multiprocessors: {multiprocessors}")
46+
print(f"Compute Capability: {compute_capability[0]}.{compute_capability[1]}")
47+
print(f"")
48+
49+
# Device Name
50+
print(f"CUDA Device Name: {torch.cuda.get_device_name(device_id)}")
51+
print(f"")
52+
53+
# CUDA Path (from environment variables)
54+
cuda_path = os.getenv('CUDA_PATH', 'Not set')
55+
print(f"CUDA Path: {cuda_path}")
56+
57+
# CUDA Toolkit Directory (check via environment variable if available)
58+
cuda_toolkit_dir = os.getenv('CUDA_HOME', 'Not set')
59+
print(f"CUDA Toolkit Dir: {cuda_toolkit_dir}")
60+
61+
# Environment Variables
62+
print(f"\n")
63+
print("=================================================")
64+
print("--- Below are OS SYSTEM Environment Variables ---")
65+
print(" not just whats available within the python VENV")
66+
print("=================================================")
67+
print(f"")
68+
69+
print(f"{'CUDA_HOME:':<25} {os.environ.get('CUDA_HOME', 'Not set')}")
70+
print(f"")
71+
72+
print(f"{'CUDA_VISIBLE_DEVICES:':<25} {os.environ.get('CUDA_VISIBLE_DEVICES', 'Not set')}")
73+
print(f"")
74+
75+
print(f"{'LD_LIBRARY_PATH:':<25} {os.environ.get('LD_LIBRARY_PATH', 'Not set')}")
76+
print(f"")
77+
78+
print(f"{'PATH:':<25} {os.environ.get('PATH', 'Not set')}")
79+
print(f"")
80+
81+
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
82+
else:
83+
print("##############################################################")
84+
print("CUDA is NOT available! You may need to reinstall Pytorch/Torch")
85+
print("Falling back to using CPU.")
86+
print("##############################################################")
87+
print(f"")
88+
89+
# Provide details for CPU-based configurations
90+
print(f"PyTorch Version: {torch.__version__}")
91+
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
92+
93+
# Call the function to print details
94+
print_cuda_details()

patches/piper_CMakeLists.patch

Lines changed: 0 additions & 16 deletions
This file was deleted.

patches/wyoming_piper_process.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
--- process.py 2025-01-12 12:08:32.699567820 -0500
2-
+++ process.py.patched 2025-01-12 12:28:28.568004323 -0500
1+
--- process.py 2025-01-12 14:43:19.398599231 -0500
2+
+++ process.patched 2025-01-12 14:44:38.795966270 -0500
33
@@ -148,6 +148,15 @@
44
if self.args.noise_w:
55
piper_args.extend(["--noise-w", str(self.args.noise_w)])
6-
6+
77
+ if self.args.sentence_silence:
88
+ piper_args.extend(["--sentence-silence", str(self.args.sentence_silence)])
99
+
@@ -15,4 +15,4 @@
1515
+
1616
_LOGGER.debug(
1717
"Starting piper process: %s args=%s", self.args.piper, piper_args
18-
)
18+
)

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

run.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
export LD_LIBRARY_PATH=/app/lib/:/usr/local/cuda-12.3/targets/x86_64-linux/lib:$LD_LIBRARY_PATH
3+
export LD_LIBRARY_PATH=/app/lib/:/usr/local/cuda-11.8/targets/x86_64-linux/lib:$LD_LIBRARY_PATH
44

55
# Run wyoming-piper server
66
source /app/bin/activate
@@ -16,6 +16,4 @@ source /app/bin/activate
1616
--max-piper-procs "${PIPER_PROCS:-1}" \
1717
--data-dir /data \
1818
--download-dir /data \
19-
"$@"
20-
21-
# --use-cuda crashes with onnxruntime 1.20.1
19+
--use-cuda "$@"

0 commit comments

Comments
 (0)