mirror of
https://github.com/occ-ai/obs-localvocal
synced 2024-11-07 18:57:14 +00:00
Enable MacOS ARM64 and Windows CUDA builds (#76)
* Enable CoreML and allow fallback to CPU on MacOS ARM64 * Disable CoreML support on MacOS ARM64 * Fix build configuration for MacOS * Update macOS build configuration based on MACOS_ARCH environment variable * Update BuildWhispercpp.cmake to disable FMA instructions on non-Apple platforms * Add cuBLAS support to build and package actions * Update Cublas versions in Windows build and packaging scripts * Update CUDA_TOOLKIT_ROOT_DIR environment variable * Add sub-packages and non-cuda-sub-packages options to CUDA toolkit setup * Update CUDA sub-packages in build-project.yaml * Add "visual_studio_integration" to sub-packages in CUDA build workflow * Fix typo in build-project.yaml * Fix typo in CUDA build method * Update sub-packages in CUDA toolkit installation * Remove unnecessary CUDA sub-packages and method
This commit is contained in:
parent
8b1ab7cfed
commit
17ffcfc2c1
5
.github/actions/build-plugin/action.yaml
vendored
5
.github/actions/build-plugin/action.yaml
vendored
@ -8,6 +8,10 @@ inputs:
|
||||
description: 'Build configuration'
|
||||
required: false
|
||||
default: 'RelWithDebInfo'
|
||||
cublas:
|
||||
description: 'Enable cuBLAS'
|
||||
required: false
|
||||
default: 'cpu'
|
||||
codesign:
|
||||
description: 'Enable codesigning (macOS only)'
|
||||
required: false
|
||||
@ -78,6 +82,7 @@ runs:
|
||||
$BuildArgs = @{
|
||||
Target = '${{ inputs.target }}'
|
||||
Configuration = '${{ inputs.config }}'
|
||||
Cublas = '${{ inputs.cublas }}'
|
||||
}
|
||||
|
||||
.github/scripts/Build-Windows.ps1 @BuildArgs
|
||||
|
5
.github/actions/package-plugin/action.yaml
vendored
5
.github/actions/package-plugin/action.yaml
vendored
@ -8,6 +8,10 @@ inputs:
|
||||
description: 'Build configuration'
|
||||
required: false
|
||||
default: 'RelWithDebInfo'
|
||||
cublas:
|
||||
description: 'Enable cuBLAS'
|
||||
required: false
|
||||
default: 'cpu'
|
||||
codesign:
|
||||
description: 'Enable codesigning (macOS only)'
|
||||
required: false
|
||||
@ -108,6 +112,7 @@ runs:
|
||||
$PackageArgs = @{
|
||||
Target = '${{ inputs.target }}'
|
||||
Configuration = '${{ inputs.config }}'
|
||||
Cublas = '${{ inputs.cublas }}'
|
||||
}
|
||||
|
||||
if ( '${{ inputs.package }}' -eq 'true' ) {
|
||||
|
10
.github/scripts/.build.zsh
vendored
10
.github/scripts/.build.zsh
vendored
@ -230,7 +230,15 @@ ${_usage_host:-}"
|
||||
-DCODESIGN_IDENTITY=${CODESIGN_IDENT:--}
|
||||
)
|
||||
|
||||
cmake_build_args+=(--preset ${_preset} --parallel --config ${config} -- ONLY_ACTIVE_ARCH=NO -arch arm64 -arch x86_64)
|
||||
cmake_build_args+=(--preset ${_preset} --parallel --config ${config} -- ONLY_ACTIVE_ARCH=YES)
|
||||
# check the MACOS_ARCH env var to determine the build architecture
|
||||
if [[ -n ${MACOS_ARCH} ]] {
|
||||
cmake_build_args+=(-arch ${MACOS_ARCH})
|
||||
} else {
|
||||
# error out
|
||||
log_error "No MACOS_ARCH environment variable set. Please set it to the desired architecture."
|
||||
exit 2
|
||||
}
|
||||
cmake_install_args+=(build_macos --config ${config} --prefix "${project_root}/release/${config}")
|
||||
|
||||
local -a xcbeautify_opts=()
|
||||
|
4
.github/scripts/.package.zsh
vendored
4
.github/scripts/.package.zsh
vendored
@ -168,8 +168,10 @@ ${_usage_host:-}"
|
||||
|
||||
if [[ ${host_os} == macos ]] {
|
||||
autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass
|
||||
# get the arch from MACOS_ARCH env var
|
||||
local -r macos_arch=${MACOS_ARCH:-$(uname -m)}
|
||||
|
||||
local output_name="${product_name}-${product_version}-${host_os}-universal"
|
||||
local output_name="${product_name}-${product_version}-${host_os}-${macos_arch}"
|
||||
|
||||
if [[ ! -d ${project_root}/release/${config}/${product_name}.plugin ]] {
|
||||
log_error 'No release artifact found. Run the build script or the CMake install procedure first.'
|
||||
|
9
.github/scripts/Build-Windows.ps1
vendored
9
.github/scripts/Build-Windows.ps1
vendored
@ -4,6 +4,8 @@ param(
|
||||
[string] $Target = 'x64',
|
||||
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
||||
[string] $Configuration = 'RelWithDebInfo',
|
||||
[ValidateSet('cpu', '12.2.0', '11.8.0')]
|
||||
[string] $Cublas = 'cpu',
|
||||
[switch] $SkipAll,
|
||||
[switch] $SkipBuild,
|
||||
[switch] $SkipDeps,
|
||||
@ -77,6 +79,13 @@ function Build {
|
||||
'--preset', $Preset
|
||||
)
|
||||
|
||||
if ( $Cublas -ne 'cpu' ) {
|
||||
$CmakeArgs += @(
|
||||
'-DLOCALVOCAL_WITH_CUDA=ON',
|
||||
"-DCUDA_TOOLKIT_ROOT_DIR=$Env:CUDA_TOOLKIT_ROOT_DIR"
|
||||
)
|
||||
}
|
||||
|
||||
$CmakeBuildArgs += @(
|
||||
'--build'
|
||||
'--preset', $Preset
|
||||
|
5
.github/scripts/Package-Windows.ps1
vendored
5
.github/scripts/Package-Windows.ps1
vendored
@ -4,6 +4,8 @@ param(
|
||||
[string] $Target = 'x64',
|
||||
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
||||
[string] $Configuration = 'RelWithDebInfo',
|
||||
[ValidateSet('cpu', '12.2.0', '11.8.0')]
|
||||
[string] $Cublas = 'cpu',
|
||||
[switch] $BuildInstaller,
|
||||
[switch] $SkipDeps
|
||||
)
|
||||
@ -47,8 +49,9 @@ function Package {
|
||||
$BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
|
||||
$ProductName = $BuildSpec.name
|
||||
$ProductVersion = $BuildSpec.version
|
||||
$CudaName = "cuda${Cublas}"
|
||||
|
||||
$OutputName = "${ProductName}-${ProductVersion}-windows-${Target}"
|
||||
$OutputName = "${ProductName}-${ProductVersion}-windows-${Target}-${CudaName}"
|
||||
|
||||
if ( ! $SkipDeps ) {
|
||||
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
|
||||
|
40
.github/workflows/build-project.yaml
vendored
40
.github/workflows/build-project.yaml
vendored
@ -60,6 +60,9 @@ jobs:
|
||||
name: Build for macOS 🍏
|
||||
runs-on: macos-13
|
||||
needs: check-event
|
||||
strategy:
|
||||
matrix:
|
||||
architecture: [x86_64, arm64]
|
||||
defaults:
|
||||
run:
|
||||
shell: zsh --no-rcs --errexit --pipefail {0}
|
||||
@ -114,15 +117,17 @@ jobs:
|
||||
- name: Build Plugin 🧱
|
||||
uses: ./.github/actions/build-plugin
|
||||
with:
|
||||
target: macos-universal
|
||||
target: macos-${{ matrix.architecture }}
|
||||
config: ${{ needs.check-event.outputs.config }}
|
||||
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
|
||||
codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
|
||||
env:
|
||||
MACOS_ARCH: ${{ matrix.architecture }}
|
||||
|
||||
- name: Package Plugin 📀
|
||||
uses: ./.github/actions/package-plugin
|
||||
with:
|
||||
target: macos-universal
|
||||
target: macos-${{ matrix.architecture }}
|
||||
config: ${{ needs.check-event.outputs.config }}
|
||||
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
||||
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
|
||||
@ -132,19 +137,21 @@ jobs:
|
||||
notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
|
||||
codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
|
||||
codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
|
||||
env:
|
||||
MACOS_ARCH: ${{ matrix.architecture }}
|
||||
|
||||
- name: Upload Artifacts 📡
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal.*
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}.*
|
||||
|
||||
- name: Upload Debug Symbol Artifacts 🪲
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ needs.check-event.outputs.config == 'Release' }}
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-dSYMs.*
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-${{ needs.check-event.outputs.commitHash }}-dSYMs
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-dSYMs.*
|
||||
|
||||
ubuntu-build:
|
||||
name: Build for Ubuntu 🐧
|
||||
@ -218,6 +225,9 @@ jobs:
|
||||
name: Build for Windows 🪟
|
||||
runs-on: windows-2022
|
||||
needs: check-event
|
||||
strategy:
|
||||
matrix:
|
||||
cublas: [cpu, 12.2.0, 11.8.0]
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
@ -227,6 +237,20 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install CUDA Toolkit
|
||||
if: ${{ matrix.cublas != 'cpu' }}
|
||||
id: cuda-toolkit
|
||||
uses: Jimver/cuda-toolkit@v0.2.11
|
||||
with:
|
||||
cuda: '${{ matrix.cublas }}'
|
||||
|
||||
- name: Set CUDA_TOOLKIT_ROOT_DIR if CUDA is installed
|
||||
if: ${{ matrix.cublas != 'cpu' }}
|
||||
run: |
|
||||
ls "$env:CUDA_PATH\bin"
|
||||
ls -d 2 "$env:CUDA_PATH\lib"
|
||||
"CUDA_TOOLKIT_ROOT_DIR=$env:CUDA_PATH" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Set Up Environment 🔧
|
||||
id: setup
|
||||
run: |
|
||||
@ -247,6 +271,7 @@ jobs:
|
||||
with:
|
||||
target: x64
|
||||
config: ${{ needs.check-event.outputs.config }}
|
||||
cublas: ${{ matrix.cublas }}
|
||||
|
||||
- name: Package Plugin 📀
|
||||
uses: ./.github/actions/package-plugin
|
||||
@ -254,9 +279,10 @@ jobs:
|
||||
target: x64
|
||||
config: ${{ needs.check-event.outputs.config }}
|
||||
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
||||
cublas: ${{ matrix.cublas }}
|
||||
|
||||
- name: Upload Artifacts 📡
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
|
||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ matrix.cublas }}-${{ needs.check-event.outputs.commitHash }}
|
||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64*.*
|
||||
|
@ -17,8 +17,20 @@ if(UNIX AND NOT APPLE)
|
||||
-DWHISPER_NO_AVX2=ON)
|
||||
endif()
|
||||
if(APPLE)
|
||||
# disable Metal on MacOS as it hurts performance right now
|
||||
set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_METAL=OFF)
|
||||
# check the "MACOS_ARCH" env var to figure out if this is x86 or arm64
|
||||
if(NOT DEFINED ENV{MACOS_ARCH})
|
||||
message(FATAL_ERROR "The MACOS_ARCH environment variable is not set. Please set it to either `x86` or `arm64`")
|
||||
endif(NOT DEFINED ENV{MACOS_ARCH})
|
||||
set(CMAKE_OSX_ARCHITECTURES_ "$ENV{MACOS_ARCH}")
|
||||
if($ENV{MACOS_ARCH} STREQUAL "x86_64")
|
||||
set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_METAL=OFF -DWHISPER_COREML=OFF -DWHISPER_NO_AVX=OFF
|
||||
-DWHISPER_NO_AVX2=OFF -DWHISPER_NO_F16C=OFF)
|
||||
else()
|
||||
set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_METAL=OFF -DWHISPER_COREML=OFF -DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON
|
||||
-DWHISPER_NO_F16C=ON -DWHISPER_NO_FMA=ON)
|
||||
endif()
|
||||
set(WHISPER_EXTRA_CXX_FLAGS
|
||||
"-Wno-shorten-64-to-32 -Wno-unused-parameter -Wno-unused-function -Wno-unguarded-availability-new")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
|
Loading…
Reference in New Issue
Block a user