Ubuntu16.04安裝Theano

首先聲明一下,我是接著本專題寫(xiě)的,所以到此應(yīng)該已經(jīng)裝好了NVIDIA顯卡驅(qū)動(dòng)、cudnn、以及常用的庫(kù)如numpy等

1. 我們先配置鏡像(提速,可選)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

2. 安裝theano

conda install theano pygpu

配置:

sudo gedit ~/.theanorc

添加:

[global]
floatX=float32
device=gpu
base_compiledir=~/external/.theano/
allow_gc=False
warn_float64=warn
[mode]=FAST_RUN
[nvcc]
fastmath=True
[cuda]
root=/usr/local/cuda

自己cuda位置可通過(guò)whereis cuda進(jìn)行查看
之后保存退出,終端輸入python然后import theano,
結(jié)果報(bào)錯(cuò):

'You are tring to use the old GPU back-end. '
ValueError: You are tring to use the old GPU back-end. It was removed from Theano. Use device=cuda* now. See https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29 for more information.

我嘗試更新一下:

pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git

無(wú)果
無(wú)奈只好修改.theanorc文件:

[global]
floatX=float32
#device=gpu
device=cuda0
base_compiledir=~/external/.theano/
allow_gc=False
warn_float64=warn
[mode]=FAST_RUN
[nvcc]
fastmath=True
[cuda]
root=/usr/local/cuda

繼續(xù)測(cè)試,報(bào)錯(cuò):

RuntimeError:
To use MKL 2018 with Theano either update the numpy conda packages to
their latest build or set "MKL_THREADING_LAYER=GNU" in your
environment.

解決方法:

conda uninstall mkl=2018
conda install mkl=2017

之后python import theano,一切正常

參考:
https://blog.csdn.net/u010751535/article/details/50806073/
https://blog.csdn.net/legend_hua/article/details/79732587
https://stackoverflow.com/questions/49048734/runtimeerror-to-use-mkl-2018-with-theano-you-must-set-mkl-threading-layer-gnu

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容