在theano中优化卷积时收到AssertionError [英] Receive AssertionError while optimizing convolution in theano

查看:281
本文介绍了在theano中优化卷积时收到AssertionError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行以下代码:

I am trying to run this code:

x_set = np.random.rand(100,100,100)
x = T.dtensor3('x')
inp = x.reshape((100, 1, 100, 100))
W_stdDev = np.sqrt(2. / (3 * 3 * 2))

W = theano.shared(
    np.asarray(
        np.random.normal(loc=.0, scale=W_stdDev, size=(3,1,3,3)),
        dtype=theano.config.floatX
    ),
    borrow=True
)

conv_out = conv2d(
    input=inp,
    filters=W,
    filter_shape=(3,1,3,3),
)

train_model = theano.function(
    inputs=[x],
    outputs=conv_out,
)

print(train_model(x_set))

但收到错误:

AssertionError:AbstractConv2d Theano优化失败:没有 可用的实现支持所请求的选项.你是否 从优化程序中同时排除"conv_dnn"和"conv_gemm"?如果在GPU上, cuDNN是否可用,GPU是否支持它?如果在CPU上,您有 安装了Theano的BLAS库是否可以链接?

AssertionError: AbstractConv2d Theano optimization failed: there is no implementation available supporting the requested options. Did you exclude both "conv_dnn" and "conv_gemm" from the optimizer? If on GPU, is cuDNN available and does the GPU support it? If on CPU, do you have a BLAS library installed Theano can link against?

我正在Windows 10 64位和Anaconda 4.1.1安装上使用:

I am working on Windows 10 64bit and an Anaconda 4.1.1 installation with:

python 3.4.5; numpy 1.11.1; theano 0.9.0.dev2; mkl 11.3.3; mkl-service 1.1.2;

python 3.4.5; numpy 1.11.1; theano 0.9.0.dev2; mkl 11.3.3; mkl-service 1.1.2;

我试图弄清楚如何将theano链接到mkl,但是被卡住了.因为numpy.show_config()表示:

I tried to figure out how to link theano to mkl but got stuck. Because the numpy.show_config() says:

blas_opt_info:
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
    libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
    library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
openblas_lapack_info:
  NOT AVAILABLE
lapack_mkl_info:
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
    libraries = ['mkl_lapack95_lp64', 'mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
    library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
mkl_info:
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
    libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
    library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
lapack_opt_info:
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
    libraries = ['mkl_lapack95_lp64', 'mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
    library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']
blas_mkl_info:
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['C:\\Minonda\\envs\\_build\\Library\\include']
    libraries = ['mkl_core_dll', 'mkl_intel_lp64_dll', 'mkl_intel_thread_dll']
    library_dirs = ['C:\\Minonda\\envs\\_build\\Library\\lib']

但是系统上不存在路径'C:\ Minonda \ envs \ _build \ Library \ lib'.

but the Path 'C:\Minonda\envs\_build\Library\lib' does not exist on my system.

我还尝试在C:\ Anaconda \ pkgs中找到mkl安装,但是只有一个mkl-11.3.3-1.tar.bz2文件.

I tried also to find the mkl installation inside C:\Anaconda\pkgs, but there is just a mkl-11.3.3-1.tar.bz2 file.

我还单独安装了英特尔MKL,并尝试添加

Also I installed Intel MKL separately and tried to add

[blas]
ldflags = -LC:\Program Files(x86)\IntelSWTools\compilers_and_libraries_2016.3.207\windows\mkl\include

到我的theanorc.txt,导致错误:

to my theanorc.txt, which leads to the error:

ValueError :(在编译节点时发生以下错误",CorrMM {valid,(1,1),(1,1)}}(InplaceDimShuffle {0,x,1,2} .0,Elemwise {Cast {float64}}.0),'\ n',ldflags_str中的无效令牌文件":-LC:\ Program Files(x86)\ IntelSWTools \ compilers_and_libraries_2016.3.207 \ windows \ mkl \ include"')

ValueError: ('The following error happened while compiling the node', CorrMM{valid, (1, 1), (1, 1)}(InplaceDimShuffle{0,x,1,2}.0, Elemwise{Cast{float64}}.0), '\n', 'invalid token "Files" in ldflags_str: "-LC:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2016.3.207\windows\mkl\include"')

我如何将anaconda mkl或intel mkl正确链接到我的theano?

How am I able to link the anaconda mkl or the intel mkl correctly to my theano?

推荐答案

是的,theano无法处理文件路径中的空格...程序文件(x86)

Yes, theano cannot deal with spaces in the file path...ProgramFiles(x86)

我尝试到处寻找有关如何转义空格字符的答案,但我无法做到.最后,我找到了符号链接,该链接创建了指向另一个目录的某种目录.

I tried to find answers everywhere about how to escape the space character, and I was unable to do it. At the end, I found out the symbolic link, which creates some kind of directory that points to another directory.

  • 以管理员身份运行cmd.
  • 键入命令mklink /D "C:\LinkToProgramFilesX86" "C:\Program Files (x86)"(或您想要链接的其他任何名称,但请确保不会在其中添加任何空格,大声笑)
  • Run cmd as administrator.
  • Type the command mklink /D "C:\LinkToProgramFilesX86" "C:\Program Files (x86)" (or any other name you want to the link, but make sure you won't add any spaces to that, lol)

这将创建链接,您将能够在Windows资源管理器中看到此新目录,就好像它是快捷方式一样,但可以作为实际文件夹使用.

This will create the link and you will be able to see this new dir in Windows Explorer as if it were a shortcut, but working as an actual folder.

然后将其添加到您的[blas]配置中:

Then add this to your [blas] configuration:

ldflags = -L"C:\LinkToProgramFilesX86\IntelSWTools\compilers_and_libraries_2016.3.207\windows\mkl\include"

虽然不确定它是否是正确的目录,但是它肯定可以解决空格问题.就我而言,我使用了:

Not sure if it's the right dir, though, but it definitely solves the problem with spaces. In my case, I used:

-L"C:/LinkToProgramFilesX86/IntelSWTools/compilers_and_libraries_2017/windows/mkl/lib/intel64_win" -lmkl_lapack95_lp64 -lmkl_blas95_lp64 -lmkl_rt -lm -lm

...带双引号.

现在,由于生活不轻松,出现了一个新问题:我们没有在用于blas的库的library_dir中找到动态库.

Now, because life isn't easy, a new problem appeared: We did not found a dynamic library into the library_dir of the library we use for blas.

我解决了该问题,请转到numpy安装目录,并在文件__config__.py中更改相同的内容. (将所有Program Files (x86)替换为新链接LinkToProgramFilesX86)

I solved that going to the numpy installation directory, and changing the same thing in the file __config__.py. (Replaced all Program Files (x86) with the new link LinkToProgramFilesX86)

此后消息不再显示:)

这篇关于在theano中优化卷积时收到AssertionError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