【问题标题】:Theano undefined reference to dgemm (Windows 7, WinPython)Theano 未定义对 dgemm 的引用(Windows 7,WinPython)
【发布时间】:2017-04-25 13:25:12
【问题描述】:

我使用 WinPython-64bit-3.5.1.1 和 Theano。导入 Theano 有效,我什至可以训练循环神经网络。但是,当我尝试使用卷积神经网络时,出现以下错误:

[...]mod.cpp:528: 对 `dgemm_' 的未定义引用\r.[...]

我假设某些库丢失/不适用于我的 CPU,但我不知道如何解决这个问题。你能告诉我你需要哪些信息来帮助我调试这个问题并最终解决这个问题吗?

例如,这段代码 (from a kaggle forum) 可以正常工作:

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

输出:

blas.ldflags= 
NP time: 0.452026[s], theano time: 0.491028[s] (times should be close when run on CPU!)
Result difference: 0.000000

每次我导入 theano 时,我都会收到一个错误,但它从未阻止我的循环神经网络工作。这是错误:

1 #define _CUDA_NDARRAY_C
2 
3 #include <Python.h>
4 #include <structmember.h>
5 #include "theano_mod_helper.h"
6 
7 #include <numpy/arrayobject.h>
8 #include <iostream>
9 
10 #include "cuda_ndarray.cuh"
11 
[...]
5327 
5328 /*
5329   Local Variables:
5330   mode:c++
5331   c-basic-offset:4
5332   c-file-style:"stroustrup"
5333   indent-tabs-mode:nil
5334   fill-column:79
5335   End:
5336 */
5337 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=79 :
5338 
===============================
nvcc : fatal error : nvcc cannot find a supported version of Microsoft Visual Studio. Only the versions 2008, 2010, and 2012 are supported
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 4294967295, 'for cmd', 'nvcc -shared -O3 -Xlinker /DEBUG -D HAVE_ROUND -m64 -Xcompiler -DCUDA_NDARRAY_CUH=mc72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD -IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\lib\\site-packages\\theano\\sandbox\\cuda -IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\lib\\site-packages\\numpy\\core\\include -IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\include -IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\lib\\site-packages\\theano\\gof -o C:\\Users\\user\\AppData\\Local\\Theano\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-3.5.1-64\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\libs -LC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64 -lpython35 -lcublas -lcudart')

['nvcc', '-shared', '-O3', '-Xlinker', '/DEBUG', '-D HAVE_ROUND', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=mc72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD', '-IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\lib\\site-packages\\theano\\sandbox\\cuda', '-IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\lib\\site-packages\\numpy\\core\\include', '-IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\include', '-IC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\lib\\site-packages\\theano\\gof', '-o', 'C:\\Users\\user\\AppData\\Local\\Theano\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-3.5.1-64\\cuda_ndarray\\cuda_ndarray.pyd', 'mod.cu', '-LC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64\\libs', '-LC:\\WinPython-64bit-3.5.1.1\\python-3.5.1.amd64', '-lpython35', '-lcublas', '-lcudart']

我发现this 线程讨论了同样的问题,但它只是链接到另一个站点。我可以按照这些说明进行操作,但他们假设我不使用 WinPython,从头开始安装所有内容。这是唯一的方法吗?

【问题讨论】:

    标签: python windows-7 theano


    【解决方案1】:

    我对空的 theano.config.blas.ldflags 很好奇。文档指出默认值为 -lblas 并且 dgemm_ 是 BLAS 事物。尝试安装 blas 并设置此变量。 例如。对于 MKL:

    1. 安装 MKL
    2. 确保您的编译器可以通过设置 LIBRARY_PATH 找到 mkl_rt
    3. 设置 theano.config.blas.ldflags='-lmkl_rt'

    【讨论】:

    • 错误:C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../ x86_64-w64-mingw32/bin/ld.exe: 找不到 -lmkl_rt 我设置了 LIBRARY_PATH = C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2017.0.036\compilers_and_libraries_2017\windows\compiler\lib 是否正确?
    • 它有 libmkl_rt 吗?
    • 好的,我修复了路径,但现在我得到了这个新错误:异常:('编译节点时发生以下错误',Dot22(X,Y),'\ n','编译失败(返回状态=1):C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2017/windows/mkl/lib/intel64_win/mkl_rt.lib:错误添加符号:没有错误\r.collect2.exe:错误:ld返回1 退出状态\r. ', '[Dot22(X, Y)]')
    • 多么有用的错误信息!我确定 Winpython 带有某种形式的 BLAS,你可以尝试找到那个位置并相应地设置你的路径和 config.blas.ldflags。 np.__config__.show() 可能会告诉您该 BLAS 库的位置。
    猜你喜欢
    • 1970-01-01
    • 2011-11-01
    • 1970-01-01
    • 2014-09-19
    • 2017-05-14
    • 2015-11-08
    • 2021-02-18
    • 2018-04-12
    • 1970-01-01
    相关资源
    最近更新 更多