Why the spyder is showing error message Restarting kernel

username: hema_rathore
cooked: <p>I am not getting why the spyder is showing error message<br>
<code>Restarting kernel...</code></p>
<p>every time I am executing the code. Previously it was working fine. I just change the dataset (bigger one) on sam code.</p>
<p>Can anyone guide its urgent!</p>
<p>Regards</p>

username: ptrblck
cooked: <p>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.</p>

username: hema_rathore
cooked: <p>Sir <a class="mention" href="/u/ptrblck">@ptrblck</a> on terminal it is saying</p>
<p><code>killed</code></p>
<p>what to do?</p>

username: ptrblck
cooked: <p><code>killed</code> is usually reported if the process receives a <code>SIGKILL</code> so I would guess you are running out of memory and the OS kills it.<br>
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).</p>

username: hema_rathore
cooked: <p>sir <a class="mention" href="/u/ptrblck">@ptrblck</a> what do mean by swap?<br>
sorry but please explain. whether reducting the batch size in training will help?</p>
<p>Regards</p>

username: ptrblck
cooked: <p><a href="https://www.linux.com/news/all-about-linux-swap-space/">This article</a> 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.</p>
<p>Yes, reducing the batch size would help in case you are running out of memory.</p>

username: hema_rathore
cooked: <p>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 <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=10" title=":frowning:" class="emoji" alt=":frowning:"></p>

username: Philip_Quinlan
cooked: <p>Hi I am a new to this forum and Pytorch. I thought I might share the following.</p>
<p>I prefer to run my code in spyder on a mac but was unable to get the basic tutorial code to run.</p>
<p>import torch</p>
<p>brought about a kernel restart and I simply couldn’t figure out why.</p>
<p>I did however manage to run a pared down version of the code in a terminal.</p>
<p>import torch<br>
from torch import nn<br>
from torch.utils.data import DataLoader<br>
from torchvision import datasets<br>
from torchvision.transforms import ToTensor</p>
<h1>
<a name="download-training-data-from-open-datasets-1" class="anchor" href="#download-training-data-from-open-datasets-1"></a>Download training data from open datasets.</h1>
<p>training_data = datasets.FashionMNIST(<br>
root=“data”,<br>
train=True,<br>
download=True,<br>
transform=ToTensor(),<br>
)</p>
<p>This code created the necessary folders and download the gz file and uncompressed them.</p>
<p>Next I decided to test out the code in VS.</p>
<p>This works a treat but now it started complaining when it hit this set of commands</p>
<p>training_data = datasets.FashionMNIST(<br>
root=‘/Users/me/Desktop/torch-stuff/data’,<br>
train=True,<br>
download=False,<br>
transform=ToTensor(),<br>
)</p>
<p>It gave me an [Errno 1] message which I figured was something to do with permissions.</p>
<p>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.</p>
<p>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.</p>
<p>I trust that this is of help for others who have experienced the same issues.</p>
<p>Philip.</p>