Skip to content

Commit 7760db5

Browse files
committed
Fixed [WinError 1114] A dynamic link library (DLL) initialization routine failed, Potential fix for CUDA GPU is not available
1 parent 49f1827 commit 7760db5

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.2.2 (pre-release)
2+
- 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.
3+
- Potential fix for `CUDA GPU is not available` issue, by ensuring PyTorch is installed correctly with CUDA support on Windows using the installer script.
4+
15
# 1.2.1
26
- Upgraded Abogen's interface from PyQt5 to PyQt6 for better compatibility and long-term support.
37
- Added tooltip indicators in queue manager to display book handler options (`Save chapters separately` and `Merge chapters at the end`) for queued items.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ python -m venv venv
4242
venv\Scripts\activate
4343

4444
# For NVIDIA GPUs:
45-
pip install torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 --index-url https://download.pytorch.org/whl/cu128
45+
pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu128
4646

4747
# For AMD GPUs:
4848
# Not supported yet, because ROCm is not available on Windows. Use Linux if you have AMD GPU.

WINDOWS_INSTALL.bat

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ if /I "%IS_NVIDIA%"=="true" (
279279

280280
if "%cuda_available%"=="False" (
281281
echo Installing PyTorch with CUDA (12.8) support...
282-
:: Temporarily set the PyTorch version to 2.0.8 to prevent [WinError 1114] error.
283-
%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
282+
%PYTHON_CONSOLE_PATH% -m pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location
284283
echo.
285284
if errorlevel 1 (
286285
echo Failed to install PyTorch.
@@ -304,8 +303,7 @@ if /I "%IS_NVIDIA%"=="true" (
304303
echo Skipping PyTorch installation.
305304
) else (
306305
echo Installing PyTorch with CUDA (12.8) support...
307-
:: Temporarily set the PyTorch version to 2.0.8 to prevent [WinError 1114] error.
308-
%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
306+
%PYTHON_CONSOLE_PATH% -m pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu128 --no-warn-script-location
309307
if errorlevel 1 (
310308
echo Failed to install PyTorch.
311309
pause

abogen/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44
import atexit
55
import signal
66

7+
# Fix PyTorch DLL loading issue on Windows before importing PyQt6
8+
if platform.system() == "Windows":
9+
import ctypes
10+
import site
11+
12+
for site_path in site.getsitepackages():
13+
torch_lib_path = os.path.join(site_path, "torch", "lib")
14+
if os.path.exists(torch_lib_path):
15+
# Pre-load torch DLLs before Qt can interfere
16+
for dll in ['c10.dll', 'torch_cpu.dll', 'torch_python.dll']:
17+
dll_path = os.path.join(torch_lib_path, dll)
18+
if os.path.exists(dll_path):
19+
try:
20+
ctypes.CDLL(dll_path)
21+
except Exception:
22+
pass
23+
break
24+
725
# Qt platform plugin detection (fixes #59)
826
try:
927
from PyQt6.QtCore import QLibraryInfo

abogen/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ def calculate_text_length(text):
257257

258258

259259
def get_gpu_acceleration(enabled):
260+
"""
261+
Check GPU acceleration availability.
262+
263+
Note: On Windows, torch DLLs must be pre-loaded in main.py before PyQt6
264+
to avoid DLL initialization errors.
265+
"""
260266
try:
261267
import torch
262268
from torch.cuda import is_available as cuda_available

0 commit comments

Comments
 (0)