在Windows上安装ano-加载DLL失败

2024-06-13 06:39:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在Windwos 8上安装Theano

已经遵循了these步骤。

我尝试使用:

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(), ))

我知道这个脚本是numpy和theano计算时间的比较。

但不知怎么的,有些dll没有找到。Pl找到以下日志:

[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.

作为python世界的新手,我无法找出哪个Dll在not found中。如果缺少,我将安装它,并将路径添加到系统路径变量。但我如何知道它是哪个dll。我尝试使用pdb,并在cmodule.py中的不同位置设置断点,但没有一个被命中。

  1. 你熟悉这种错误及其解决方法吗?
  2. 否则,请帮助我找到丢失的dll名称,我将执行其余操作。
  3. 我不介意在安装theano时走完全不同的路。我偶然发现一些帖子建议微软编译器工作得很好。但我已经坐在一个问题上,从过去14个小时连续,并希望一个方法,这是可行的。最终,我想要theano在我的系统上。

顺便说一下,没有CUDA。我只在用CPU。


Tags: installedinpyherelibpackageslinesite
3条回答

好吧,我终于找到了使用WinPython、python3.5.1.1、Win 7 64bit和mingw64安装的原因:

在.theanoc[.txt]文件中,在安装blas之后,我看到一个[blas]部分,其中有一行包括openblas include路径。我删除了那一行,把下面的区域留空。重新启动WinPython/Spider,打开一个新控制台,它工作了。

之后,使用Theano从千层面运行mnist.py进行测试。

可能有点晚了。我跟你一模一样地遵循着同样的指导,也遇到了同样的错误。

原来,可以通过将openblas目录添加到系统路径来修复它。在您的示例中,将“E:\ Things\u Installed\u Here\Theano\openblas”添加到系统路径变量。

请注意,根据放置DLL文件的位置,需要添加“E:\ Things\u Installed\Theano\openblas”或“E:\ Things\u Installed\Theano\openblas\bin”。

Windows1064位,Python3.5.1(Anaconda2.5),Theano0.8.2。

对于那些需要它的人,我可以在Windows 10中安装Theano,这要感谢这三个指南guide1guide2和OP附带的指南

我也在努力让theano在Windows 10 x64上运行,在阅读了几本帮助指南之后,我最终得到了以下结果:

  1. 安装英特尔Python发行版(请确保路径中有c:\ intelpython27\和c:\ intelpython27\脚本)
  2. 打开命令行并执行以下操作:conda install mingw libpython
  3. 然后做:pip install theano
  4. http://sourceforge.net/projects/openblas/files/v0.2.14/下载预编译的libopenblas.dll(我得到了OpenBLAS-v0.2.14-Win64-int32.zip)
  5. http://sourceforge.net/projects/openblas/files/v0.2.14/mingw64_dll.zip/download下载mingw64_dll.zip
  6. 例如,将OpenBLAS-v0.2.14-Win64-int32.zip解压到c:\ OpenBLAS
  7. 将mingw64_dll.zip解压到c:\ openblas\bin
  8. 将c:\ openblas\lib和c:\ openblas\bin添加到路径
  9. 在c:\用户\{username}中创建.theanoc.txt
  10. 在.theanoc.txt中输入以下内容:

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

希望这能帮助别人。

相关问题 更多 >