Theanoã使ã£ã¦GPUè¨ç®ãããã
Deep Learningã«theanoã®GPUè¨ç®ã®ãã¥ã¼ããªã¢ã«ããã£ãã®ã§ãã£ã¦ã¿ãã
pylearn2ã使ã£ããã£ã¼ãã©ã¼ãã³ã°ã®ãã¬ã¼ãã³ã°ãGPUã§é«éè¨ç®ã§ããã
Using the GPU — Theano 0.6 documentation
ã¡ãªã¿ã«CUDAã対å¿ãã¦ãªããã½ã³ã³ã ã¨CPUãã使ããªãã(airã§ããªãã£ã(; _ ;))
次ã®ã³ã¼ããå®è¡ããã
check.py
from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time vlen = 10 * 30 * 768 # 10 x 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'
CPUã§è¨ç®ããã¨ãã¯ã
THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python check.py
GPUã§è¨ç®ããã¨ãã¯ã
THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python check.py
ã¡ãªã¿ã«ãnvccã³ã³ãã¤ã©ããªãã¨ã¨ã©ã¼ãåºãã
nvcc compiler not found on $PATH. Check your nvcc installation and try again.
nvccã®ãã¦ã³ãã¼ãã
http://www.nvidia.com/content/cuda/cuda-downloads.html
ã¤ã³ã¹ãã¼ã«ã®åèãµã¤ãã
Getting Started Mac OS X :: CUDA Toolkit Documentation
ã¤ã³ã¹ãã¼ã«ãããããã¹ãéãã
export PATH=/Developer/NVIDIA/CUDA-5.5/bin:$PATH export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-5.5/lib:$DYLD_LIBRARY_PATH