Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Theano on Windows - DLL load failed

I am trying to install Theano on Windwos 8

Have followed these steps.

I try to test using:

import numpy as np
import time
import theano

print('blas.ldflags=', theano.config.blas.ldflags)
A = np.random.rand(1000, 10000).astype(theano.config.floatX)
B = np.random.rand(10000, 1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X, Y = theano.tensor.matrices('XY')
mf = theano.function([X, Y], X.dot(Y))
t_start = time.time()
tAB = mf(A, B)
t_end = time.time()
print("NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" % (
np_end - np_start, t_end - t_start))
print("Result difference: %f" % (np.abs(AB - tAB).max(), ))

I am aware that the script is comparison between numpy and theano computation time.

But somehow, some dll is not found. Pl find the following log:

[Py341] C:\>python ML\Deep\TheanoSetupTesting.py
blas.ldflags= -LE:\Things_Installed_Here\Theano\openblas -lopenblas
Traceback (most recent call last):
  File "ML\Deep\TheanoSetupTesting.py", line 12, in <module>
    mf = theano.function([X, Y], X.dot(Y))
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\compile\function.py", line 317, in function
    output_keys=output_keys)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\compile\pfunc.py", line 526, in pfunc
    output_keys=output_keys)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\compile\function_module.py", line 1778, in orig_function

    defaults)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\compile\function_module.py", line 1642, in create input_storage=input_storage_lists, storage_map=storage_map)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\link.py", line 690, in make_thunk
    storage_map=storage_map)[:3]
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\vm.py", line 1037, in make_all
    no_recycling))
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\op.py", line 932, in make_thunk
    no_recycling)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\op.py", line 850, in make_c_thunk
    output_storage=node_output_storage)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cc.py", line 1207, in make_thunk
    keep_lock=keep_lock)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cc.py", line 1152, in __compile__
    keep_lock=keep_lock)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cc.py", line 1602, in cthunk_factory
    key=key, lnk=self, keep_lock=keep_lock)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cmodule.py", line 1174, in module_from_key  module = lnk.compile_cmodule(location)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cc.py", line 1513, in compile_cmodule
    preargs=preargs)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cmodule.py", line 2196, in compile_str
    return dlimport(lib_filename)
  File "E:\Things_Installed_Here\Anaconda_Py\envs\Py341\lib\site-packages\theano-0.7.0-py3.4.egg\theano\gof\cmodule.py", line 331, in dlimport
    rval = __import__(module_name, {}, {}, [module_name])
ImportError: DLL load failed: The specified module could not be found.

being new to python world, I am not able to find out which Dll in not found. I would install it if missing and would add the path the system path variable. But how do I get to know which dll it is. I tried using pdb and set a breakpoint in cmodule.py at various locations, but none gets hit.

  1. Are you familiar to this kind of error and its resolution?
  2. Otherwise, help me find that missing dll name, and I'll do the rest.
  3. I do not mind a walking a completely different path in installing theano. I came across few posts which suggest microsoft compiler works just fine. But I am already sitting on a problem since past 14 hours continuously and would want a method which works. Ultimately I want theano on my system.

BTW, do not have a CUDA. I am trying on CPU only.

like image 805
Adorn Avatar asked Dec 29 '15 09:12

Adorn


2 Answers

This may be a little bit late. I followed the exact same guide as you, and ran into the same error.

Turns out that it can be fixed by adding the openblas directory to system path. In your example, add "E:\Things_Installed_Here\Theano\openblas" to system path variable.

Note that depending on where you put the DLL files, you either need to add "E:\Things_Installed_Here\Theano\openblas" or "E:\Things_Installed_Here\Theano\openblas\bin".

Windows 10 64 bit, Python 3.5.1 (Anaconda 2.5), Theano 0.8.2.

For those who need it, I am able to install Theano in Windows 10 thanks to these three guides guide1, guide2 and the guide attached by OP.

like image 138
cylim Avatar answered Nov 14 '22 05:11

cylim


OK, I finally found the reason at least for my installation using WinPython, python3.5.1.1, Win 7 64bit and mingw64:

In the .theanorc[.txt] file, I ha, after installing blas, a section [blas] with a line including the openblas include path. I removed that line and left the area below [blas] blank. Restarted WinPython/Spider, opened a new console and it worked.

Testet afterwards with running mnist.py from Lasagne using Theano.

like image 27
gilgamash Avatar answered Nov 14 '22 06:11

gilgamash