2016-08-18 70 views
1

我試圖運行此代碼優化卷積:接收Asse田,而在theano

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 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位工作和蟒蛇4.1.1安裝與:

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()說:

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 \圖書館\ lib中' 沒有我的系統上。

我也試過裏面找C中的MKL安裝:\蟒蛇\ PKGS,但僅僅是一個MRL-11.3.3-1.tar.bz2文件。

而且我單獨安裝英特爾MKL,並試圖

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

添加到我的theanorc.txt,從而導致錯誤:

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"')

我怎麼能夠鏈接森蚺MKL或intel mkl對我的theano正確嗎?

+0

我真的懷疑這些庫不能處理文件路徑的空間......所以,我們可能需要重新安裝顯示mkl在另一條路上,我不知道該怎麼做,我真的不想把我的電腦搞得這麼厲害:'( –

回答

0

是,theano不能在文件路徑中的空格處理...程序文件(86)

我試着到處尋找答案如何逃生空格字符,而我無法做到這一點。最後,我發現了符號鏈接,它創建了一些指向另一個目錄的目錄。

  • 以管理員身份運行cmd
  • 鍵入命令mklink /D "C:\LinkToProgramFilesX86" "C:\Program Files (x86)"(或要的聯繫,但要確保你不會添加任何空格,任何其他的名字,大聲笑)

這將創建一個鏈接,你就可以在Windows資源管理器中看到這個新目錄就好像它是一個快捷方式,但是作爲一個實際文件夾工作。

然後添加到您的[BLAS]配置:

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

不知道這是正確的目錄,雖然,但它肯定有空間解決了這個問題。在我的情況下,我用:

-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中找到一個動態庫。

我解決了進入numpy安裝目錄,並改變__config__.py文件中的相同的東西。 (全部換成Program Files (x86)新鏈接LinkToProgramFilesX86

消息停止後:)