在GPU,Windows 10上使用runnig theano引发麻烦

时间:2016-12-27 19:48:32

标签: windows-10 theano python-3.5 theano-cuda

我在GPU上运行Theano测试代码时遇到问题。我遵循了官方的Theano安装指南,之后我没有按照本指南工作:https://github.com/philferriere/dlwin。但是我仍然无法在GPU上运行代码,并且会出现一些奇怪的行为。

测试示例我想运行:

var AngularModuleComponent = function( container, state ) {
        var html = $( '#' + state.templateId ).html(),
            element = container.getElement();
        element.html(html);

    angular
        .module( state.module )

        angular.bootstrap( element[ 0 ], [ state.module ] );
    }

在Pycharm中运行时出现以下错误:

    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')

但是当我尝试从控制台导入theano时,我收到以下错误:

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

我安装了最新的64位版cuda(cuda-8.0.44),我有一个64位python 3.5.2,theano realease 0.8.2,NVIDIA GTX 680,Microsoft visual studio 2015。

我一直困扰着24小时,我的想法已经不多了。 提前感谢您的帮助!

编辑:在PyCharm中导入theano工作正常,我在两种情况下使用相同的python

0 个答案:

没有答案