刚刚开始学习Deep Learning
OS:Ubuntu 14.04 CPU:I7-4700MQ GPU:GT 750M
是在这个网站下学习的:http://deeplearning.net
安装Theano:http://deeplearning.net/software/theano/install.html#install安装过程很简单,一步一步做就行了。
使用GPU测试Theano,复制下面的python代码,自建一个py文件:
以下是执行结果:
THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python check1.py [Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)] Looping 1000 times took 2.16374897957 seconds Result is [ 1.23178029 1.61879337 1.52278066 ..., 2.20771813 2.29967761 1.62323284] Used the cpu
</pre><pre name="code" class="plain">sudo THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python check1.py Using gpu device 0: GeForce GT 750M [GpuElemwise{exp,no_inplace}(<CudaNdarrayType(float32, vector)>), HostFromGpu(GpuElemwise{exp,no_inplace}.0)] Looping 1000 times took 0.532066106796 seconds Result is [ 1.23178029 1.61879349 1.52278066 ..., 2.20771813 2.29967761 1.62323296] Used the gpu
对比以上结果:1)执行命令中:前者device=cpu,或者device=gpu
2)显示结果中,比较明显的不同是:Used the cpu计算时间超过2秒,同样的文件Used the gpu计算时间仅用了0.53秒
另外,在我自己执行的过程中,遇到一个问题:
执行命令是device=gpu,但是执行结果出现error,并且计算使用的是cpu。THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python check1.py WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: Unable to get the number of gpus available: unknown error) [Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)] Looping 1000 times took 2.19189310074 seconds Result is [ 1.23178029 1.61879337 1.52278066 ..., 2.20771813 2.29967761 1.62323284] Used the cpu
error显示是不能获得可用的gpu,其实是权限问题,只要在执行命令前加上sudo,就可以了。