Windows 10 在GPU、Windows 10上运行theano时出现问题

Windows 10 在GPU、Windows 10上运行theano时出现问题,windows-10,theano,python-3.5,theano-cuda,Windows 10,Theano,Python 3.5,Theano Cuda,我在GPU上运行无测试代码时遇到问题。我遵循了官方的Theano安装指南,但之后没有成功,我遵循了以下指南:。然而,我仍然无法在GPU上运行代码,并且出现了一些奇怪的行为 我要运行的测试示例: from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time vlen = 10 * 30 * 768 # 10 x #cores x # thre

我在GPU上运行无测试代码时遇到问题。我遵循了官方的Theano安装指南,但之后没有成功,我遵循了以下指南:。然而,我仍然无法在GPU上运行代码,并且出现了一些奇怪的行为

我要运行的测试示例:

    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')
在Pycharm中运行时,出现以下错误:

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
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.
>>>
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(17):警告C4005:“PyString\u Check”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(63):注意:请参见前面的“PyString\u检查”定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(18):警告C4005:“PyString\u FromString”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(65):注意:请参见前面对“PyString\u FromString”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(19):警告C4005:'PyString\u AsString':宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(72):注意:请参见前面对“PyString\u AsString”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(20):警告C4005:“PyString\u FromStringAndSize”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(66):注意:请参见前面对“PyString\u FromStringAndSize”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(21):警告C4005:“PyString\u Size”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(74):注意:请参见前面对“PyString\u大小”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(888):警告:已设置变量“prev”,但从未使用过
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(912):警告:已设置变量“result”,但从未使用过
mod.cu(803):警告:从指针到较小整数的转换
mod.cu(941):警告:无符号整数与零的无意义比较
mod.cu(3075):警告:语句无法访问
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(17):警告C4005:“PyString\u Check”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(63):注意:请参见前面的“PyString\u检查”定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(18):警告C4005:“PyString\u FromString”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(65):注意:请参见前面对“PyString\u FromString”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(19):警告C4005:'PyString\u AsString':宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(72):注意:请参见前面对“PyString\u AsString”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(20):警告C4005:“PyString\u FromStringAndSize”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(66):注意:请参见前面对“PyString\u FromStringAndSize”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cuda\u ndarray.cuh(21):警告C4005:“PyString\u Size”:宏重新定义
E:\Programs\Anaconda\lib\site packages\numpy\core\include\numpy/npy\u 3kcompat.h(74):注意:请参见前面对“PyString\u大小”的定义
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(888):警告:已设置变量“prev”,但从未使用过
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(912):警告:已设置变量“result”,但从未使用过
mod.cu(803):警告:从指针到较小整数的转换
mod.cu(941):警告:无符号整数与零的无意义比较
mod.cu(3075):警告:语句无法访问
nvcc警告:“compute_20”、“sm_20”和“sm_21”体系结构已弃用,可能会在将来的版本中删除(使用-Wno弃用的gpu目标来抑制警告)。
mod.cu
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(668):警告C4477:“fprintf”:格式字符串“%lu”需要类型为“unsigned long”的参数,但变量参数2的类型为“std::size\t”
E:\AsANONDA \ LIB站点包\TANO-0.82-PY3.5. Sea\TeaNo\\Soobox \CUDA\CNMEM.CPP(668):注意:考虑使用“%ZU”格式字符串
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670):警告C4477:“fprintf”:格式字符串“%016lx”需要类型为“unsigned long”的参数,但变量参数1的类型为“std::size\t”
E:\AsANONDA \ LIB站点包\TANO-0.82-PY3.5. Sea\TeaNo\\Soobox \CUDA\CNMEM.CPP(670):注意:考虑使用“%ZX”格式字符串
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670):警告C4477:“fprintf”:格式字符串“%016lx”需要类型为“unsigned long”的参数,但变量参数2的类型为“std::size\t”
E:\AsANONDA \ LIB站点包\TANO-0.82-PY3.5. Sea\TeaNo\\Soobox \CUDA\CNMEM.CPP(670):注意:考虑使用“%ZX”格式字符串
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sandbox\cuda\cnmem.cpp(670):警告C4477:“fprintf”:格式字符串“%lu”需要类型为“unsigned long”的参数,但变量参数3的类型为“std::size\t”
E:\Programs\Anaconda\lib\site packages\theano-0.8.2-py3.5.egg\theano\sa