2017-05-10 2 views
0

Je veux utiliser Théano avec GPU, et j'utiliser le script suivant pour tester si le GPU fonctionne:Je veux utiliser Theano avec GPU, mais il semble que GPU n'est pas travaillé?

import os  
os.environ['THEANO_FLAGS'] = "device=gpu0"  
import theano 
from theano import function, config, shared, tensor 
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([], tensor.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, tensor.Elemwise) and 
       ('Gpu' not in type(x.op).__name__) 
       for x in f.maker.fgraph.toposort()]): 
    print('Used the cpu') 
else: 
    print('Used the gpu') 

mais j'obtenir le résultat suivant:

WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10). Please switch to the gpuarray backend. You can get more information about how to switch at this URL: 
https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29 

/usr/lib/python2.7/site-packages/theano/sandbox/cuda/__init__.py:556: UserWarning: Theano flag device=gpu* (old gpu back-end) only support floatX=float32. You have floatX=float64. Use the new gpu back-end with device=cuda* for that value of floatX. 
    warnings.warn(msg) 
Using gpu device 0: GeForce GT 720 (CNMeM is enabled with initial size: 50.0% of memory, cuDNN 6021) 
/usr/lib/python2.7/site-packages/theano/sandbox/cuda/__init__.py:631: UserWarning: Your cuDNN version is more recent than the one Theano officially supports. If you see any problems, try updating Theano or downgrading cuDNN to version 5.1. 
    warnings.warn(warn) 

[Elemwise{exp,no_inplace}(<TensorType(float64, vector)>)] 
Looping 1000 times took 3.424644 seconds 
Result is [ 1.23178032 1.61879341 1.52278065 ..., 2.20771815 2.29967753 
    1.62323285] 
Used the cpu 

Ma question Qu'est-ce que le résultat signifie-t-il? et Comment puis-je faire fonctionner le GPU?

Répondre

0

J'ai eu un problème similaire avec la nouvelle version de theano. Vous pouvez essayer avec

THEANO_FLAGS = "floatX = float32, device = gpu, nvcc.flags = -D_FORCE_INLINES" python test_gpu.py