42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""PyInstaller hook: 避免 collect_submodules('torch') 在 isolated 子进程中 access violation 崩溃。
|
|
|
|
PyInstaller 默认 hook-torch.py 调用 collect_submodules('torch') 遍历全部子模块,
|
|
在 torch 2.5+ 的 isolated 子进程中会触发 0xC0000005 access violation。
|
|
本 hook 直接列出实际需要的 torch 子模块,完全避开 collect_submodules。
|
|
"""
|
|
# 只列出 bot 实际引用的 torch 子模块(通过 import 分析确认)
|
|
hiddenimports = [
|
|
'torch',
|
|
'torch.nn',
|
|
'torch.nn.functional',
|
|
'torch.nn.modules',
|
|
'torch.nn.modules.activation',
|
|
'torch.nn.modules.conv',
|
|
'torch.nn.modules.linear',
|
|
'torch.nn.modules.module',
|
|
'torch.nn.modules.normalization',
|
|
'torch.nn.modules.padding',
|
|
'torch.nn.modules.pooling',
|
|
'torch.nn.modules.rnn',
|
|
'torch.nn.modules.sparse',
|
|
'torch.nn.modules.dropout',
|
|
'torch.nn.modules.batchnorm',
|
|
'torch.nn.modules.loss',
|
|
'torch.nn.modules.container',
|
|
'torch.nn.modules.flatten',
|
|
'torch.nn.modules.pixelshuffle',
|
|
'torch.nn.modules.upsampling',
|
|
'torch.nn.modules.channelshuffle',
|
|
'torch.cuda',
|
|
'torch.cuda.amp',
|
|
'torch.tensor',
|
|
'torch._C',
|
|
'torch._utils',
|
|
'torch.storage',
|
|
'torch.serialization',
|
|
'torch.types',
|
|
'torch.classes',
|
|
'torch.backends',
|
|
'torch.backends.cudnn',
|
|
]
|