My CUDA and Theano do not work together

168 views Asked by At

I am trying to test my GPU sanity by running this code

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 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, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')

I got this error:

mod.cu(941): warning: pointless comparison of unsigned integer with zero
mod.cu(3001): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3004): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3006): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3009): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3011): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3014): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3017): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3020): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3022): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3025): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3027): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3030): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3032): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3035): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3038): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3041): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3043): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3046): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3048): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3051): warning: conversion from a string literal to "char *" is deprecated
mod.cu(941): warning: pointless comparison of unsigned integer with zero
mod.cu(3001): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3004): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3006): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3009): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3011): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3014): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3017): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3020): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3022): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3025): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3027): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3030): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3032): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3035): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3038): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3041): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3043): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3046): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3048): warning: conversion from a string literal to "char *" is deprecated
mod.cu(3051): warning: conversion from a string literal to "char " is deprecated
/usr/include/string.h: In function ‘void
__mempcpy_inline(void*, const void*, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
return (char ) memcpy (__dest, __src, __n) + __n;
^
mod.cu: In function ‘PyObject
CudaNdarray_Reshape(CudaNdarray*, PyObject*)’:

mod.cu:955:122: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
PyErr_Format(PyExc_ValueError, "size must remain unchanged, changed from %lld to %lld", CudaNdarray_SIZE(self), rval_size);
^
['nvcc', '-shared', '-O3', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=c72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden', '-Xlinker', '-rpath,/home/rkenaya/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.12-64/cuda_ndarray', '-I/usr/local/lib/python2.7/dist-packages/theano/sandbox/cuda', '-I/usr/local/lib/python2.7/dist-packages/numpy/core/include', '-I/usr/include/python2.7', '-I/usr/local/lib/python2.7/dist-packages/theano/gof', '-o', '/home/rkenaya/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.12-64/cuda_ndarray/cuda_ndarray.so', 'mod.cu', '-L/usr/lib', '-lcublas', '-lpython2.7', '-lcudart'] mod.cu:955:122: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘size_t {aka long unsigned int}’ [-Wformat=] 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/rkenaya/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.12-64/cuda_ndarray -I/usr/local/lib/python2.7/dist-packages/theano/sandbox/cuda -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -I/usr/local/lib/python2.7/dist-packages/theano/gof -o /home/rkenaya/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-2.7.12-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)
[Elemwise{exp,no_inplace}()]
Looping 1000 times took 4.233657 seconds
Result is [ 1.23178029 1.61879337 1.52278066 ..., 2.20771813 2.29967761 1.62323284]
Used the cpu

0

There are 0 answers