[WinError 1114] loading c10.dll issue occurred while running import torch

Environment Information

  • Operating System: Windows 11 Professional (64-bit)

  • GPU: NVIDIA RTX 4060

  • Python: 3.11.7 (installed via official Python installer, not Anaconda)

  • Virtual Environment: venv, located at F:\ai_data\.venv

System Dependencies

  • Microsoft Visual C++ Redistributable 2015–2022 (x64) — installed

  • Microsoft Visual C++ Redistributable 2015–2022 (x86) — installed

  • Both redistributables were reinstalled, and the system was rebooted multiple times

NVIDIA Driver & CUDA

Checked via nvidia-smi:

  • Driver Version: 591.74

  • CUDA Version (reported by driver): 13.1

  • PyTorch Installation Details

    • Installed using pip inside the virtual environment

    • Installation command used:

      pip install torch torchvision
      
      
    • Installed PyTorch version:

      • torch: 2.9.1

      • Build: Stable

      • Platform: Windows

      • Compute Platform: CPU

    • No errors were reported during installation

    Verification:

    python -m pip show torch
    
    

    Output:

    Name: torch
    Version: 2.9.1
    
    

    Additional Attempts

    I have repeatedly:

    • Deleted and recreated the virtual environment

    • Reinstalled PyTorch multiple times using pip

    • Tried different compute platforms, including:

      • CUDA 12.6

      • CUDA 12.8

      • CUDA 13.0

      • CPU-only builds

    Despite these attempts, the issue remains unchanged.


    The Problem

    When running the following command inside the virtual environment:

    import torch
    
    

    I consistently encounter this error:

    OSError: [WinError 1114] The initialization routine of the dynamic link library (DLL) failed.
    Error loading "F:\ai_data\.venv\Lib\site-packages\torch\lib\c10.dll" or one of its dependencies.
    
    

    Question

    What could cause c10.dll (or one of its dependencies) to fail during initialization on Windows, even though PyTorch installs successfully via pip, all Visual C++ Redistributables are installed, and the NVIDIA driver is up to date?

    Any guidance on diagnosing or resolving this issue would be greatly appreciated.

HI,There
i guess this github issue should be relevant

this comment might be helpfull
(temporary solution)try adding these lines before importing pytorch see if it works
import os
import platform
if platform.system() == “Windows”:
import ctypes
from importlib.util import find_spec
try:
if (spec := find_spec(“torch”)) and spec.origin and os.path.exists(
dll_path := os.path.join(os.path.dirname(spec.origin), “lib”, “c10.dll”)
):
ctypes.CDLL(os.path.normpath(dll_path))
except Exception: