Installing Theano on Windows - DLL load failed
Asked Answered
C

6

5

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.

Counterfoil answered 29/12, 2015 at 9:45 Comment(1)
Hi there. Suffering from the same problem here. Really, theano on Windows 64bit is a catastrophy. One problems hunts the next, and if your depatment just does not use/allow linux, what choice is there?Pepys
V
5

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.

Vaginal answered 12/5, 2016 at 15:46 Comment(1)
unfortunately, I cannot test it, i am enjoying the world of linux. For the people this works, add it in comments, over a period of time, this might become the working solutionCounterfoil
P
3

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.

Pepys answered 4/2, 2016 at 15:27 Comment(1)
I had done this, but it did not work for me. I have surrendered to it and moved to linux - things are blazing fast :P. I appreciate your efforts.Counterfoil
P
2

I was struggling with getting theano to work on Windows 10 x64 as well, and after reading several help guides, what worked for me in the end was the following:

  1. Install Intel Distribution for Python (make sure c:\intelpython27\ and c:\intelpython27\scripts are in the PATH)
  2. Open a command line and do: conda install mingw libpython
  3. Then do: pip install theano
  4. Download the precompiled libopenblas.dll from http://sourceforge.net/projects/openblas/files/v0.2.14/ (I got OpenBLAS-v0.2.14-Win64-int32.zip)
  5. Download mingw64_dll.zip as well from http://sourceforge.net/projects/openblas/files/v0.2.14/mingw64_dll.zip/download
  6. extract OpenBLAS-v0.2.14-Win64-int32.zip to c:\openblas, for example
  7. extract mingw64_dll.zip to c:\openblas\bin
  8. Add c:\openblas\lib and c:\openblas\bin to PATH
  9. Create .theanorc.txt in c:\Users\{username}
  10. Put the following in .theanorc.txt:

    [global]
    floatX = float32
    device = cpu
    
    [blas]
    ldflags = -LC:\\openblas\\bin -LC:\\openblas\\lib -lopenblas
    

Hope this helps someone.

Poulter answered 16/11, 2016 at 11:26 Comment(0)
H
1

Just to add my experience with Win10 64bit and theano (and keras). I was getting the DLL load fail error as well. Tried all the stuff I have found on theano win install webpage and in the different forum and blog posts (mentioned here in Uradium's post).

It didn't work for me, but here is what worked:

  1. I installed TDM-GCC-64 and openblas, using regedit I have added their /bin directories to PATH (and /lib directory of openblas as well)

  2. made clean venv under miniconda3 - installed prerequisites for theano and keras (scipy, numpy, pyyaml), python 3.5.2

  3. conda install mingw libpython

  4. conda install theano (installs all the mingw libraries as well)

  5. at this point - it worked - so I didnt use any .theanorc.txt file configuration, no fiddling with Windows environment variables. It even worked for keras based python scripts, even-though I had not installed keras into my conda venv it was working in...(I have keras installed in my "normal" non-conda python3, and later I pip installed keras under my conda venv as well).

Huntley answered 17/11, 2016 at 22:21 Comment(0)
C
0

Quite late, but for future reference. I stumbled upon this thread trying to run an OpenBLAS test script on the CPU. It worked fine on the GPU but the CPU gives me the same errors as the OP. I tried the suggestions here, but that didn't work. Turns out that the line in .theanorc:

ldflags=-LE:\OpenBLAS-v0.2.14-Win64-int32/bin -lopenblas

shouldn't have the space after bin and before -l. So it should be:

ldflags=-LE:\OpenBLAS-v0.2.14-Win64-int32/bin-lopenblas

Now everything works. Tried it on:

Windows 10
Python 3.5
Theano 0.9
Cuda 8 (with CudaMEM and CudaDNN)
Visual Studio 2015 Community
Coen answered 28/3, 2017 at 14:40 Comment(0)
S
0

I have this problem and I get this solution, after install theano,again I reinstall numpy . I solved this problem

pip uninstall numpy

pip install numpy

Synchromesh answered 4/1 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.