这两天发现开发环境坏了,查看原因,发现是import torch出现段错误。
python -c "import torch" Segmentation fault (core dumped)
调试出现如下信息
gdb python
(gdb) r -c "import torch"
Starting program: /home/username/.local/bin/python -c "import torch"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
type_qualname (type=0x555558790100, context=0x0) at Objects/typeobject.c:479
479 Objects/typeobject.c: No such file or directory.
(gdb) bt
#0 type_qualname (type=0x555558790100, context=0x0) at Objects/typeobject.c:479
#1 0x000055555562bae2 in type_getattro (type=0x555558790100, name=0x7ffff6ff02b0) at Objects/typeobject.c:3401
#2 0x000055555560477b in PyObject_GetAttrString (name=<optimized out>, v=0x555558790100) at Objects/object.c:795
解决:
不要把libtorch库的路径添加到LD_LIBRARY_PATH ,
用命令清除: unset LD_LIBRARY_PATH
在文件.bashrc .profile /etc/profile 里查看是否清除。