I am trying to run neural network inference by calling a Python script, but the process crashes. After narrowing the issue down, it appears that the crash happens whenever a layer is added to a PyTorch model.
import qtm
import torch.nn as nn
class SingleEventModel(nn.Module):
def __init__(self):
super().__init__()
self.fc = nn.Linear(18,128) # if I comment this line, it does not crash
def test_model():
m = SingleEventModel()
print(m)
def add_menu():
"""Function for adding custom commands and setting up the menu in QTM"""
qtm.gui.add_command("test_model")
qtm.gui.set_command_execute_function("test_model", test_model)
# Add menu and button
menu_id = qtm.gui.insert_menu_submenu(None, "My menu")
qtm.gui.insert_menu_button(menu_id, "test_model", "test_model")
if __name__ == "__main__":
clear() # qtm terminal clear
add_menu()
Pressing test_model button crashes the application.

The same code runs correctly when executed directly in a terminal.

OS: Windows 11
Pip list:

I tried several solutions from ChatGPT like:
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
Didn't help.
Any guidance on what might cause a crash and how to avoid it?
I am trying to run neural network inference by calling a Python script, but the process crashes. After narrowing the issue down, it appears that the crash happens whenever a layer is added to a PyTorch model.
Pressing test_model button crashes the application.

The same code runs correctly when executed directly in a terminal.

OS: Windows 11

Pip list:
I tried several solutions from ChatGPT like:
Didn't help.
Any guidance on what might cause a crash and how to avoid it?