python 3.11环境运行python cli_demo.py chatglm报错

如果您使用 Jittor 时遇到了安装问题、运行错误、输出错误等问题,您可以在 “问答” 区提问。
为了更好地定位您的问题,建议包含以下内容:

  1. 错误信息、
  2. Jittor 运行的完整 log(建议复制粘贴运行输出,如果可能请不要使用截图)、
  3. 复现此问题的代码或者描述、
  4. 您认为正确结果应当如何、
  5. 其他必要信息

这有一个 参考模板

错误信息:
[i 0512 09:24:42.449682 16 compiler.py:956] g++ at /usr/local/gcc-5.4.0/bin/g++(5.4.0)
[i 0512 09:24:42.450107 16 compiler.py:957] cache_path: /root/.cache/jittor/jt1.3.7/g++5.4.0/py3.11.3/Linux-3.10.0-9x58/IntelRXeonRCPUxfe/default
[i 0512 09:24:42.505531 16 __init__.py:411] Found gdb(7.6.1) at /bin/gdb.
[i 0512 09:24:42.511027 16 __init__.py:411] Found addr2line(2.27) at /bin/addr2line.
In file included from /usr/include/python2.7/pyconfig.h:6:0,
from /usr/include/python2.7/Python.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:11,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:
/usr/include/python2.7/pyconfig-64.h:1191:0: 警告:“_POSIX_C_SOURCE”重定义
#define _POSIX_C_SOURCE 200112L
^
In file included from /usr/local/gcc-5.4.0/include/c++/5.4.0/x86_64-unknown-linux-gnu/bits/os_defines.h:39:0,
from /usr/local/gcc-5.4.0/include/c++/5.4.0/x86_64-unknown-linux-gnu/bits/c++config.h:482,
from /usr/local/gcc-5.4.0/include/c++/5.4.0/bits/stl_algobase.h:59,
from /usr/local/gcc-5.4.0/include/c++/5.4.0/memory:62,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/common.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/cache_compile.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:7:
/usr/include/features.h:168:0: 附注:这是先前定义的位置

define _POSIX_C_SOURCE 200809L

^
In file included from /usr/include/python2.7/pyconfig.h:6:0,
from /usr/include/python2.7/Python.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:11,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:
/usr/include/python2.7/pyconfig-64.h:1213:0: 警告:“_XOPEN_SOURCE”重定义
#define _XOPEN_SOURCE 600
^
In file included from /usr/local/gcc-5.4.0/include/c++/5.4.0/x86_64-unknown-linux-gnu/bits/os_defines.h:39:0,
from /usr/local/gcc-5.4.0/include/c++/5.4.0/x86_64-unknown-linux-gnu/bits/c++config.h:482,
from /usr/local/gcc-5.4.0/include/c++/5.4.0/bits/stl_algobase.h:59,
from /usr/local/gcc-5.4.0/include/c++/5.4.0/memory:62,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/common.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/cache_compile.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:7:
/usr/include/features.h:170:0: 附注:这是先前定义的位置

define _XOPEN_SOURCE 700

