wisdom
wisdom

Reputation: 442

OSError: [WinError 126] module could not be found

I am trying to run MXNet port of SSD in python but I am facing a strange error when I run the demo saying

OSError: [WinError 126] The specified module could not be found

specifically when trying to open libmxnet.dll so I found when I tried to debug it.

the whole error message is like this:

>>>> kernel32
>>>>  C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\libmxnet.dll
Traceback (most recent call last):
  File "demo.py", line 2, in <module>
    import tools.find_mxnet
  File "C:\Users\wisdom\Desktop\mxnet-ssd-master\tools\find_mxnet.py", line 6, in <module>
    import mxnet as mx
  File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\__init__.py", line 24, in <module>
    from .context import Context, current_context, cpu, gpu, cpu_pinned
  File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\context.py", line 24, in <module>
    from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
  File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\base.py", line 213, in <module>
    _LIB = _load_lib()
  File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\site-packages\mxnet\base.py", line 204, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
  File "C:\Users\wisdom\Anaconda3\envs\gpu-test\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

where first two lines with >>>> sign indicate to the lines I was trying to debug and check where/when the error is fired in ...\ctypes\__init__.py file which look like this

if handle is None:
    x = (self._name)
    print('>>>>',x)
    self._handle = _dlopen(self._name, mode)

I checked of course the existence of the requested file libmxnet.dll and it is there, but whenever it is called it throws this error!

Upvotes: 2

Views: 28260

Answers (2)

Hello World
Hello World

Reputation: 211

you should install vcredist_x64 or vcredist_x86 package stands for Visual C++ Redistributable.

Upvotes: 0

wisdom
wisdom

Reputation: 442

Ok finally solved!

I got to know that such error could be thrown when the file dependencies are not satisfied or not found. So to check the dependencies you go first to Visual Studio Prompt and then navigate to the folder where libmxnet.dll exists and run the following command

dumpbin /dependents libmxnet.dll

and it will show you a list of required files.

What was missing in my case are some of nVidia GPU Computing Toolkit files Cuda 9.0 as libmxnet.dll asks for them and I was having toolkit version 10.0 instead!

Upvotes: 3

Related Questions