import torch: How to fix OSError WinError 126, error loading fbgemm.dll or dependencies

211 views Asked by At

I installed the modules below:

conda install pytorch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 -c pytorch

Then installed numpy, pandas, matplotlib, seaborn, sickit-learn, pyedflib in this environment. Yet upon import it seems some files are missing:

OSError                                   Traceback (most recent call last)
Cell In[3], line 1
----> 1 import torch
      2 from torch import nn
      3 import numpy as np

File d:\anaconda3\envs\RN\lib\site-packages\torch\__init__.py:141
    139                 err = ctypes.WinError(ctypes.get_last_error())
    140                 err.strerror += f' Error loading "{dll}" or one of its dependencies.'
--> 141                 raise err
    143     kernel32.SetErrorMode(prev_error_mode)
    146 def _preload_cuda_deps(lib_folder, lib_name):

OSError: [WinError 126] can't find this module. Error loading "d:\anaconda3\envs\RN\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

I reinstalled torch, but I can't solve it. And I even checked the file 'fbgemm.dll', it is there.

1

There are 1 answers

0
OCa On

It looks like, somehow, another file is missing (one of its dependencies). Starting from a new environment could remove unnecessary constraints. Inspired from this answer, with all requirements at once, not one part then add the other modules:

conda create -n env_torch pytorch=2.2.0 torchvision=0.17.0 torchaudio=2.2.0 numpy pandas matplotlib seaborn scikit-learn pyedflib
activate env_torch 

The conda cheat sheet is your best friend. Other things I looked up: