我刚刚安装了Theano。 我在python中导入theano时遇到问题。当我在python 27 32位中导入Theano时,在Windows 7 64位中,我收到以下错误和警告:我还应该添加目前我已经安装了GCC 4.8.1。我需要做些什么来解决它。
谢谢,Afshin
===============================
00001 #include <Python.h>
00002 #include "structmember.h"
00003 #include <sys/time.h>
00004
00005 // Old Python compatibility from here:
00006 // http://www.python.org/dev/peps/pep-0353/
00007 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
00008 typedef int Py_ssize_t;
00009 #define PY_SSIZE_T_MAX INT_MAX
00010 #define PY_SSIZE_T_MIN INT_MIN
00011 // This one was taken from:
00012 // http://svn.python.org/projects/python/trunk/Modules/_ctypes/ctypes.h
00013 #define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob)
00014 #endif
00015
00016 #if PY_VERSION_HEX >= 0x03000000
00017 #include "numpy/npy_3kcompat.h"
00018 #define PyCObject_AsVoidPtr NpyCapsule_AsVoidPtr
00019 #define PyCObject_GetDesc NpyCapsule_GetDesc
00020 #define PyCObject_Check NpyCapsule_Check
00021 #endif
00022
00023 #ifndef Py_TYPE
00024 #define Py_TYPE(obj) obj->ob_type
00025 #endif
00026
00027 /**
00028
00029 TODO:
00030 - Check max supported depth of recursion
00031 - CLazyLinker should add context information to errors caught during evaluation. Say what node we were on, add the traceback attached to the node.
00032 - Clear containers of fully-useed intermediate results if allow_gc is 1
00033 - Add timers for profiling
00034 - Add support for profiling space used.
00035
00036
00037 */
00038 static double pytime(const struct timeval * tv)
00039 {
00040 struct timeval t;
00041 if (!tv)
00042 {
00043 tv = &t;
00044 gettimeofday(&t, NULL);
00045 }
00046 return (double) tv->tv_sec + (double) tv->tv_usec / 1000000.0;
00047 }
00048
00049 /**
00050 Helper routine to convert a PyList of integers to a c array of integers.
00051 */
00052 static int unpack_list_of_ssize_t(PyObject * pylist, Py_ssize_t **dst, Py_ssize_t *len,
00053 const char* kwname)
00054 {
00055 Py_ssize_t buflen, *buf;
00056 if (!PyList_Check(pylist))
00057 {
00058 PyErr_Format(PyExc_TypeError, "%s must be list", kwname);
00059 return -1;
00060 }
00061 assert (NULL == *dst);
00062 *len = buflen = PyList_Size(pylist);
00063 *dst = buf = (Py_ssize_t*)calloc(buflen, sizeof(Py_ssize_t));
00064 assert(buf);
00065 for (int ii = 0; ii < buflen; ++ii)
00066 {
00067 PyObject * el_i = PyList_GetItem(pylist, ii);
00068 Py_ssize_t n_i = PyNumber_AsSsize_t(el_i, PyExc_IndexError);
00069 if (PyErr_Occurred())
00070 {
00071 free(buf);
00072 *dst = NULL;
00073 return -1;
00074 }
00075 buf[ii] = n_i;
00076 }
00077 return 0;
00078 }
00079
00080 /**
00081
00082 CLazyLinker
00083
00084
00085 */
00086 typedef struct {
00087 PyObject_HEAD
00088 /* Type-specific fields go here. */
00089 PyObject * nodes; // the python list of nodes
00090 PyObject * thunks; // python list of thunks
00091 PyObject * pre_call_clear; //list of cells to clear on call.
00092 int allow_gc;
00093 Py_ssize_t n_applies;
00094 int n_vars; // number of variables in the graph
00095 int * var_computed; // 1 or 0 for every variable
00096 PyObject ** var_computed_cells;
00097 PyObject ** var_value_cells;
00098 Py_ssize_t **dependencies; // list of vars dependencies for GC
00099 Py_ssize_t *n_dependencies;
00100
00101 Py_ssize_t n_output_vars;
00102 Py_ssize_t * output_vars; // variables that *must* be evaluated by call
00103
00104 int * is_lazy; // 1 or 0 for every thunk
00105
00106 Py_ssize_t * var_owner; // nodes[[var_owner[var_idx]]] is var[var_idx]->owner
00107 int * var_has_owner; // 1 or 0
00108
00109 Py_ssize_t * node_n_inputs;
00110 Py_ssize_t * node_n_outputs;
00111 Py_ssize_t ** node_inputs;
00112 Py_ssize_t ** node_outputs;
00113 Py_ssize_t * node_inputs_outputs_base; // node_inputs and node_outputs point into this
00114 Py_ssize_t * node_n_prereqs;
00115 Py_ssize_t ** node_prereqs;
00116
00117 Py_ssize_t * update_storage; // input cells to update with the last outputs in output_vars
00118 Py_ssize_t n_updates;
00119
00120 void ** thunk_cptr_fn;
00121 void ** thunk_cptr_data;
00122 PyObject * call_times;
00123 PyObject * call_counts;
00124 int do_timing;
00125 int need_update_inputs;
00126 int position_of_error; // -1 for no error, otw the index into `thunks` that failed.
00127 } CLazyLinker;
00128
00129
00130 static void
00131 CLazyLinker_dealloc(PyObject* _self)
00132 {
00133 CLazyLinker* self = (CLazyLinker *) _self;
00134 free(self->thunk_cptr_fn);
00135 free(self->thunk_cptr_data);
00136
00137 free(self->is_lazy);
00138
00139 free(self->update_storage);
00140
00141 if (self->node_n_prereqs)
00142 {
00143 for (int i = 0; i < self->n_applies; ++i)
00144 {
00145 free(self->node_prereqs[i]);
00146 }
00147 }
00148 free(self->node_n_prereqs);
00149 free(self->node_prereqs);
00150 free(self->node_inputs_outputs_base);
00151 free(self->node_n_inputs);
00152 free(self->node_n_outputs);
00153 free(self->node_inputs);
00154 free(self->node_outputs);
00155
00156 if (self->dependencies)
00157 {
00158 for (int i = 0; i < self->n_vars; ++i)
00159 {
00160 free(self->dependencies[i]);
00161 }
00162 free(self->dependencies);
00163 free(self->n_dependencies);
00164 }
00165
00166 free(self->var_owner);
00167 free(self->var_has_owner);
00168 free(self->var_computed);
00169 if (self->var_computed_cells)
00170 {
00171 for (int i = 0; i < self->n_vars; ++i)
00172 {
00173 Py_DECREF(self->var_computed_cells[i]);
00174 Py_DECREF(self->var_value_cells[i]);
00175 }
00176 }
00177 free(self->var_computed_cells);
00178 free(self->var_value_cells);
00179 free(self->output_vars);
00180
00181 Py_XDECREF(self->nodes);
00182 Py_XDECREF(self->thunks);
00183 Py_XDECREF(self->call_times);
00184 Py_XDECREF(self->call_counts);
00185 Py_XDECREF(self->pre_call_clear);
00186 Py_TYPE(self)->tp_free((PyObject*)self);
00187 }
00188 static PyObject *
00189 CLazyLinker_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
00190 {
00191 CLazyLinker *self;
00192
00193 self = (CLazyLinker *)type->tp_alloc(type, 0);
00194 if (self != NULL) {
00195 self->nodes = NULL;
00196 self->thunks = NULL;
00197 self->pre_call_clear = NULL;
00198
00199 self->allow_gc = 1;
00200 self->n_applies = 0;
00201 self->n_vars = 0;
00202 self->var_computed = NULL;
00203 self->var_computed_cells = NULL;
00204 self->var_value_cells = NULL;
00205 self->dependencies = NULL;
00206 self->n_dependencies = NULL;
00207
00208 self->n_output_vars = 0;
00209 self->output_vars = NULL;
00210
00211 self->is_lazy = NULL;
00212
...... (我刚刚删除了一些代码,因为Stachoverflow不允许超过30000个字符...... ......
01075 PyModule_AddObject(m, "CLazyLinker", (PyObject *)&lazylinker_ext_CLazyLinkerType);
01076
01077 return RETVAL;
01078 }
01079
01080
Problem occurred during compilation with the command line below:
C:\cygwin64\bin\g++.exe -shared -g -march=nehalem -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=nehalem -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m32 -IC:\python2732\lib\site-packages\numpy-1.9.0-py2.7-win32.egg\numpy\core\include -IC:\python2732\include -o C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\lazylinker_ext.pyd C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp -LC:\python2732\libs -LC:\python2732 -lpython27
===============================
In file included from C:\python2732\include/Python.h:86:0,
from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:
C:\python2732\include/intobject.h:46:35: error: expected initializer before 'PyInt_AsUnsignedLongLongMask'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
^
In file included from C:\python2732\include/Python.h:8:0,
from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:
C:\python2732\include/pyconfig.h:302:23: error: '__int64' was not declared in this scope
# define PY_LONG_LONG __int64
^
C:\python2732\include/longobject.h:50:44: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
^
In file included from C:\python2732\include/Python.h:58:0,
from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:
C:\python2732\include/pyconfig.h:302:23: error: '__int64' does not name a type
# define PY_LONG_LONG __int64
^
C:\python2732\include/pyport.h:793:34: note: in definition of macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) RTYPE
^
C:\python2732\include/longobject.h:52:12: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
^
In file included from C:\python2732\include/Python.h:88:0,
from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:
C:\python2732\include/longobject.h:53:35: error: expected initializer before 'PyLong_AsUnsignedLongLong'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
^
C:\python2732\include/longobject.h:54:35: error: expected initializer before 'PyLong_AsUnsignedLongLongMask'
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
^
In file included from C:\python2732\include/Python.h:58:0,
from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:
C:\python2732\include/pyconfig.h:302:23: error: '__int64' does not name a type
# define PY_LONG_LONG __int64
^
C:\python2732\include/pyport.h:793:34: note: in definition of macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) RTYPE
^
C:\python2732\include/longobject.h:55:12: note: in expansion of macro 'PY_LONG_LONG'
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
^
Traceback (most recent call last):
File "C:\Users\Dell\Documents\Pyton\Home Work 1\test-theano\test-theano.py", line 7, in <module>
from theano import *
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\__init__.py", line 55, in <module>
from theano.compile import \
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\compile\__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\compile\function_module.py", line 18, in <module>
import theano.compile.mode
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\gof\vm.py", line 568, in <module>
import lazylinker_c
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\gof\lazylinker_c.py", line 116, in <module>
preargs=args)
File "C:\python2732\lib\site-packages\theano-0.7.0-py2.7.egg\theano\gof\cmodule.py", line 2010, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): In file included from C:\python2732\include/Python.h:86:0,. from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:. C:\python2732\include/intobject.h:46:35: error: expected initializer before 'PyInt_AsUnsignedLongLongMask'. PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);. ^. In file included from C:\python2732\include/Python.h:8:0,. from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:. C:\python2732\include/pyconfig.h:302:23: error: '__int64' was not declared in this scope. # define PY_LONG_LONG __int64. ^. C:\python2732\include/longobject.h:50:44: note: in expansion of macro 'PY_LONG_LONG'. PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);. ^. In file included from C:\python2732\include/Python.h:58:0,. from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:. C:\python2732\include/pyconfig.h:302:23: error: '__int64' does not name a type. # define PY_LONG_LONG __int64. ^. C:\python2732\include/pyport.h:793:34: note: in definition of macro 'PyAPI_FUNC'. # define PyAPI_FUNC(RTYPE) RTYPE. ^. C:\python2732\include/longobject.h:52:12: note: in expansion of macro 'PY_LONG_LONG'. PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);. ^. In file included from C:\python2732\include/Python.h:88:0,. from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:. C:\python2732\include/longobject.h:53:35: error: expected initializer before 'PyLong_AsUnsignedLongLong'. PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);. ^. C:\python2732\include/longobject.h:54:35: error: expected initializer before 'PyLong_AsUnsignedLongLongMask'. PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);. ^. In file included from C:\python2732\include/Python.h:58:0,. from C:\Users\Dell\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_30_Stepping_5_GenuineIntel-2.7.8-32\lazylinker_ext\mod.cpp:1:. C:\python2732\include/pyconfig.h:302:23: error: '__int64' does not name a type. # define PY_LONG_LONG __int64. ^. C:\python2732\include/pyport.h:793:34: note: in definition of macro 'PyAPI_FUNC'. # define PyAPI_FUNC(RTYPE) RTYPE. ^. C:\python2732\include/longobject.h:55:12: note: in expansion of macro 'PY_LONG_LONG'. PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);. ^.