diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a12ff8..7a17583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.2.2 (pre-release) +- Fixed `[WinError 1114] A dynamic link library (DLL) initialization routine failed` error on Windows, pre-loading PyTorch DLLs before initializing PyQt6 to avoid DLL initialization errors, mentioned in #98 by @ephr0n. +- Potential fix for `CUDA GPU is not available` issue, by ensuring PyTorch is installed correctly with CUDA support on Windows using the installer script. + # 1.2.1 - Upgraded Abogen's interface from PyQt5 to PyQt6 for better compatibility and long-term support. - Added tooltip indicators in queue manager to display book handler options (`Save chapters separately` and `Merge chapters at the end`) for queued items. diff --git a/README.md b/README.md index 00ca00f..191feeb 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ python -m venv venv venv\Scripts\activate # For NVIDIA GPUs: -pip install torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128 +pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu128 # For AMD GPUs: # Not supported yet, because ROCm is not available on Windows. Use Linux if you have AMD GPU. diff --git a/WINDOWS_INSTALL.bat b/WINDOWS_INSTALL.bat index 6cb1e6b..35af1ed 100644 --- a/WINDOWS_INSTALL.bat +++ b/WINDOWS_INSTALL.bat @@ -279,8 +279,7 @@ if /I "%IS_NVIDIA%"=="true" ( if "%cuda_available%"=="False" ( echo Installing PyTorch with CUDA (12.8) support... - :: Temporarily set the PyTorch version to 2.0.8 to prevent [WinError 1114] error. - %PYTHON_CONSOLE_PATH% -m pip install torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 --extra-index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location + %PYTHON_CONSOLE_PATH% -m pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location echo. if errorlevel 1 ( echo Failed to install PyTorch. @@ -304,8 +303,7 @@ if /I "%IS_NVIDIA%"=="true" ( echo Skipping PyTorch installation. ) else ( echo Installing PyTorch with CUDA (12.8) support... - :: Temporarily set the PyTorch version to 2.0.8 to prevent [WinError 1114] error. - %PYTHON_CONSOLE_PATH% -m pip install torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 --extra-index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location + %PYTHON_CONSOLE_PATH% -m pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location if errorlevel 1 ( echo Failed to install PyTorch. pause diff --git a/abogen/main.py b/abogen/main.py index 6495051..8c68453 100644 --- a/abogen/main.py +++ b/abogen/main.py @@ -4,6 +4,24 @@ import platform import atexit import signal +# Fix PyTorch DLL loading issue on Windows before importing PyQt6 +if platform.system() == "Windows": + import ctypes + import site + + for site_path in site.getsitepackages(): + torch_lib_path = os.path.join(site_path, "torch", "lib") + if os.path.exists(torch_lib_path): + # Pre-load torch DLLs before Qt can interfere + for dll in ['c10.dll', 'torch_cpu.dll', 'torch_python.dll']: + dll_path = os.path.join(torch_lib_path, dll) + if os.path.exists(dll_path): + try: + ctypes.CDLL(dll_path) + except Exception: + pass + break + # Qt platform plugin detection (fixes #59) try: from PyQt6.QtCore import QLibraryInfo diff --git a/abogen/utils.py b/abogen/utils.py index f93208e..51e2555 100644 --- a/abogen/utils.py +++ b/abogen/utils.py @@ -257,6 +257,12 @@ def calculate_text_length(text): def get_gpu_acceleration(enabled): + """ + Check GPU acceleration availability. + + Note: On Windows, torch DLLs must be pre-loaded in main.py before PyQt6 + to avoid DLL initialization errors. + """ try: import torch from torch.cuda import is_available as cuda_available