Fixed [WinError 1114] A dynamic link library (DLL) initialization routine failed, Potential fix for CUDA GPU is not available

This commit is contained in:
Deniz Şafak
2025-10-30 12:52:46 +03:00
parent 4b175c7cf2
commit afbd5203fe
5 changed files with 31 additions and 5 deletions
+4
View File
@@ -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.
+1 -1
View File
@@ -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.
+2 -4
View File
@@ -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
+18
View File
@@ -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
+6
View File
@@ -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