M1 pytorch jupyter notebook kernel dead

Hey guys, I running alexnet on my macbook pro m1 I have a issue with this error.


[I 12:52:49.616 NotebookApp] Starting buffering for 7919a2ac-1921-469f-838c-71c37fa7b337:71ee38e5-509c-4bb0-a69c-ae46406b8456
[I 12:52:49.623 NotebookApp] Restoring connection for 7919a2ac-1921-469f-838c-71c37fa7b337:71ee38e5-509c-4bb0-a69c-ae46406b8456
info 12:53:35.239: Restart kernel execution
info 12:53:35.239: Restart requested file:///Users/bahk_insung/Documents/Github/torch-study/conv1d.ipynb
info 12:53:35.239: Restarting 7919a2ac-1921-469f-838c-71c37fa7b337
[I 12:53:35.242 NotebookApp] Creating new notebook in 
info 12:53:35.249: installMissingDependencies /Users/bahk_insung/miniconda3/bin/python, ui.disabled=false for resource '/Users/bahk_insung/Documents/Github/torch-study/conv1d.ipynb'
info 12:53:35.250: Got env vars with python /Users/bahk_insung/miniconda3/bin/python, with env var count 67 and custom env var count 63 in 1ms
info 12:53:35.252: Process Execution: > ~/miniconda3/bin/python -c "import ipykernel"
> ~/miniconda3/bin/python -c "import ipykernel"
info 12:53:35.418: Spec argv[0] updated from '/Users/bahk_insung/miniconda3/bin/python' to '/Users/bahk_insung/miniconda3/bin/python'
info 12:53:35.419: Got env vars with python /Users/bahk_insung/miniconda3/bin/python, with env var count 67 and custom env var count 63 in 1ms
[I 12:53:35.446 NotebookApp] Kernel started: 707c1d61-5656-4eed-afaa-0e1f46b25298, name: pythonjvsc74a57bd0cbd03b52000256fffc5622fb1d5afa03ae770321afbfaac74e08013d54c137c2
[W 12:53:35.458 NotebookApp] delete /conv1d-jvsc-b30b9bca-0e40-410d-88a2-1396d6efd81457160c03-a7a1-4995-9268-10657842773d.ipynb
info 12:53:36.045: Got new session 707c1d61-5656-4eed-afaa-0e1f46b25298
info 12:53:36.045: Started new restart session
[I 12:53:36.049 NotebookApp] Kernel shutdown: 7919a2ac-1921-469f-838c-71c37fa7b337
info 12:53:36.073: UpdateWorkingDirectoryAndPath in Kernel
[I 12:53:41.434 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
error 12:53:41.437: Error in waiting for cell to complete Error: Canceled future for execute_request message before replies were done
    at t.KernelShellFutureHandler.dispose (/Users/bahk_insung/.vscode/extensions/ms-toolsai.jupyter-2022.11.1003412109/out/extension.node.js:2:32353)
    at /Users/bahk_insung/.vscode/extensions/ms-toolsai.jupyter-2022.11.1003412109/out/extension.node.js:2:26572
    at Map.forEach (<anonymous>)
    at v._clearKernelState (/Users/bahk_insung/.vscode/extensions/ms-toolsai.jupyter-2022.11.1003412109/out/extension.node.js:2:26557)
    at /Users/bahk_insung/.vscode/extensions/ms-toolsai.jupyter-2022.11.1003412109/out/extension.node.js:2:29000
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
warn 12:53:41.437: Cell completed with errors {
  message: 'Canceled future for execute_request message before replies were done'
}
info 12:53:41.437: Cancel all remaining cells true || Error || undefined
[I 12:53:41.437 NotebookApp] Starting buffering for 707c1d61-5656-4eed-afaa-0e1f46b25298:439c0a18-ff80-4866-a6c0-166d700928b3
[I 12:53:41.445 NotebookApp] Restoring connection for 707c1d61-5656-4eed-afaa-0e1f46b25298:439c0a18-ff80-4866-a6c0-166d700928b3

and here the codes.

criterion = nn.CrossEntropyLoss()
alexnet = AlexNet().to(device)
optimizer = optim.Adam(alexnet.parameters(), lr=1e-3)

loss = list()
n = len(trainloader)

for epoch in range(50):
    running_loss = 0.0
    for data in trainloader:
        inputs, labels = data[0].to(device), data[1].to(device)

        # Forward
        optimizer.zero_grad()
        outputs = alexnet(inputs)
        loss = criterion(outputs, labels)

        # Backward
        loss.backward()
        optimizer.step()
        
        running_loss += loss.item()
    
    loss.append(running_loss / n)
    print(f"{epoch + 1} loss : {running_loss / len(trainloader)}")

I installed pytorch by conda, pytorch version is ‘1.13.1’.
Please let me know, anyone who know how to fix it. Thanks you.