mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Fixed [WinError 1114] A dynamic link library (DLL) initialization routine failed, Potential fix for CUDA GPU is not available
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user