diff --git a/.github/actions/build-plugin/action.yaml b/.github/actions/build-plugin/action.yaml index ac5950d..75c8af7 100644 --- a/.github/actions/build-plugin/action.yaml +++ b/.github/actions/build-plugin/action.yaml @@ -82,7 +82,6 @@ runs: $BuildArgs = @{ Target = '${{ inputs.target }}' Configuration = '${{ inputs.config }}' - Cublas = '${{ inputs.cublas }}' } .github/scripts/Build-Windows.ps1 @BuildArgs diff --git a/.github/scripts/Build-Windows.ps1 b/.github/scripts/Build-Windows.ps1 index 875ea0a..2d4c4ca 100644 --- a/.github/scripts/Build-Windows.ps1 +++ b/.github/scripts/Build-Windows.ps1 @@ -4,8 +4,6 @@ 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, @@ -79,13 +77,6 @@ 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 diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index d554e05..cdb1a33 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -237,20 +237,6 @@ 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: | diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 3c6156a..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vendor/curl"] - path = vendor/curl - url = https://github.com/curl/curl.git diff --git a/cmake/BuildWhispercpp.cmake b/cmake/BuildWhispercpp.cmake index 354c09e..e54a75b 100644 --- a/cmake/BuildWhispercpp.cmake +++ b/cmake/BuildWhispercpp.cmake @@ -1,8 +1,5 @@ include(ExternalProject) - -set(CMAKE_OSX_ARCHITECTURES_ "arm64$x86_64") - -set(Whispercpp_Build_GIT_TAG "f22d27a385d34b1e544031efe8aa2e3d73922791") +include(FetchContent) if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo) set(Whispercpp_BUILD_TYPE Release) @@ -10,85 +7,103 @@ else() set(Whispercpp_BUILD_TYPE Debug) endif() -if(UNIX AND NOT APPLE) - # On linux add the `-fPIC` flag to the compiler - set(WHISPER_EXTRA_CXX_FLAGS "-fPIC") - set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_BLAS=OFF -DWHISPER_CUBLAS=OFF -DWHISPER_OPENBLAS=OFF -DWHISPER_NO_AVX=ON - -DWHISPER_NO_AVX2=ON) -endif() if(APPLE) # 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`") + message(FATAL_ERROR "The MACOS_ARCH environment variable is not set. Please set it to either `x86_64` or `arm64`") endif(NOT DEFINED ENV{MACOS_ARCH}) - set(CMAKE_OSX_ARCHITECTURES_ "$ENV{MACOS_ARCH}") + + set(WHISPER_CPP_URL + "https://github.com/occ-ai/occ-ai-dep-whispercpp/releases/download/0.0.1/whispercpp-macos-$ENV{MACOS_ARCH}-0.0.1.tar.gz" + ) 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) + set(WHISPER_CPP_HASH "36F39F02F999AAF157EAD3460DD00C8BDAA3D6C4A769A9E4F64E327871B4B11F") + elseif($ENV{MACOS_ARCH} STREQUAL "arm64") + set(WHISPER_CPP_HASH "6AF7BB904B03B6208B4281D44465B727FB608A32CABD1394B727937C5F4828A1") 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) + message( + FATAL_ERROR + "The MACOS_ARCH environment variable is not set to a valid value. Please set it to either `x86_64` or `arm64`") endif() - set(WHISPER_EXTRA_CXX_FLAGS - "-Wno-shorten-64-to-32 -Wno-unused-parameter -Wno-unused-function -Wno-unguarded-availability-new") -endif() -if(WIN32) - if(LOCALVOCAL_WITH_CUDA) - # Build with CUDA Check that CUDA_TOOLKIT_ROOT_DIR is set - if(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) - message(FATAL_ERROR "CUDA_TOOLKIT_ROOT_DIR is not set. Please set it to the root directory of your CUDA " - "installation, e.g. `C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4`") - endif(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) - - set(WHISPER_ADDITIONAL_ENV "CUDAToolkit_ROOT=${CUDA_TOOLKIT_ROOT_DIR}") - set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_BLAS=OFF -DWHISPER_CUBLAS=ON -DWHISPER_OPENBLAS=OFF - -DCMAKE_GENERATOR_TOOLSET=cuda=${CUDA_TOOLKIT_ROOT_DIR}) + FetchContent_Declare( + whispercpp_fetch + URL ${WHISPER_CPP_URL} + URL_HASH SHA256=${WHISPER_CPP_HASH}) + FetchContent_MakeAvailable(whispercpp_fetch) + + add_library(Whispercpp::Whisper STATIC IMPORTED) + set_target_properties( + Whispercpp::Whisper + PROPERTIES + IMPORTED_LOCATION + ${whispercpp_fetch_SOURCE_DIR}/lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) + set_target_properties(Whispercpp::Whisper PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + ${whispercpp_fetch_SOURCE_DIR}/include) + +elseif(WIN32) + if(NOT DEFINED ENV{CPU_OR_CUDA}) + message( + FATAL_ERROR + "The CPU_OR_CUDA environment variable is not set. Please set it to either `cpu` or `11.8.0` or `12.2.0`") + endif(NOT DEFINED ENV{CPU_OR_CUDA}) + + set(CUDA_PREFIX $ENV{CPU_OR_CUDA}) + if(NOT $ENV{CPU_OR_CUDA} STREQUAL "cpu") + set(CUDA_PREFIX "cuda$ENV{CPU_OR_CUDA}") + endif() + + set(WHISPER_CPP_URL + "https://github.com/occ-ai/occ-ai-dep-whispercpp/releases/download/0.0.1/whispercpp-windows-${CUDA_PREFIX}-0.0.1.zip" + ) + if($ENV{CPU_OR_CUDA} STREQUAL "cpu") + set(WHISPER_CPP_HASH "5261FCCD18BA52AE7ECD37617452F0514238FAB4B12713F1FCA491F4ABA170AA") + elseif($ENV{CPU_OR_CUDA} STREQUAL "12.2.0") + set(WHISPER_CPP_HASH "1966A6C7347FCB9529140F8097AED306F31C6DDE328836FD6498A980E20B8E6C") + elseif($ENV{CPU_OR_CUDA} STREQUAL "11.8.0") + set(WHISPER_CPP_HASH "172F4021E888A89A694373AE0888C04DB99BC11F3A2633270248E03AF5AC762E") else() - # Build with OpenBLAS - set(OpenBLAS_URL "https://github.com/xianyi/OpenBLAS/releases/download/v0.3.24/OpenBLAS-0.3.24-x64.zip") - set(OpenBLAS_SHA256 "6335128ee7117ea2dd2f5f96f76dafc17256c85992637189a2d5f6da0c608163") - ExternalProject_Add( - OpenBLAS - URL ${OpenBLAS_URL} - URL_HASH SHA256=${OpenBLAS_SHA256} - DOWNLOAD_NO_PROGRESS true - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ) - ExternalProject_Get_Property(OpenBLAS INSTALL_DIR) - set(OpenBLAS_DIR ${INSTALL_DIR}) - set(WHISPER_ADDITIONAL_ENV "OPENBLAS_PATH=${OpenBLAS_DIR}") - set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_BLAS=ON -DWHISPER_CUBLAS=OFF) + message( + FATAL_ERROR + "The CPU_OR_CUDA environment variable is not set to a valid value. Please set it to either `cpu` or `11.8.0` or `12.2.0`" + ) endif() - ExternalProject_Add( - Whispercpp_Build - DOWNLOAD_EXTRACT_TIMESTAMP true - GIT_REPOSITORY https://github.com/ggerganov/whisper.cpp.git - GIT_TAG ${Whispercpp_Build_GIT_TAG} - BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${Whispercpp_BUILD_TYPE} - BUILD_BYPRODUCTS - /lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX} - /bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX} - /lib/${CMAKE_IMPORT_LIBRARY_PREFIX}whisper${CMAKE_IMPORT_LIBRARY_SUFFIX} - CMAKE_GENERATOR ${CMAKE_GENERATOR} - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config ${Whispercpp_BUILD_TYPE} && ${CMAKE_COMMAND} -E copy - /${Whispercpp_BUILD_TYPE}/whisper.lib /lib && ${CMAKE_COMMAND} -E copy - /ggml.h /include - CONFIGURE_COMMAND - ${CMAKE_COMMAND} -E env ${WHISPER_ADDITIONAL_ENV} ${CMAKE_COMMAND} -B -G - ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=${Whispercpp_BUILD_TYPE} - -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 - -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} - -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DBUILD_SHARED_LIBS=ON -DWHISPER_BUILD_TESTS=OFF - -DWHISPER_BUILD_EXAMPLES=OFF ${WHISPER_ADDITIONAL_CMAKE_ARGS}) + FetchContent_Declare( + whispercpp_fetch + URL ${WHISPER_CPP_URL} + URL_HASH SHA256=${WHISPER_CPP_HASH}) + FetchContent_MakeAvailable(whispercpp_fetch) + + add_library(Whispercpp::Whisper SHARED IMPORTED) + set_target_properties( + Whispercpp::Whisper + PROPERTIES IMPORTED_LOCATION + ${whispercpp_fetch_SOURCE_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX}) + set_target_properties( + Whispercpp::Whisper + PROPERTIES IMPORTED_IMPLIB + ${whispercpp_fetch_SOURCE_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) + set_target_properties(Whispercpp::Whisper PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + ${whispercpp_fetch_SOURCE_DIR}/include) + + if($ENV{CPU_OR_CUDA} STREQUAL "cpu") + # add openblas to the link line + add_library(Whispercpp::OpenBLAS STATIC IMPORTED) + set_target_properties(Whispercpp::OpenBLAS PROPERTIES IMPORTED_LOCATION + ${whispercpp_fetch_SOURCE_DIR}/lib/libopenblas.dll.a) + endif() + + # glob all dlls in the bin directory and install them + file(GLOB WHISPER_DLLS ${whispercpp_fetch_SOURCE_DIR}/bin/*.dll) + install(FILES ${WHISPER_DLLS} DESTINATION "obs-plugins/64bit") - if(NOT LOCALVOCAL_WITH_CUDA) - add_dependencies(Whispercpp_Build OpenBLAS) - endif(NOT LOCALVOCAL_WITH_CUDA) else() + set(Whispercpp_Build_GIT_TAG "f22d27a385d34b1e544031efe8aa2e3d73922791") + set(WHISPER_EXTRA_CXX_FLAGS "-fPIC") + set(WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_BLAS=OFF -DWHISPER_CUBLAS=OFF -DWHISPER_OPENBLAS=OFF -DWHISPER_NO_AVX=ON + -DWHISPER_NO_AVX2=ON) + # On Linux and MacOS build a static Whisper library ExternalProject_Add( Whispercpp_Build @@ -107,62 +122,24 @@ else() -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DBUILD_SHARED_LIBS=OFF -DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ${WHISPER_ADDITIONAL_CMAKE_ARGS}) -endif(WIN32) - -ExternalProject_Get_Property(Whispercpp_Build INSTALL_DIR) - -# add the Whisper library to the link line -if(WIN32) - add_library(Whispercpp::Whisper SHARED IMPORTED) - set_target_properties( - Whispercpp::Whisper - PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX}) - set_target_properties( - Whispercpp::Whisper - PROPERTIES IMPORTED_IMPLIB ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) - install(FILES ${INSTALL_DIR}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION "obs-plugins/64bit") + ExternalProject_Get_Property(Whispercpp_Build INSTALL_DIR) - if(NOT LOCALVOCAL_WITH_CUDA) - # add openblas to the link line - add_library(Whispercpp::OpenBLAS STATIC IMPORTED) - set_target_properties(Whispercpp::OpenBLAS PROPERTIES IMPORTED_LOCATION ${OpenBLAS_DIR}/lib/libopenblas.dll.a) - install(FILES ${OpenBLAS_DIR}/bin/libopenblas.dll DESTINATION "obs-plugins/64bit") - else(NOT LOCALVOCAL_WITH_CUDA) - # normalize CUDA path with file(TO_CMAKE_PATH) - file(TO_CMAKE_PATH ${CUDA_TOOLKIT_ROOT_DIR} CUDA_TOOLKIT_ROOT_DIR) - # find the CUDA DLLs for cuBLAS in the bin directory of the CUDA installation e.g. cublas64_NN.dll - file(GLOB CUBLAS_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublas64_*.dll") - # find cublasLt DLL, e.g. cublasLt64_11.dll - file(GLOB CUBLASLT_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublasLt64_*.dll") - # find cudart DLL, e.g. cudart64_110.dll - file(GLOB CUDART_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cudart64_*.dll") - # if any of the files cannot be found, abort - if(NOT CUBLAS_DLLS - OR NOT CUBLASLT_DLLS - OR NOT CUDART_DLLS) - message(FATAL_ERROR "Could not find cuBLAS, cuBLASLt or cuDART DLLs in ${CUDA_TOOLKIT_ROOT_DIR}/bin") - endif() - # copy the DLLs to the OBS plugin directory - install(FILES ${CUBLAS_DLLS} ${CUBLASLT_DLLS} ${CUDART_DLLS} DESTINATION "obs-plugins/64bit") - endif(NOT LOCALVOCAL_WITH_CUDA) -else() # on Linux and MacOS add the static Whisper library to the link line add_library(Whispercpp::Whisper STATIC IMPORTED) set_target_properties( Whispercpp::Whisper PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX}) -endif(WIN32) + set_target_properties(Whispercpp::Whisper PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) +endif() add_library(Whispercpp INTERFACE) add_dependencies(Whispercpp Whispercpp_Build) target_link_libraries(Whispercpp INTERFACE Whispercpp::Whisper) -if(WIN32 AND NOT LOCALVOCAL_WITH_CUDA) +if(WIN32 AND "$ENV{CPU_OR_CUDA}" STREQUAL "cpu") target_link_libraries(Whispercpp INTERFACE Whispercpp::OpenBLAS) endif() -set_target_properties(Whispercpp::Whisper PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) if(APPLE) target_link_libraries(Whispercpp INTERFACE "-framework Accelerate") endif(APPLE) diff --git a/cmake/common/buildspec_common.cmake b/cmake/common/buildspec_common.cmake index d0f43c7..b2c2414 100644 --- a/cmake/common/buildspec_common.cmake +++ b/cmake/common/buildspec_common.cmake @@ -73,13 +73,6 @@ function(_setup_obs_studio) set(_cmake_version "3.0.0") endif() - message(STATUS "Patch libobs") - execute_process( - COMMAND patch --forward "libobs/CMakeLists.txt" "${CMAKE_CURRENT_SOURCE_DIR}/patch_libobs.diff" - RESULT_VARIABLE _process_result - WORKING_DIRECTORY "${dependencies_dir}/${_obs_destination}") - message(STATUS "Patch - done") - message(STATUS "Configure ${label} (${arch})") execute_process( COMMAND diff --git a/vendor/curl b/vendor/curl deleted file mode 160000 index 98044e8..0000000 --- a/vendor/curl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 98044e81705dc24a56daaf3544f30c13f0fc3a31