Thoughts & Cats

Simple life of Khaos

Setup Whispercpp on Windows

Posted at — Jan 14, 2025

Recently, I’ve been using Whisper to transcribe YouTube videos for subtitle translation. I have a Windows PC with an NVIDIA 3060 GPU, which is suitable for running Whisper. Initially, I set up the Whisper.cpp service under WSL2 (Windows Subsystem for Linux) because I’m more comfortable with Linux development.

At first, everything worked fine, but I noticed that the network connection between my local computer and the Whisper.cpp service was a bit unstable. The setup looked like this:

local_computer => windows PC(Port forward) => Whisper.cpp server on WSL2

Sometimes, the network would become unstable, and even SSH connections would get stuck. After some research, I found various reasons online—some suggested that WSL2’s network might be unstable, while others pointed to firewall issues. I thought it might be better to run the Whisper.cpp server directly on Windows instead of WSL2 to avoid potential network instability. However, I later discovered that the issue wasn’t with WSL2 but with a virtual network card installed on my computer at the time. After resetting the network, the problem was resolved.

My System:

OS: Windows 10
CPU: Intel i7 4790K
Memory: 16GB
GPU: NVIDIA 3060 Ti (8G)

MSVC way:

  1. Prerequisite:

    • CUDA Toolkit: Download and install the appropriate version for your system
    • MicroSoft Visual Studio: Install the Community 2022 version. During installation, ensure you select the C++ development components.
  2. Environment Setup:

    • Before starting, make sure your environment variables are correctly set, especially for the CUDA Toolkit.
  3. Building Whisper.cpp:

    • Open Developer Command Prompt(ensure you’re using the correct one, as I initially used the wrong prompt because i have several Prompt on my windows)
    • CD to your whisper.cpp working directory(I assume you have already clone the whisper.cpp source code from the github first)
    • Run the below command:
      mkdir build
      cd build
      cmake -S . -B ./build -A x64 -DGGML_CUDA=ON
      cmake --build . --config Release
      
    • The executable file will be located in the build/Release/bin directory
    • If you want to move the exec files into somewhere else, ensure that the necessary DLL files in bin could be accessible
  4. Run whisper.cpp server:

    ./build/Release/bin/server.exe -m models/ggml-base.bin
    

This is my experience building and running Whisper.cpp on Windows. I hope it helps others who might face similar issues!

Reference:

  1. https://github.com/ggerganov/whisper.cpp/discussions/85