配置使用GPU加速的Theano环境
来源:互联网 发布:鬼泣4但丁数据 编辑:程序博客网 时间:2024/05/21 22:58
在安装过Anaconda3的环境下想利用oython2.7.13配置Theano环境,比较简单的方法是在Anaconda3里面另开一个python环境,然后在Pycharm里面切换python.exe的环境即可,这里可以参考我之前写过的在Anaconda下实现Python2.X与Python3.X共存 ,配置环境可以参考我之前的一篇总结Anaconda下安装keras 配置与pycharm运行demo(windows版本) 。
这里主要想总结一下我配置GPU加速的Teano环境的过程。当然如果想配置GPU加速的Tensorflow环境可以参考我的这篇文章。
这里我想说Theano的配置不像Tensorflow需要下载对应的GPU版本,我们在配置好Theano环境之后,只要 C:\Users\你的用户名 的路径下添加
.theanorc.txt 文件。
这里给出我的配置文件,里面的路径需要换成对应的路径,这里不多说。也可以参考文章后面的参考资料2的文章。
[global]openmp=Falsedevice = gpufloatX = float32base_compiler = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\binallow_input_downcast=True [lib]cnmem = 0.75[blas]ldflags=[gcc]cxxflags=-IC:\Users\lyh\Anaconda2\MinGW[nvcc]fastmath = Trueflags = -LC:\Users\lyh\Anaconda2\libscompiler_bindir = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\binflags = -arch=sm_30
如果在上述文件配置上遇到问题可以参考我下面的文章
Theano: CNMeM is disabled, CuDNN not available
http://blog.csdn.net/johinieli/article/details/77100240
Failed to get the number of CUDA devices: CUDA driver version is insufficient for CUDA runtime versi
http://blog.csdn.net/johinieli/article/details/77100091
python - Theano: Initialisation of device gpu failed! Reason=CNMEM_STATUS_OUT_OF_MEMORY
http://blog.csdn.net/johinieli/article/details/77100427
NameError: the name CVM is not defined
http://blog.csdn.net/johinieli/article/details/78137008
这里还给出Theano的GPU环境测试程序:
from theano import function, config, shared, sandboximport theano.tensor as Timport numpyimport timevlen = 10 * 30 * 768 # 10 x #cores x # threads per coreiters = 1000rng = numpy.random.RandomState(22)x = shared(numpy.asarray(rng.rand(vlen), config.floatX))f = function([], T.exp(x))print(f.maker.fgraph.toposort())t0 = time.time()for i in range(iters): r = f()t1 = time.time()print("Looping %d times took %f seconds" % (iters, t1 - t0))print("Result is %s" % (r,))if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]): print('Used the cpu')else: print('Used the gpu')
如果打印出了Used the gpu说明环境配置成功!
还有一个十分关键的地方,我已经被坑了好多次:
上述测试程序,还有其它自己编写的程序一定要注意命名!
不要使用关键字命名代码,否则程序报错,然后很难根据错误信息找到解决方法。笔者小白就是花了大量的时间在这个上面。
笔者小白在这个问题上面还碰到了,在Ananconda Prompt里面import theano正确,但是在pycharm里面import theano 报错,关键是配置的python.exe的路径也是正确的。在折腾了一大圈之后,发现还是测试代码文件命名的问题。
参考资料:
1、http://blog.csdn.net/goodshot/article/details/54945588 2017.9.29
2、http://blog.csdn.net/qq_30507287/article/details/70767017 2017.9.29
- 配置使用GPU加速的Theano环境
- 使用gpu加速theano
- Win7配置CUDA并搭建基于Theano框架的GPU加速环境
- Win7配置CUDA并搭建基于Theano框架的GPU加速环境
- Win7配置CUDA并搭建基于Theano框架的GPU加速环境
- Win7配置CUDA并搭建基于Theano框架的GPU加速环境
- windows下的theano以及GPU加速环境的搭建
- Win7_64环境theano的GPU配置
- Theano(Deep Learning Tool) 利用GPU来进行加速的配置及使用
- 【深度学习】win10+Theano+GPU加速配置
- 使用GPU和Theano加速深度学习
- 使用GPU和Theano加速深度学习
- Theano 配置记(Anaconda+Theano 0.7+GPU加速+VS2010)
- Win7 中安装Theano及配置CUDA以搭建GPU加速环境
- 配置ubuntu16.04下Theano使用GPU运行程序的环境
- Theano利用GPU加速
- Windows8-64bit环境下Theano的GPU配置
- windows系统下的keras(Theano/Tensorflow后端)CPU以及GPU加速环境搭建
- 爬虫小练手-爬取慕课网首页的图片
- MFC控件子类化技术实现
- Linux中的僵尸进程和信号
- BFS算法之求单源最短路径
- 864F(tarjan思想)
- 配置使用GPU加速的Theano环境
- OpenGL初探_1:光栅化概念
- 南阳理工_13Fibonacci数
- Unity3d背包系统系统(二)—— 开发消耗品、装备、武器材料
- DFS非递归算法
- 深度优先搜索(Depth-First-Search,DFS)
- sql 学习
- 超全面的JavaWeb笔记day08<Tomcat&Web应用&HTTP协议>
- 基于ssm框架的个人博客(4)--点击菜单中的功能,在center中添加tab