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'
|
description: 'Build configuration'
|
||||||
required: false
|
required: false
|
||||||
default: 'RelWithDebInfo'
|
default: 'RelWithDebInfo'
|
||||||
|
cublas:
|
||||||
|
description: 'Enable cuBLAS'
|
||||||
|
required: false
|
||||||
|
default: 'cpu'
|
||||||
codesign:
|
codesign:
|
||||||
description: 'Enable codesigning (macOS only)'
|
description: 'Enable codesigning (macOS only)'
|
||||||
required: false
|
required: false
|
||||||
@ -78,6 +82,7 @@ runs:
|
|||||||
$BuildArgs = @{
|
$BuildArgs = @{
|
||||||
Target = '${{ inputs.target }}'
|
Target = '${{ inputs.target }}'
|
||||||
Configuration = '${{ inputs.config }}'
|
Configuration = '${{ inputs.config }}'
|
||||||
|
Cublas = '${{ inputs.cublas }}'
|
||||||
}
|
}
|
||||||
|
|
||||||
.github/scripts/Build-Windows.ps1 @BuildArgs
|
.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'
|
description: 'Build configuration'
|
||||||
required: false
|
required: false
|
||||||
default: 'RelWithDebInfo'
|
default: 'RelWithDebInfo'
|
||||||
|
cublas:
|
||||||
|
description: 'Enable cuBLAS'
|
||||||
|
required: false
|
||||||
|
default: 'cpu'
|
||||||
codesign:
|
codesign:
|
||||||
description: 'Enable codesigning (macOS only)'
|
description: 'Enable codesigning (macOS only)'
|
||||||
required: false
|
required: false
|
||||||
@ -108,6 +112,7 @@ runs:
|
|||||||
$PackageArgs = @{
|
$PackageArgs = @{
|
||||||
Target = '${{ inputs.target }}'
|
Target = '${{ inputs.target }}'
|
||||||
Configuration = '${{ inputs.config }}'
|
Configuration = '${{ inputs.config }}'
|
||||||
|
Cublas = '${{ inputs.cublas }}'
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( '${{ inputs.package }}' -eq 'true' ) {
|
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:--}
|
-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}")
|
cmake_install_args+=(build_macos --config ${config} --prefix "${project_root}/release/${config}")
|
||||||
|
|
||||||
local -a xcbeautify_opts=()
|
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 ]] {
|
if [[ ${host_os} == macos ]] {
|
||||||
autoload -Uz check_packages read_codesign read_codesign_installer read_codesign_pass
|
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 ]] {
|
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.'
|
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',
|
[string] $Target = 'x64',
|
||||||
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
||||||
[string] $Configuration = 'RelWithDebInfo',
|
[string] $Configuration = 'RelWithDebInfo',
|
||||||
|
[ValidateSet('cpu', '12.2.0', '11.8.0')]
|
||||||
|
[string] $Cublas = 'cpu',
|
||||||
[switch] $SkipAll,
|
[switch] $SkipAll,
|
||||||
[switch] $SkipBuild,
|
[switch] $SkipBuild,
|
||||||
[switch] $SkipDeps,
|
[switch] $SkipDeps,
|
||||||
@ -77,6 +79,13 @@ function Build {
|
|||||||
'--preset', $Preset
|
'--preset', $Preset
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ( $Cublas -ne 'cpu' ) {
|
||||||
|
$CmakeArgs += @(
|
||||||
|
'-DLOCALVOCAL_WITH_CUDA=ON',
|
||||||
|
"-DCUDA_TOOLKIT_ROOT_DIR=$Env:CUDA_TOOLKIT_ROOT_DIR"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
$CmakeBuildArgs += @(
|
$CmakeBuildArgs += @(
|
||||||
'--build'
|
'--build'
|
||||||
'--preset', $Preset
|
'--preset', $Preset
|
||||||
|
5
.github/scripts/Package-Windows.ps1
vendored
5
.github/scripts/Package-Windows.ps1
vendored
@ -4,6 +4,8 @@ param(
|
|||||||
[string] $Target = 'x64',
|
[string] $Target = 'x64',
|
||||||
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
[ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')]
|
||||||
[string] $Configuration = 'RelWithDebInfo',
|
[string] $Configuration = 'RelWithDebInfo',
|
||||||
|
[ValidateSet('cpu', '12.2.0', '11.8.0')]
|
||||||
|
[string] $Cublas = 'cpu',
|
||||||
[switch] $BuildInstaller,
|
[switch] $BuildInstaller,
|
||||||
[switch] $SkipDeps
|
[switch] $SkipDeps
|
||||||
)
|
)
|
||||||
@ -47,8 +49,9 @@ function Package {
|
|||||||
$BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
|
$BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json
|
||||||
$ProductName = $BuildSpec.name
|
$ProductName = $BuildSpec.name
|
||||||
$ProductVersion = $BuildSpec.version
|
$ProductVersion = $BuildSpec.version
|
||||||
|
$CudaName = "cuda${Cublas}"
|
||||||
|
|
||||||
$OutputName = "${ProductName}-${ProductVersion}-windows-${Target}"
|
$OutputName = "${ProductName}-${ProductVersion}-windows-${Target}-${CudaName}"
|
||||||
|
|
||||||
if ( ! $SkipDeps ) {
|
if ( ! $SkipDeps ) {
|
||||||
Install-BuildDependencies -WingetFile "${ScriptHome}/.Wingetfile"
|
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 🍏
|
name: Build for macOS 🍏
|
||||||
runs-on: macos-13
|
runs-on: macos-13
|
||||||
needs: check-event
|
needs: check-event
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
architecture: [x86_64, arm64]
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: zsh --no-rcs --errexit --pipefail {0}
|
shell: zsh --no-rcs --errexit --pipefail {0}
|
||||||
@ -114,15 +117,17 @@ jobs:
|
|||||||
- name: Build Plugin 🧱
|
- name: Build Plugin 🧱
|
||||||
uses: ./.github/actions/build-plugin
|
uses: ./.github/actions/build-plugin
|
||||||
with:
|
with:
|
||||||
target: macos-universal
|
target: macos-${{ matrix.architecture }}
|
||||||
config: ${{ needs.check-event.outputs.config }}
|
config: ${{ needs.check-event.outputs.config }}
|
||||||
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
|
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
|
||||||
codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
|
codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
|
||||||
|
env:
|
||||||
|
MACOS_ARCH: ${{ matrix.architecture }}
|
||||||
|
|
||||||
- name: Package Plugin 📀
|
- name: Package Plugin 📀
|
||||||
uses: ./.github/actions/package-plugin
|
uses: ./.github/actions/package-plugin
|
||||||
with:
|
with:
|
||||||
target: macos-universal
|
target: macos-${{ matrix.architecture }}
|
||||||
config: ${{ needs.check-event.outputs.config }}
|
config: ${{ needs.check-event.outputs.config }}
|
||||||
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
||||||
codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
|
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) }}
|
notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
|
||||||
codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
|
codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
|
||||||
codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
|
codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
|
||||||
|
env:
|
||||||
|
MACOS_ARCH: ${{ matrix.architecture }}
|
||||||
|
|
||||||
- name: Upload Artifacts 📡
|
- name: Upload Artifacts 📡
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
|
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-universal.*
|
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}.*
|
||||||
|
|
||||||
- name: Upload Debug Symbol Artifacts 🪲
|
- name: Upload Debug Symbol Artifacts 🪲
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
if: ${{ needs.check-event.outputs.config == 'Release' }}
|
if: ${{ needs.check-event.outputs.config == 'Release' }}
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-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-universal-dSYMs.*
|
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-${{ matrix.architecture }}-dSYMs.*
|
||||||
|
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
name: Build for Ubuntu 🐧
|
name: Build for Ubuntu 🐧
|
||||||
@ -218,6 +225,9 @@ jobs:
|
|||||||
name: Build for Windows 🪟
|
name: Build for Windows 🪟
|
||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
needs: check-event
|
needs: check-event
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
cublas: [cpu, 12.2.0, 11.8.0]
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
@ -227,6 +237,20 @@ jobs:
|
|||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
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 🔧
|
- name: Set Up Environment 🔧
|
||||||
id: setup
|
id: setup
|
||||||
run: |
|
run: |
|
||||||
@ -247,6 +271,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
target: x64
|
target: x64
|
||||||
config: ${{ needs.check-event.outputs.config }}
|
config: ${{ needs.check-event.outputs.config }}
|
||||||
|
cublas: ${{ matrix.cublas }}
|
||||||
|
|
||||||
- name: Package Plugin 📀
|
- name: Package Plugin 📀
|
||||||
uses: ./.github/actions/package-plugin
|
uses: ./.github/actions/package-plugin
|
||||||
@ -254,9 +279,10 @@ jobs:
|
|||||||
target: x64
|
target: x64
|
||||||
config: ${{ needs.check-event.outputs.config }}
|
config: ${{ needs.check-event.outputs.config }}
|
||||||
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
package: ${{ fromJSON(needs.check-event.outputs.package) }}
|
||||||
|
cublas: ${{ matrix.cublas }}
|
||||||
|
|
||||||
- name: Upload Artifacts 📡
|
- name: Upload Artifacts 📡
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
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*.*
|
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)
|
-DWHISPER_NO_AVX2=ON)
|
||||||
endif()
|
endif()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# disable Metal on MacOS as it hurts performance right now
|
# check the "MACOS_ARCH" env var to figure out if this is x86 or arm64
|
||||||
set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_METAL=OFF)
|
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()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
Loading…
Reference in New Issue
Block a user