theanoでGPUを使用しようとしています。.theanorc ファイルを作成し、次の Python コードを実行しようとしました。
from theano import function, config, shared
import theano.tensor as T
import numpy
import time
vlen = 10 * 30 * 768 # 10 x #cores x # threads per core
iters = 1000
rng = 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 xrange(iters):
r = f()
t1 = time.time()
print 'Looping %d times took' % iters, t1 - t0, 'seconds'
print 'Result is', 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'
このコードは deeplearning.net から取得しました。
出力:
nvcc : fatal error : Unsupported host compiler 'bi'
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', -1, 'for cmd', 'nvcc -shared -g -O3 --compiler-bindir C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bi -Xlinker /DEBUG -m64 -Xcompiler -LC:\\Python26\\libs,-DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88a837011,/Zi,/MD -IC:\\Users\\Prashanth\\Anaconda\\lib\\site-packages\\theano\\sandbox\\cuda -IC:\\Users\\Prashanth\\Anaconda\\lib\\site-packages\\numpy\\core\\include -IC:\\Users\\Prashanth\\Anaconda\\include -o C:\\Users\\Prashanth\\AppData\\Local\\Theano\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_42_Stepping_7_GenuineIntel-2.7.8-64\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\Users\\Prashanth\\Anaconda\\libs -LNone\\lib -LNone\\lib64 -LC:\\Users\\Prashanth\\Anaconda -lpython27 -lcublas -lcudart')
ERROR:theano.sandbox.cuda:Failed to compile cuda_ndarray.cu: ('nvcc return status', -1, 'for cmd', 'nvcc -shared -g -O3 --compiler-bindir C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bi -Xlinker /DEBUG -m64 -Xcompiler -LC:\\Python26\\libs,-DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88a837011,/Zi,/MD -IC:\\Users\\Prashanth\\Anaconda\\lib\\site-packages\\theano\\sandbox\\cuda -IC:\\Users\\Prashanth\\Anaconda\\lib\\site-packages\\numpy\\core\\include -IC:\\Users\\Prashanth\\Anaconda\\include -o C:\\Users\\Prashanth\\AppData\\Local\\Theano\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_42_Stepping_7_GenuineIntel-2.7.8-64\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LC:\\Users\\Prashanth\\Anaconda\\libs -LNone\\lib -LNone\\lib64 -LC:\\Users\\Prashanth\\Anaconda -lpython27 -lcublas -lcudart')
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available
WARNING:theano.sandbox.cuda:CUDA is installed, but device gpu is not available
['nvcc', '-shared', '-g', '-O3', '--compiler-bindir', 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bi', '-Xlinker', '/DEBUG', '-m64', '-Xcompiler', '-LC:\\Python26\\libs,-DCUDA_NDARRAY_CUH=d67f7c8a21306c67152a70a88a837011,/Zi,/MD', '-IC:\\Users\\Prashanth\\Anaconda\\lib\\site-packages\\theano\\sandbox\\cuda', '-IC:\\Users\\Prashanth\\Anaconda\\lib\\site-packages\\numpy\\core\\include', '-IC:\\Users\\Prashanth\\Anaconda\\include', '-o', 'C:\\Users\\Prashanth\\AppData\\Local\\Theano\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_42_Stepping_7_GenuineIntel-2.7.8-64\\cuda_ndarray\\cuda_ndarray.pyd', 'mod.cu', '-LC:\\Users\\Prashanth\\Anaconda\\libs', '-LNone\\lib', '-LNone\\lib64', '-LC:\\Users\\Prashanth\\Anaconda', '-lpython27', '-lcublas', '-lcudart']
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 16.3019998074 seconds
Result is [ 1.23178029 1.61879337 1.52278066 ..., 2.20771813 2.29967761
1.62323284]
Used the cpu