3

次のスクリプトを使用して、GPU が動作しているかどうかをテストします。

#!/usr/bin/env python
from theano import function, config, shared, sandbox
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')

実行すると、次のようになります。

http://pastebin.com/wM9jaGMF

興味深い部分は最後にあります。

ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 1, 'for cmd', 'nvcc -shared -O3 -m64 -Xcompiler -DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden -Xlinker -rpath,/home/moose/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.11+-64/cuda_ndarray -I/home/moose/.local/lib/python2.7/site-packages/theano/sandbox/cuda -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -I/home/moose/.local/lib/python2.7/site-packages/theano/gof -o /home/moose/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.11+-64/cuda_ndarray/cuda_ndarray.so mod.cu -L/usr/lib -lcublas -lpython2.7 -lcudart')
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available  (error: cuda unavailable)

私のシステム

  • Ubuntu 16.04 を使用しています。
  • 標準リポジトリ ( ) から CUDA をインストールしましたV7.5.17nvcc --version動作します。
  • pip経由でTheanoをインストールしました
  • CuDNN 4 を持っています (TensorFlow で動作します)
  • 私は設定CUDA_ROOT=/usr/bin/LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/ました(それが正しいかどうかはわかりません)

私の~/.theanorc

[global]
exception_verbosity=high
device=gpu
floatX=float32

[cuda]
root=/usr/bin/

パス

標準リポジトリからのインストールは、手動インストールとは異なる場合があると思います。いくつかの問題を明らかにする可能性のあるいくつかのパスを次に示します。

/usr/bin/nvcc
/usr/lib/x86_64-linux-gnu/libcuda.so
/usr/lib/x86_64-linux-gnu/libcudart.so
/usr/lib/nvidia-cuda-toolkit
/usr/include/cudnn.h

質問

どうすればそれを機能させることができますか?

4

2 に答える 2

4

何が問題を解決したのか正確にはわかりませんが、次のいずれかまたは両方 ( source )

sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev libblas-dev git
echo -e "\n[nvcc]\nflags=-D_FORCE_INLINES\n" >> ~/.theanorc
于 2016-05-26T23:12:16.007 に答える