1. 程式人生 > >解決深度學習框架theano 匯入時報warning :g++ not available

解決深度學習框架theano 匯入時報warning :g++ not available

軟體包準備

1、Anaconda 下載地址,包含python、numpy、scipy、nose、pip等包,嗯,很爽。

2、tdm64-gcc 下載地址,windows下的gcc、g++編譯器,用來theano效能優化的,不然速度會很慢(官方文件如是說)

3、theano原始碼 下載地址,github上的實時更新的thenao原始碼,可以下載zip包,或者clone。

一、安裝

Anaconda、tdm64-gcc一路下一步安裝即可,沒有什麼特殊需要注意的。

下載theano原始碼後進入其根目錄例如:theano-master,cmd執行如下命令進行安裝:

python setup.py develop

二、配置theanorc.txt

編輯thenaorc.txt 存放在使用者的根目錄,知道根目錄在哪可以cmd執行如下命令進行檢視:

echo  %USERPROFILE%

theanorc.txt內容如下(只配置了gcc、g++路徑,用來theano的優化):

[cxx]
flags=C:\TDM-GCC-64\bin
以上C:\TDM-GCC-64\bin路徑為tdm-gcc編譯器的bin目錄,按照你自己的路徑來配置。

三、測試theano安裝成功

cmd開啟python,執行:

import theano
theano.test()

import theano執行失敗證明theano安裝不成功,我在theano.test()時出現如下錯誤

ERROR: Failure: ImportError (No module named nose_parameterized)

安裝nose_parameterized即可,cmd執行:

pip install nose_parameterized

後記

1、LINK : fatal error LNK1181: cannot open input file 'cublas.lib' 的問題

可能是因為cuda安裝的該版本(我的是7.5),這個版本的cublas.lib只有64位的,這樣如果你的anacanda安裝的是32位就會在編譯的時候報錯,連結不了。

2、theano 提示 g++ not detected !

匯入theano包後出現如下警告:

WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.

解決辦法:

conda install mingw libpython

3、安裝cudnn

解壓縮,複製到cuda的相應的資料夾裡即可。

4、配置檔案

複製程式碼
[global]
device = cpu
floatX = float32
exception_verbosity=high

[lib]
cnmem = .95

[cuda]  
root=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin  


[nvcc]
flags=-LD:\Anaconda2\libs
compiler_bindir=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
fastmath = True

[traceback]
limit=20
複製程式碼