I am having trouble running Theano testing code on GPU. I have followed the official Theano installation guides, and after that didn't work i followed this guide:https://github.com/philferriere/dlwin . However i am still not able to run the code on GPU plus some strange behaviors are exhibited.
Test example i want to run:
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')
When running in Pycharm i get the following error:
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(17): warning C4005: 'PyString_Check': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(63): note: see previous definition of 'PyString_Check'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(18): warning C4005: 'PyString_FromString': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(65): note: see previous definition of 'PyString_FromString'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(19): warning C4005: 'PyString_AsString': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(72): note: see previous definition of 'PyString_AsString'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(20): warning C4005: 'PyString_FromStringAndSize': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(66): note: see previous definition of 'PyString_FromStringAndSize'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(21): warning C4005: 'PyString_Size': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(74): note: see previous definition of 'PyString_Size'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(888): warning: variable "prev" was set but never used
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(912): warning: variable "result" was set but never used
mod.cu(803): warning: conversion from pointer to smaller integer
mod.cu(941): warning: pointless comparison of unsigned integer with zero
mod.cu(3075): warning: statement is unreachable
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(17): warning C4005: 'PyString_Check': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(63): note: see previous definition of 'PyString_Check'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(18): warning C4005: 'PyString_FromString': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(65): note: see previous definition of 'PyString_FromString'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(19): warning C4005: 'PyString_AsString': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(72): note: see previous definition of 'PyString_AsString'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(20): warning C4005: 'PyString_FromStringAndSize': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(66): note: see previous definition of 'PyString_FromStringAndSize'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda_ndarray.cuh(21): warning C4005: 'PyString_Size': macro redefinition
E:\Programs\Anaconda\lib\site-packages\numpy\core\include\numpy/npy_3kcompat.h(74): note: see previous definition of 'PyString_Size'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(888): warning: variable "prev" was set but never used
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(912): warning: variable "result" was set but never used
mod.cu(803): warning: conversion from pointer to smaller integer
mod.cu(941): warning: pointless comparison of unsigned integer with zero
mod.cu(3075): warning: statement is unreachable
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mod.cu
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(668): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(668): note: consider using '%zu' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): warning C4477: 'fprintf' : format string '%016lx' requires an argument of type 'unsigned long', but variadic argument 1 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): note: consider using '%zx' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): warning C4477: 'fprintf' : format string '%016lx' requires an argument of type 'unsigned long', but variadic argument 2 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): note: consider using '%zx' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 3 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): note: consider using '%zu' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): warning C4477: 'fprintf' : format string '%016lx' requires an argument of type 'unsigned long', but variadic argument 4 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): note: consider using '%zx' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): warning C4477: 'fprintf' : format string '%2lu' requires an argument of type 'unsigned long', but variadic argument 5 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670): note: consider using '%zu' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(690): warning C4477: 'fprintf' : format string '%016lx' requires an argument of type 'unsigned long', but variadic argument 3 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(690): note: consider using '%zx' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(690): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 4 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(690): note: consider using '%zu' in the format string
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(690): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 5 has type 'std::size_t'
E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(690): note: consider using '%zu' in the format string
mod.cu(803): warning C4311: 'type cast': pointer truncation from 'CudaNdarray *' to 'long'
mod.cu(3374): warning C4312: 'type cast': conversion from 'long' to 'float *' of greater size
LINK : fatal error LNK1104: cannot open file 'uuid.lib'
['nvcc', '-shared', '-O3', '-Xlinker', '/DEBUG', '-D HAVE_ROUND', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=m18715462c72ed6afcd7ca5d52813ce90,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD', '-IE:\\Programs\\Anaconda\\lib\\site-packages\\theano-0.8.2-py3.5.egg\\theano\\sandbox\\cuda', '-IE:\\Programs\\Anaconda\\lib\\site-packages\\numpy\\core\\include', '-IE:\\Programs\\Anaconda\\include', '-IE:\\Programs\\Anaconda\\lib\\site-packages\\theano-0.8.2-py3.5.egg\\theano\\gof', '-o', 'C:\\Users\\erikj\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-3.5.2-64\\cuda_ndarray\\cuda_ndarray.pyd', 'mod.cu', '-LE:\\Programs\\Anaconda\\libs', '-LE:\\Programs\\Anaconda', '-lcublas', '-lpython35', '-lcudart']
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -O3 -Xlinker /DEBUG -D HAVE_ROUND -m64 -Xcompiler -DCUDA_NDARRAY_CUH=m18715462c72ed6afcd7ca5d52813ce90,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,/Zi,/MD -IE:\\Programs\\Anaconda\\lib\\site-packages\\theano-0.8.2-py3.5.egg\\theano\\sandbox\\cuda -IE:\\Programs\\Anaconda\\lib\\site-packages\\numpy\\core\\include -IE:\\Programs\\Anaconda\\include -IE:\\Programs\\Anaconda\\lib\\site-packages\\theano-0.8.2-py3.5.egg\\theano\\gof -o C:\\Users\\erikj\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-3.5.2-64\\cuda_ndarray\\cuda_ndarray.pyd mod.cu -LE:\\Programs\\Anaconda\\libs -LE:\\Programs\\Anaconda -lcublas -lpython35 -lcudart')
[Elemwise{exp,no_inplace}(<TensorType(float64, vector)>)]
Looping 1000 times took 11.687520 seconds
Result is [ 1.23178032 1.61879341 1.52278065 ..., 2.20771815 2.29967753
1.62323285]
Used the cpu
Process finished with exit code 0
But when i just try to import theano from the console i get the following error:
erikj@DESKTOP-76UUOFA MINGW64 /c/Users/erikj/Desktop
$ python -i
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano
Traceback (most recent call last):
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\gof\cutils.py", line 305, in <module>
from cutils_ext.cutils_ext import * # noqa
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\gof\cutils.py", line 316, in <module>
from cutils_ext.cutils_ext import * # noqa
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\__init__.py", line 76, in <module>
from theano.scan_module import scan, map, reduce, foldl, foldr, clone
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\scan_module\__init__.py", line 40, in <module>
from theano.scan_module import scan_opt
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\scan_module\scan_opt.py", line 59, in <module>
from theano import tensor, scalar
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\tensor\__init__.py", line 7, in <module>
from theano.tensor.subtensor import *
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\tensor\subtensor.py", line 27, in <module>
import theano.gof.cutils # needed to import cutils_ext
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\gof\cutils.py", line 319, in <module>
compile_cutils()
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\gof\cutils.py", line 284, in compile_cutils
preargs=args)
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\gof\cmodule.py", line 2213, in compile_str
return dlimport(lib_filename)
File "E:\Programs\Anaconda\lib\site-packages\theano-0.8.2-py3.5.egg\theano\gof\cmodule.py", line 299, in dlimport
rval = __import__(module_name, {}, {}, [module_name])
ImportError: DLL load failed: The specified procedure could not be found.
>>>
I installed latest 64 bit version of cuda (cuda-8.0.44), I have a 64 bit python 3.5.2, theano realease 0.8.2, NVIDIA GTX 680, Microsoft visual studio 2015.
I have been bothering for 24 hours with this and i am running out of ideas. Thank you in advance for the help !
edit: Import of theano in PyCharm works fine and i am using the same python in both cases