-
Notifications
You must be signed in to change notification settings - Fork 30
Vulkan support #124
Copy link
Copy link
Open
Description
Hey guys!
I am successfully running kokoro with Vulkan support on TTS.cpp using Docker.
I'm happy to contribute these changes, but have no idea how to format this so it makes sense as a PR.
Here's my Dockerfile:
# ===== Stage 1: builder =====
FROM ubuntu:24.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl git cmake build-essential ninja-build \
libvulkan1 libvulkan-dev vulkan-tools \
ffmpeg \
python3 \
&& rm -rf /var/lib/apt/lists/*
# --- Build Shaderc (glslc) ---
WORKDIR /tmp
RUN git clone https://github.com/google/shaderc.git shaderc \
&& cd shaderc \
&& python3 utils/git-sync-deps \
&& cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/shaderc \
-DSHADERC_SKIP_TESTS=ON \
-DSHADERC_SKIP_EXAMPLES=ON \
-DSPIRV_SKIP_TESTS=ON \
-DSPIRV_TOOLS_BUILD_STATIC=ON \
&& cmake --build build -j \
&& cmake --install build
ENV PATH="/opt/shaderc/bin:${PATH}"
# --- Install NEW Vulkan headers (header-only; provides Vulkan-Hpp too) ---
WORKDIR /tmp
RUN git clone --depth 1 https://github.com/KhronosGroup/Vulkan-Headers.git vkheaders \
&& cmake -S vkheaders -B vkheaders/build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/vulkan \
&& cmake --build vkheaders/build -j \
&& cmake --install vkheaders/build
# Make CMake find these headers before the old distro ones
ENV CMAKE_PREFIX_PATH="/opt/vulkan:${CMAKE_PREFIX_PATH}"
# --- Build whisper.cpp with Vulkan ---
WORKDIR /app
# Clone a TTS-capable repo (TTS.cpp recommended). If you prefer llama.cpp swap the URL.
#RUN git clone --recurse-submodules --depth 1 https://github.com/mmwillet/TTS.cpp.git tts.cpp
# clone repo (no depth shenanigans) and init submodules properly
RUN git clone https://github.com/mmwillet/TTS.cpp.git tts.cpp \
&& cd tts.cpp \
&& git submodule update --init --recursive
RUN apt-get update && apt-get install -y g++-12 libstdc++-12-dev
RUN apt-get update && apt-get install -y g++-13 libstdc++-13-dev
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100
WORKDIR /app/tts.cpp
# Clean any old build
RUN rm -rf build
# Fix bugs that prevent building
RUN touch /app/tts.cpp/include/tts.h
RUN touch /app/tts.cpp/include/phonemizer.h
RUN cp CMakeLists.txt CMakeLists.txt.tmp \
&& sed 's/parer-version.cmake/parler-version.cmake/g' CMakeLists.txt.tmp > CMakeLists.txt \
&& rm CMakeLists.txt.tmp
# Configure + build in one step, passing variables to CMake properly
# Build with Vulkan enabled
RUN cmake -S . -B build \
-G Ninja \
-DGGML_VULKAN=1 \
-DGLSLC_EXECUTABLE=/opt/shaderc/bin/glslc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/tts.cpp \
-DLINUX=ON \
-DCMAKE_CXX_STANDARD=20 \
&& cmake --build build -v -j$(nproc)
RUN cmake --install build
# ===== Stage 2: runtime =====
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# add curl + CA bundle so HTTPS works
RUN apt-get update && apt-get install -y --no-install-recommends \
libvulkan1 vulkan-tools ffmpeg curl ca-certificates \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends \
mesa-vulkan-drivers vulkan-tools \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# copy install tree (bins + libs)
COPY --from=builder /opt/tts.cpp/ /usr/local/
# copy the model helper into PATH
COPY --from=builder /app/models/download-ggml-model.sh /usr/local/bin/download-ggml-model.sh
RUN chmod +x /usr/local/bin/download-ggml-model.sh
# sample clip for fallback runs
COPY --from=builder /app/samples/jfk.wav /samples/jfk.wav
# ensure dynamic linker sees libwhisper.so.*
#RUN printf "/usr/local/lib\n/usr/local/lib64\n" > /etc/ld.so.conf.d/whisper-local.conf && ldconfig
#ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${LD_LIBRARY_PATH}
# (optional but harmless) make curl explicitly use the system bundle
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
# Create a runtime user (non-root)
RUN useradd -m appuser || true
USER appuser
WORKDIR /home/appuser
# mountable models dir
VOLUME ["/home/appuser/models"]
# helpful to keep logs or speaker files
VOLUME ["/home/appuser/data"]
# convenience mount points
#RUN mkdir -p /models /audios
CMD ["/bin/bash"]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels