From 673d701ea471daebecb1fb0c1edf79a2017a78ac Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 16 Nov 2024 15:04:13 -0800 Subject: Add support for whisper large v3 turbo Also: * Double # of audio device slots * Fetch CuDNN from NVIDIA at runtime instead of vendoring --- GUI/GUI/GUI/Frame.cpp | 166 ++++++++++++++++++++++++++++++++++++++++---------- GUI/package.ps1 | 34 ----------- 2 files changed, 133 insertions(+), 67 deletions(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index 77447bc..0782376 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -136,6 +136,16 @@ namespace { "7", "8", "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17", + "18", + "19", }; const size_t kNumMicChoices = sizeof(kMicChoices) / sizeof(kMicChoices[0]); constexpr int kMicDefault = 0; // index @@ -472,6 +482,7 @@ namespace { "large-v2", "distil-large-v3", "large-v3", + "large-v3-turbo", }; const size_t kNumModelChoices = sizeof(kModelChoices) / sizeof(kModelChoices[0]); constexpr int kModelDefault = 2; // base.en @@ -1855,6 +1866,27 @@ void Frame::OnNavbarDebug(wxCommandEvent& event) Resize(); } +bool FindDirectoryByPrefix(wxTextCtrl* out, const std::string& prefix, std::filesystem::path& path) { + std::error_code ec; + // Find directory starting with "cudnn" + for (const auto& entry : + std::filesystem::directory_iterator(".", ec)) { + if (ec) { + Log(out, "Failed to iterate cwd: {}\n", + ec.message()); + return false; + } + + if (entry.is_directory(ec) && + !ec && + entry.path().filename().string().starts_with(prefix)) { + path = entry.path(); + return true; + } + } + return false; +} + void Frame::EnsureVirtualEnv(bool block, bool force) { auto status = env_proc_.wait_for(std::chrono::seconds(0)); @@ -1886,48 +1918,116 @@ void Frame::EnsureVirtualEnv(bool block, bool force) return; } - env_proc_ = std::move(std::async(std::launch::async, [&]() { - Log(transcribe_out_, "Setting up Python virtual environment\n"); - Log(transcribe_out_, "This could take several minutes, please be " - "patient!\n"); - Log(transcribe_out_, "This will download ~1GB of dependencies.\n"); - - { - Log(transcribe_out_, " Installing pip\n"); - auto out_cb = [&](const std::string& out, const std::string& err) { - Log(transcribe_out_, "{}", out); - Log(transcribe_out_, "{}", err); - }; - if (!PythonWrapper::InstallPip(std::move(out_cb))) { - Log(transcribe_out_, "Failed to install pip!\n"); - return false; - } - } + env_proc_ = std::move(std::async(std::launch::async, [&]() { + Log(transcribe_out_, "Setting up Python virtual environment\n"); + Log(transcribe_out_, "This could take several minutes, please be " + "patient!\n"); + Log(transcribe_out_, "This will download ~1GB of dependencies.\n"); - Log(transcribe_out_, " Installing dependencies\n"); + { + Log(transcribe_out_, " Installing pip\n"); auto out_cb = [&](const std::string& out, const std::string& err) { Log(transcribe_out_, "{}", out); Log(transcribe_out_, "{}", err); }; - if (!PythonWrapper::InvokeWithArgs(*app_c_, - { - "-u", // Unbuffered output - "-m pip", - "install", - "-r Resources/Scripts/requirements_frozen.txt", - }, std::move(out_cb))) { - Log(transcribe_out_, "Failed to launch environment setup thread!\n"); + if (!PythonWrapper::InstallPip(std::move(out_cb))) { + Log(transcribe_out_, "Failed to install pip!\n"); return false; } - Log(transcribe_out_, "Successfully set up virtual environment!\n"); + } - std::ofstream venv_flag_ofs(venv_flag); - auto now = std::chrono::system_clock::now(); - const int64_t seconds_since_epoch = std::chrono::duration_cast(now.time_since_epoch()).count(); - venv_flag_ofs << std::to_string(seconds_since_epoch); + Log(transcribe_out_, " Installing python dependencies\n"); + auto out_cb = [&](const std::string& out, const std::string& err) { + Log(transcribe_out_, "{}", out); + Log(transcribe_out_, "{}", err); + }; + if (!PythonWrapper::InvokeWithArgs(*app_c_, + { + "-u", // Unbuffered output + "-m pip", + "install", + "-r Resources/Scripts/requirements_frozen.txt", + }, out_cb)) { + Log(transcribe_out_, "Failed to launch environment setup thread!\n"); + return false; + } - return true; - })); + Log(transcribe_out_, " Fetching CuDNN\n"); + if (!PythonWrapper::InvokeWithArgs(*app_c_, + { + "-m wget", + "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/windows-x86_64/cudnn-windows-x86_64-9.5.1.17_cuda12-archive.zip" + }, out_cb)) { + } + Log(transcribe_out_, " Unzipping CuDNN\n"); + if (!PythonWrapper::InvokeWithArgs(*app_c_, + { + "-m zipfile -e", + "cudnn-windows-x86_64-9.5.1.17_cuda12-archive.zip", + "." + }, out_cb)) { + } + Log(transcribe_out_, " Installing CuDNN\n"); + { + std::filesystem::path cudnn_dir; + if (!FindDirectoryByPrefix(transcribe_out_, "cudnn", cudnn_dir)) { + Log(transcribe_out_, "Failed to find unzipped cudnn " + "directory\n"); + return false; + } + std::error_code ec; + const std::filesystem::path dest_dir = "Resources/Scripts"; + for (const auto& entry : + std::filesystem::recursive_directory_iterator(cudnn_dir, ec)) { + if (ec) { + Log(transcribe_out_, "Failed to iterate cudnn dir: {}\n", + ec.message()); + return false; + } + if (!entry.is_regular_file(ec)) { + continue; + } + if (ec) { + Log(transcribe_out_, "Skipping unrecognized file type " + "{}: {}\n", entry.path().string(), ec.message()); + continue; + } + if (entry.path().extension() != ".dll") { + continue; + } + std::filesystem::path dest = + dest_dir / entry.path().filename(); + // Remove destination + std::filesystem::remove(dest, ec); + if (ec) { + Log(transcribe_out_, "Failed to delete old CuDNN .dll: {}\n", + ec.message()); + return false; + } + // Rename file + std::filesystem::rename(entry.path(), dest, ec); + if (ec) { + Log(transcribe_out_, "Failed to move CuDNN .dll: {}\n", + ec.message()); + } + } + // Delete cudnn dir + std::filesystem::remove_all(cudnn_dir, ec); + if (ec) { + Log(transcribe_out_, "Failed to remove old CuDNN dir: {}\n", + ec.message()); + } + } + + Log(transcribe_out_, "Successfully set up virtual environment!\n"); + + std::ofstream venv_flag_ofs(venv_flag); + auto now = std::chrono::system_clock::now(); + const int64_t seconds_since_epoch = std::chrono::duration_cast(now.time_since_epoch()).count(); + venv_flag_ofs << std::to_string(seconds_since_epoch); + + return true; + })); if (block) { // Spinning prevents the GUI from hanging. diff --git a/GUI/package.ps1 b/GUI/package.ps1 index 9b1c05b..697f1a2 100644 --- a/GUI/package.ps1 +++ b/GUI/package.ps1 @@ -85,39 +85,6 @@ if (-Not (Test-Path $git_dir)) { Read-Host -Prompt "Press enter once PortableGit is installed at $pwd\PortableGit" } -$nvidia_dir = "nvidia_dll" - -if (-Not (Test-Path $nvidia_dir)) { - echo "Fetching CUDNN dependencies" - - mkdir $nvidia_dir - pushd $nvidia_dir > $null - - $ZLIB_URL = "https://drive.google.com/uc?export=download&id=1NpWU83JVOWG0tJtFK7ObygTbOasGWZpI" - Invoke-WebRequest $ZLIB_URL -OutFile "zlibwapi.dll" - - # NVIDIA locks these files behind a fucking login making it a massive - # pain in the dick for end users to download, so I rehosted them. - # TODO check hashes. - echo "Fetching NVIDIA dll 1/4 (90 MB)" - $CUDNN_1_URL = "https://www.dropbox.com/scl/fi/d21dsoa982ce7wigng510/cudnn_ops_infer64_8.dll?rlkey=xflxyux0ekhr0fs11m4gs58md&st=0wff5fyn&dl=1" - Invoke-WebRequest $CUDNN_1_URL -OutFile "cudnn_ops_infer64_8.dll" - - echo "Fetching NVIDIA dll 2/4 (570 MB)" - $CUDNN_2_URL = "https://www.dropbox.com/scl/fi/uqccevwk9h2q84dt9vr6u/cudnn_cnn_infer64_8.dll?rlkey=sik7xd0ozg06nr4eayzdym4la&st=031bb8pa&dl=1" - Invoke-WebRequest $CUDNN_2_URL -OutFile "cudnn_cnn_infer64_8.dll" - - echo "Fetching NVIDIA dll 3/4 (470 MB)" - $CUBLAS_1_URL = "https://www.dropbox.com/scl/fi/3vrd4fzwno8q5ejigqz6l/cublasLt64_12.dll?rlkey=uvbdn5e7dmm8ajdhm7yztjmhc&st=dguf57q4&dl=1" - Invoke-WebRequest $CUBLAS_1_URL -OutFile "cublasLt64_12.dll" - - echo "Fetching NVIDIA dll 4/4 (100 MB)" - $CUBLAS_2_URL = "https://www.dropbox.com/scl/fi/hoxjdru7qmwbzelw1gr2t/cublas64_12.dll?rlkey=mcmq5t0b62wjc2uc7ylrixwi6&st=z1la337w&dl=1" - Invoke-WebRequest $CUBLAS_2_URL -OutFile "cublas64_12.dll" - - popd > $null -} - if (-Not (Test-Path UwwwuPP)) { git clone https://github.com/yum-food/UwwwuPP pushd UwwwuPP > $null @@ -162,7 +129,6 @@ cp -Recurse ../Fonts/Emotes TaSTT/Resources/Fonts/Emotes cp -Recurse Python TaSTT/Resources/Python cp -Recurse PortableGit TaSTT/Resources/PortableGit cp -Recurse ../Scripts TaSTT/Resources/Scripts -cp $nvidia_dir/*.dll TaSTT/Resources/Scripts/ mkdir TaSTT/Resources/Images cp ../Images/logo*.png TaSTT/Resources/Images/ cp -Recurse ../Shaders TaSTT/Resources/Shaders -- cgit v1.2.3