首先聲明一下,我是接著本專題寫的,所以到此應(yīng)該已經(jīng)裝好了NVIDIA顯卡驅(qū)動(dòng)、cudnn、以及常用的庫如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位置可通過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
無果
無奈只好修改.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ù)測試,報(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