利用Pyinstaller打包后死锁

我尝试将我训练好的模型用Qt窗口写一个demo,但是用Pyinstaller对代码进行打包成exe文件时,代码运行到下面的分割线位置就会卡住不动。
[i 1224 20:58:09.204000 80 compiler.pyc:944] Jittor(1.3.1.27) src: c:\users\neo\desktop\zipit\dist\inf\jittor
[i 1224 20:58:09.239000 80 compiler.pyc:945] cl at C:\Users\Neo.cache\jittor\msvc\VC_____\bin\cl.exe(19.29.30133)
[i 1224 20:Neo:09.243000 80 compiler.pyc:946] cache_path: C:\Users\Neo.cache\jittor\jt1.3.1\cl\py3.8.12\Windows-10-10.xd2\AMDRyzen74800Ux89\default
[i 1224 20:58:09.372000 80 __init__.pyc:365] Found gdb(8.1) at D:\Softwares\minGW64\mingw64\bin\gdb.EXE.
[i 1224 20:58:09.415000 80 __init__.pyc:365] Found addr2line(2.30) at D:\Softwares\minGW64\mingw64\bin\addr2line.EXE.
[i 1224 20:58:09.421000 80 __init__.pyc:187] Total mem: 15.37GB, using 5 procs for compiling.
------------------------------------------------------分割线------------------------------------------------------
没有办法,我只能按下Ctrl+C暂停,然后模型则会显示如下的trace back。

Caught SIGNAL 2, quick exitTraceback (most recent call last):
File “inf.py”, line 1, in
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked

File “”, line 671, in load_unlocked
(pack_model) C:\Users\Neo\Desktop\zipit\dist\inf> File “PyInstaller\loader\pyimod03_importers.py”, line 476, in exec_module
File "jittor_init
.py", line 14, in
File “jittor_utils\lock.py”, line 60, in enter
File “jittor_utils\lock.py”, line 28, in lock
KeyboardInterrupt

我的环境是Win64 on AMD R7-4800U,我并不知道是什么原因引发了这个问题,希望得到开发者的帮助,万分感谢。

同学你好,这是因为jittor有一个全局文件锁,防止多个jittor进程同时启动时产生竞争冒险,卡死的原因可能是程序不正常退出导致的死锁,有两种解决方案:

  1. 你可以更新到最新版本1.3.1.30,然后设置环境变量disable_lock=1(在python代码的第一行import os; os.environ[“disable_lock”]=“1”,必须是在最开始,import jittor之前)直接吧锁关掉,
  2. 或者尝试手动清除文件锁,文件锁的位置在~/.cache/jittor下,文件名为jittor.lock

后续有问题欢迎随时联系