^
In file included from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:11:0,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h: 在函数‘jittor::Log& jittor::operator<<(jittor::Log&, PyObject*)’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:55:43: 错误:‘PyUnicode_AsUTF8’在此作用域中尚未声明
PyUnicode_AsUTF8(repr_obj.obj);
^
In file included from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:0:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h: 在函数‘typename std::enable_if<std::is_same<T, std::__cxx11::basic_string >::value, std::__cxx11::basic_string >::type jittor::from_py_object(PyObject*)’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:48:55: 错误:‘PyUnicode_AsUTF8AndSize’的实参不依赖模板参数,所以‘PyUnicode_AsUTF8AndSize’的声明必须可用 [-fpermissive]
const char* s = PyUnicode_AsUTF8AndSize(obj, &size);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:48:55: 附注:(如果您使用‘-fpermissive’,G++ 会接受您的代码,但是允许使用未定义的名称是已弃用的风格)
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h: 在函数‘typename std::enable_if<std::is_same<T, jittor::Slice>::value, T>::type jittor::from_py_object(PyObject*)’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:162:45: 错误:‘PySlice_Unpack’的实参不依赖模板参数,所以‘PySlice_Unpack’的声明必须可用 [-fpermissive]
PySlice_Unpack(obj, &start, &stop, &step);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h: 在函数‘typename std::enable_if<std::is_same<T, jittor::NanoString>::value, T>::type jittor::from_py_object(PyObject*)’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:258:38: 错误:‘PyUnicode_AsUTF8’的实参不依赖模板参数,所以‘PyUnicode_AsUTF8’的声明必须可用 [-fpermissive]
return T(PyUnicode_AsUTF8(obj));
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:261:50: 错误:‘_PyType_Name’的实参不依赖模板参数,所以‘_PyType_Name’的声明必须可用 [-fpermissive]
return T(_PyType_Name((PyTypeObject )obj));
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:265:40: 错误:‘PyUnicode_AsUTF8’的实参不依赖模板参数,所以‘PyUnicode_AsUTF8’的声明必须可用 [-fpermissive]
return T(PyUnicode_AsUTF8(t.obj));
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:269:48: 错误:‘_PyType_Name’的实参不依赖模板参数,所以‘_PyType_Name’的声明必须可用 [-fpermissive]
return T(_PyType_Name((PyTypeObject )t.obj));
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在 lambda 函数中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:261:58: 错误:‘PyUnicode_AsUTF8’在此作用域中尚未声明
auto ks = PyUnicode_AsUTF8(ko);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在函数‘void jittor::pyjt_def_core(PyObject
)’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:312:5: 错误:‘METH_FASTCALL’在此作用域中尚未声明
METH_FASTCALL | METH_KEYWORDS,
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在 lambda 函数中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:332:64: 错误:‘PyUnicode_AsUTF8’在此作用域中尚未声明
const char
arg1 = PyUnicode_AsUTF8(args[1]);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在 lambda 函数中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:547:58: 错误:‘PyUnicode_AsUTF8’在此作用域中尚未声明
auto ks = PyUnicode_AsUTF8(ko);
^
In file included from /usr/local/python/lib/python3.11/site-packages/jittor/src/common.h:10:0,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/cache_compile.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:7:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在函数‘void jittor::pyjt_def_core(PyObject*)’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:589:41: 错误:‘PyModule_AddFunctions’在此作用域中尚未声明
ASSERT(PyModule_AddFunctions(m, defs)==0);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/log.h:177:7: 附注:in definition of macro ‘_LOG_IF’
!(cond) ? (void) 0 : _LOG(level, v)
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/log.h:173:5: 附注:in expansion of macro ‘LOG_IF’
LOG_IF(f, PREDICT_BRANCH_NOT_TAKEN(!(cond)))
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/log.h:173:15: 附注:in expansion of macro ‘PREDICT_BRANCH_NOT_TAKEN’
LOG_IF(f, PREDICT_BRANCH_NOT_TAKEN(!(cond)))
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/log.h:267:19: 附注:in expansion of macro ‘CHECK’
#define ASSERT(s) CHECK(s) << “Something wrong… Could you please report this issue?\n”
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:589:5: 附注:in expansion of macro ‘ASSERT’
ASSERT(PyModule_AddFunctions(m, defs)==0);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在全局域:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:595:25: 错误:变量或字段‘init_module’声明为 void
static void init_module(PyModuleDef* mdef, PyObject* m) {
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:595:25: 错误:‘PyModuleDef’在此作用域中尚未声明
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:595:38: 错误:‘mdef’在此作用域中尚未声明
static void init_module(PyModuleDef* mdef, PyObject* m) {
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:595:52: 错误:expected primary-expression before ‘’ token
static void init_module(PyModuleDef
mdef, PyObject* m) {
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:595:54: 错误:‘m’在此作用域中尚未声明
static void init_module(PyModuleDef* mdef, PyObject* m) {
^
In file included from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:11:0,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在函数‘void PyInit_jit_utils_core()’中:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:67:9: 错误:‘PyModuleDef’在此作用域中尚未声明
PyModuleDef def = new PyModuleDef();
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:67:22: 错误:‘def’在此作用域中尚未声明
PyModuleDef def = new PyModuleDef();
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:67:32: 错误:expected type-specifier before ‘PyModuleDef’
PyModuleDef def = new PyModuleDef();
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:73:59: 错误:‘PyModule_Create’在此作用域中尚未声明
jittor::PyObjHolder holder(m = PyModule_Create(def));
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:74:27: 错误:‘init_module’在此作用域中尚未声明
init_module(def, m);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:78:16: 错误:在返回‘void’的函数中,返回语句带返回值 [-fpermissive]
return nullptr;
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:80:12: 错误:在返回‘void’的函数中,返回语句带返回值 [-fpermissive]
return m;
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:599:1: 附注:in expansion of macro ‘PYJT_MODULE_INIT’
PYJT_MODULE_INIT(jit_utils_core);
^
In file included from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:0:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h: In instantiation of ‘typename std::enable_if<std::is_same<T, std::__cxx11::basic_string >::value, std::__cxx11::basic_string >::type jittor::from_py_object(PyObject
) [with T = std::__cxx11::basic_string; typename std::enable_if<std::is_same<T, std::__cxx11::basic_string >::value, std::__cxx11::basic_string >::type = std::__cxx11::basic_string; PyObject = _object]’:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:235:65: required from here
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:48:44: 错误:‘PyUnicode_AsUTF8AndSize’在此作用域中尚未声明
const char
s = PyUnicode_AsUTF8AndSize(obj, &size);
^
In file included from /usr/include/python2.7/Python.h:87:0,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_obj_holder.h:8,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:11,
from /usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:8:
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h: In instantiation of ‘typename std::enable_if<std::is_same<T, bool>::value, _object
>::type jittor::to_py_object(const T&) [with T = bool; typename std::enable_if<std::is_same<T, bool>::value, _object*>::type = _object*]’:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:300:88: required from here
/usr/include/python2.7/boolobject.h:24:46: 警告:提领类型双关的指针将破坏强重叠规则 [-Wstrict-aliasing]
#define Py_True ((PyObject ) &_Py_TrueStruct)
^
/usr/include/python2.7/boolobject.h:27:51: 附注:in expansion of macro ‘Py_True’
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:59:12: 附注:in expansion of macro ‘Py_RETURN_TRUE’
if (a) Py_RETURN_TRUE;
^
/usr/include/python2.7/boolobject.h:23:47: 警告:提领类型双关的指针将破坏强重叠规则 [-Wstrict-aliasing]
#define Py_False ((PyObject ) &_Py_ZeroStruct)
^
/usr/include/python2.7/boolobject.h:28:53: 附注:in expansion of macro ‘Py_False’
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/pyjt/py_converter.h:60:5: 附注:in expansion of macro ‘Py_RETURN_FALSE’
Py_RETURN_FALSE;
^
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc: 在全局域:
/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc:222:13: 警告:‘void jittor::pyjt_def_core(PyObject
)’定义后未使用 [-Wunused-function]
static void pyjt_def_core(PyObject
m) {
^
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/python/lib/python3.11/site-packages/jtorch/init.py”, line 4, in
import jittor as jt
File “/usr/local/python/lib/python3.11/site-packages/jittor/init.py”, line 18, in
from . import compiler
File “/usr/local/python/lib/python3.11/site-packages/jittor/compiler.py”, line 1189, in
check_cache_compile()
File “/usr/local/python/lib/python3.11/site-packages/jittor/compiler.py”, line 884, in check_cache_compile
recompile = compile(cc_path, cc_flags+f" {opt_flags} “, files, jit_utils.cache_path+‘/jit_utils_core’+extension_suffix, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/python/lib/python3.11/site-packages/jittor/compiler.py”, line 126, in compile
return do_compile(fix_cl_flags(cmd))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/python/lib/python3.11/site-packages/jittor/compiler.py”, line 91, in do_compile
run_cmd(cmd)
File “/usr/local/python/lib/python3.11/site-packages/jittor_utils/init.py”, line 188, in run_cmd
raise Exception(err_msg)
Exception: Run cmd failed: “/usr/local/gcc-5.4.0/bin/g++” “/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/cache_compile.cc” “/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/log.cc” “/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/tracer.cc” “/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/jit_utils.cc” “/usr/local/python/lib/python3.11/site-packages/jittor/src/utils/str_utils.cc” -Wall -Wno-unknown-pragmas -std=c++14 -fPIC -march=native -fdiagnostics-color=always -lstdc++ -ldl -shared -I”/usr/local/python/lib/python3.11/site-packages/jittor/src" -I/usr/include/python2.7 -I/usr/include/python2.7 -O2 -o “/root/.cache/jittor/jt1.3.7/g++5.4.0/py3.11.3/Linux-3.10.0-9x58/IntelRXeonRCPUxfe/default/jit_utils_core.so”

python版本为3.11.3, 在python控制台import jtorch也报类似的错误。
建议提供1个可以运行的docker 镜像,相关依赖都包含, 安装过程中中问题还是不少的,比如python 版本,源码安装, gcc版本要求等。

由于使用安装镜像报ssl Module available ,换了清华的镜像安装
pip install -r requirements.txt -i Simple Index
不知道是否与镜像源有关系, 阿里云的镜像也试了,一样的问题。