Skip to content

Build script for Fedora with ROCm/CUDA/CPU support #198

@JumpLink

Description

@JumpLink

I created a build script for Fedora that supports building with ROCm (AMD GPU), CUDA (NVIDIA GPU), or CPU-only acceleration. This might be helpful for other users who want to build the project on Fedora or use it as inspiration for other Linux distributions with ROCm or CUDA support.

Prerequisites

I myself have only tested ROCm and it seems to work. CUDA would have to be tried by someone else and could give feedback here.

Usage

  1. Save this script as build-fedora.sh in the project root
  2. Make it executable: chmod +x build-fedora.sh
  3. Run it: ./build-fedora.sh
#!/bin/bash

# Exit on error
set -e

# Install required dependencies
sudo dnf install -y \
    gcc \
    gcc-c++ \
    cmake \
    ninja-build \
    git \
    openssl-devel \
    qt6-qtbase-devel \
    qt6-qtbase-private-devel \
    qt6-qtsvg-devel \
    qt6-qtwayland-devel \
    qt6-qtshadertools-devel \
    qt6-qtdeclarative-devel \
    wayland-devel \
    libX11-devel \
    libXcomposite-devel \
    libXinerama-devel \
    libXrandr-devel \
    libXfixes-devel \
    libxcb-devel \
    libcurl-devel \
    ccache \
    obs-studio-devel \
    ffmpeg-devel \
    x264-devel \
    jansson-devel \
    pulseaudio-libs-devel \
    libv4l-devel \
    freetype-devel \
    fontconfig-devel \
    mbedtls-devel \
    swig \
    luajit-devel \
    python3-devel \
    rocm-runtime \
    rocm-hip-devel \
    rocm-opencl-devel

# Create build directory
rm -rf build
mkdir -p build

# Set acceleration to hipblas (AMD ROCm)
# Note: This seems to be needed only for the Windows builds, but I added it anyway as a precaution.
# Possible values for ACCELERATION:
# - "cpu"     : CPU only, no hardware acceleration
# - "cuda"    : NVIDIA GPU acceleration using CUDA
# - "hipblas" : AMD GPU acceleration using ROCm/HipBLAS
export ACCELERATION="hipblas"

# Configure with CMake
# For different hardware acceleration support, use WHISPER_ADDITIONAL_CMAKE_ARGS:
# CPU only:
#   -DWHISPER_ADDITIONAL_CMAKE_ARGS="-DWHISPER_BLAS=OFF -DWHISPER_CUBLAS=OFF -DWHISPER_OPENBLAS=OFF"
# AMD GPU (ROCm/HipBLAS):
#   -DWHISPER_ADDITIONAL_CMAKE_ARGS="-DWHISPER_BLAS=ON -DWHISPER_HIPBLAS=ON -DWHISPER_OPENBLAS=OFF -DWHISPER_CUBLAS=OFF"
# NVIDIA GPU (CUDA):
#   -DWHISPER_ADDITIONAL_CMAKE_ARGS="-DWHISPER_BLAS=ON -DWHISPER_HIPBLAS=OFF -DWHISPER_OPENBLAS=OFF -DWHISPER_CUBLAS=ON"
cmake -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DUSE_SYSTEM_CURL=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_PREFIX_PATH=/usr/lib64/cmake/Qt6 \
    -DQT_VERSION=6 \
    -DBUILD_SHARED_LIBS=ON \
    -DWHISPER_ADDITIONAL_CMAKE_ARGS="-DWHISPER_BLAS=ON -DWHISPER_HIPBLAS=ON -DWHISPER_OPENBLAS=OFF -DWHISPER_CUBLAS=OFF"

# Build using all available CPU cores (with retry logic)
cd build
for i in {1..3}; do
    if ninja -j$(nproc); then
        break
    else
        echo "Build attempt $i failed, retrying..."
        sleep 5
    fi
done

# Create plugin directories
mkdir -p ~/.config/obs-studio/plugins/obs-localvocal/bin/64bit
mkdir -p ~/.config/obs-studio/plugins/obs-localvocal/data

# Copy built files to OBS plugin directories (with backup)
if [ -f "obs-localvocal.so" ]; then
    if [ -f ~/.config/obs-studio/plugins/obs-localvocal/bin/64bit/obs-localvocal.so ]; then
        echo "Backing up existing plugin..."
        cp -b ~/.config/obs-studio/plugins/obs-localvocal/bin/64bit/obs-localvocal.so \
           ~/.config/obs-studio/plugins/obs-localvocal/bin/64bit/obs-localvocal.so.bak
    fi
    cp obs-localvocal.so ~/.config/obs-studio/plugins/obs-localvocal/bin/64bit/
fi

# Copy data files (with backup)
if [ -d "../data" ]; then
    if [ -d ~/.config/obs-studio/plugins/obs-localvocal/data ]; then
        echo "Backing up existing data..."
        cp -r -b ~/.config/obs-studio/plugins/obs-localvocal/data \
              ~/.config/obs-studio/plugins/obs-localvocal/data.bak
    fi
    cp -R ../data/* ~/.config/obs-studio/plugins/obs-localvocal/data/
fi

echo "Build and installation completed!"

Notes

  • The script includes support for ROCm, CUDA, and CPU-only builds through CMake options
  • It automatically installs all required dependencies via dnf
  • Creates backups of existing installations before overwriting
  • Includes retry logic for build failures (specifically, the git checkouts often fail for me)
  • Comments explain how to configure for different acceleration methods

Disclaimer

This script was created with the help of an AI assistant. While it works for my setup, I don't have deep understanding of the entire codebase. I'm sharing it in hopes it might help other users or serve as a starting point for automated builds on other distributions.

Feel free to improve upon this or incorporate parts of it into the official build system!

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions