python 在Windows上安装Theano- DLL加载失败

9lowa7mx  于 2024-01-05  发布在  Python
关注(0)|答案(6)|浏览(162)

我正在尝试在Windwos 8上安装Theano
已遵循these步骤。
我试着用以下方法测试:

  1. import numpy as np
  2. import time
  3. import theano
  4. print('blas.ldflags=', theano.config.blas.ldflags)
  5. A = np.random.rand(1000, 10000).astype(theano.config.floatX)
  6. B = np.random.rand(10000, 1000).astype(theano.config.floatX)
  7. np_start = time.time()
  8. AB = A.dot(B)
  9. np_end = time.time()
  10. X, Y = theano.tensor.matrices('XY')
  11. mf = theano.function([X, Y], X.dot(Y))
  12. t_start = time.time()
  13. tAB = mf(A, B)
  14. t_end = time.time()
  15. print("NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" % (
  16. np_end - np_start, t_end - t_start))
  17. print("Result difference: %f" % (np.abs(AB - tAB).max(), ))

字符串
我知道脚本是numpy和theano计算时间的比较。
但不知何故,一些dll没有找到。请找到以下日志:

  1. [Py341] C:\>python ML\Deep\TheanoSetupTesting.py
  2. blas.ldflags= -LE:\Things_Installed_Here\Theano\openblas -lopenblas
  3. Traceback (most recent call last):
  4. File "ML\Deep\TheanoSetupTesting.py", line 12, in <module>
  5. mf = theano.function([X, Y], X.dot(Y))
  6. 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
  7. output_keys=output_keys)
  8. 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
  9. output_keys=output_keys)
  10. 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
  11. defaults)
  12. 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)
  13. 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
  14. storage_map=storage_map)[:3]
  15. 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
  16. no_recycling))
  17. 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
  18. no_recycling)
  19. 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
  20. output_storage=node_output_storage)
  21. 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
  22. keep_lock=keep_lock)
  23. 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__
  24. keep_lock=keep_lock)
  25. 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
  26. key=key, lnk=self, keep_lock=keep_lock)
  27. 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)
  28. 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
  29. preargs=preargs)
  30. 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
  31. return dlimport(lib_filename)
  32. 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
  33. rval = __import__(module_name, {}, {}, [module_name])
  34. ImportError: DLL load failed: The specified module could not be found.


作为python世界的新手,我无法找到哪个Dll没有找到。如果缺少,我会安装它,并将路径添加到系统路径变量。但我如何知道它是哪个dll。我尝试使用pdb并在cmodule.py的各个位置设置断点,但没有命中。
1.你熟悉这种错误及其解决方法吗?
1.否则,请帮助我找到丢失的dll名称,其余的由我来完成。
1.我不介意在安装theano时走一条完全不同的道路。我遇到了一些建议微软编译器工作正常的帖子。但我已经坐在一个问题上,因为过去14个小时连续,并希望有一个工作的方法。最终我希望在我的系统上theano
顺便说一句,没有CUDA。我只在CPU上试。

uubf1zoe

uubf1zoe1#

这可能有点晚了。我遵循了和你完全一样的指南,也遇到了同样的错误。
原来它可以通过将openbox目录添加到系统路径来修复。在您的示例中,将“E:\Things_Installed_Here\Theano\openbox”添加到系统路径变量。
请注意,根据您放置DLL文件的位置,您需要添加“E:\Things_Installed_Here\Theano\openbox”或“E:\Things_Installed_Here\Theano\openbox\bin”。
Windows 10 64位,Python 3.5.1(Anaconda 2.5),Theano 0.8.2。
对于那些需要它的人,我能够在Windows 10中安装Theano,这要归功于这三个指南guide1guide2和OP所附的指南。

b91juud3

b91juud32#

好了,我终于找到了原因,至少我使用WinPython,python3.5.1.1,Win 7 64位和mingw 64安装:
在.theanorc[.txt]文件中,我在安装了Python之后,有一个部分[Python],其中有一行包含了OpenPython的包含路径。我删除了那一行,并将[Python]下面的区域留空。重新启动WinPython/Spider,打开一个新的控制台,它工作了。
之后使用Theano从Lasagne运行 mnist.py进行测试。

yqyhoc1h

yqyhoc1h3#

我也在努力让theano在Windows 10 x64上工作,在阅读了几个帮助指南之后,最终对我起作用的是以下内容:
1.安装Intel Distribution for Python(确保c:\intelpython27\和c:\intelpython27\scripts位于PATH中)
1.打开一个命令行并执行:conda install mingw libpython
1.然后执行:pip install theano
1.从http://sourceforge.net/projects/openblas/files/v0.2.14/下载预编译的libopenblas.dll(我得到了OpenBLAS-v0.2.14-Win64-int32.zip)
1.也可以从http://sourceforge.net/projects/openblas/files/v0.2.14/mingw64_dll.zip/download下载mingw64_dll.zip
1.例如,将OpenBLAS-v0.2.14-Win64-int32.zip解压缩到c:\openbox
1.将mingw64_dll.zip解压缩到c:\openbox\bin
1.将c:\openbox\lib和c:\openbox\bin添加到PATH
1.在c:\Users{username}中创建. theanorc.txt
1.在.theanorc.txt中输入以下内容:

  1. [global]
  2. floatX = float32
  3. device = cpu
  4. [blas]
  5. ldflags = -LC:\\openblas\\bin -LC:\\openblas\\lib -lopenblas

字符串
希望这对某人有帮助。

展开查看全部
ecr0jaav

ecr0jaav4#

只是为了增加我的经验与Win10 64位和theano(和keras).我得到了DLL加载失败错误以及.尝试了所有的东西,我已经发现在theano win安装网页和在不同的论坛和博客文章(在这里提到Uradium的帖子).
它对我不起作用,但以下是有效的:
1.我安装了TDM-GCC-64和OpenSSL,使用regedit将它们的/bin目录添加到PATH(以及OpenSSL的/lib目录)

  1. made clean venv under miniconda3 - installed premises for theano and keras(scipy,numpy,pyyaml),python 3.5.2
    1.第一个月
  2. conda install theano(同时安装所有mingw库)
    1.在这一点上-它工作-所以我没有使用任何.theanorc.txt文件配置,没有摆弄Windows环境变量。它甚至适用于基于keras的python脚本,即使我没有安装keras到我的conda venv中,它正在工作.(我在我的“正常”非conda python3中安装了keras,后来我也在我的conda venv下安装了keras)。
n3h0vuf2

n3h0vuf25#

很晚了,但供将来参考。我偶然发现这个线程试图在CPU上运行OpenBLAS测试脚本。它在GPU上运行良好,但CPU给我的错误与OP相同。我尝试了这里的建议,但没有工作。原来.theanorc中的行:

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

字符串
在bin之后和-l之前不应该有空格。所以应该是:

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


现在一切正常。试过了:

  1. Windows 10
  2. Python 3.5
  3. Theano 0.9
  4. Cuda 8 (with CudaMEM and CudaDNN)
  5. Visual Studio 2015 Community

展开查看全部
4ktjp1zp

4ktjp1zp6#

我有这个问题,我得到这个解决方案,安装后theano,我再次重新安装numpy。我解决了这个问题
pip uninstall numpy
pip安装numpy

相关问题