Why the spyder is showing error message Restarting kernel

I am not getting why the spyder is showing error message
Restarting kernel...

every time I am executing the code. Previously it was working fine. I just change the dataset (bigger one) on sam code.

Can anyone guide its urgent!

Regards

Maybe the process is running out of (host) memory, is killed by the OS, and Spyder needs to restart the kernel. Run the script in a terminal and check if you are seeing a better error message.

Sir @ptrblck on terminal it is saying

killed

what to do?

killed is usually reported if the process receives a SIGKILL so I would guess you are running out of memory and the OS kills it.
Check the host RAM usage during the process and verify that it’s indeed the root cause. If so, reduce the memory usage or alternatively increase your swap (this will however slow down your system once the swap is used).

sir @ptrblck what do mean by swap?
sorry but please explain. whether reducting the batch size in training will help?

Regards

This article explains the swap file in detail. In short: you can offload data to the swap file (located on your SSD/HDD) if you are running out of RAM.

Yes, reducing the batch size would help in case you are running out of memory.

I don’t think I can do this for my near work. Sir, I have purchased a new SSD for my desktop, But I think that won’t help either, This is a matter of RAM :frowning:

Hi I am a new to this forum and Pytorch. I thought I might share the following.

I prefer to run my code in spyder on a mac but was unable to get the basic tutorial code to run.

import torch

brought about a kernel restart and I simply couldn’t figure out why.

I did however manage to run a pared down version of the code in a terminal.

import torch
from torch import nn
from torch.utils.data import DataLoader
from torchvision import datasets
from torchvision.transforms import ToTensor

Download training data from open datasets.

training_data = datasets.FashionMNIST(
root=“data”,
train=True,
download=True,
transform=ToTensor(),
)

This code created the necessary folders and download the gz file and uncompressed them.

Next I decided to test out the code in VS.

This works a treat but now it started complaining when it hit this set of commands

training_data = datasets.FashionMNIST(
root=‘/Users/me/Desktop/torch-stuff/data’,
train=True,
download=False,
transform=ToTensor(),
)

It gave me an [Errno 1] message which I figured was something to do with permissions.

To overcome this and after a considerable amount of searching I found the work around is to give VS Full Disk Access via the Security and Privacy settings.

I really dont know why the code would not run and still dont understand the kernel problems in sypder but the VS code works just fine.

I trust that this is of help for others who have experienced the same issues.

Philip.