Kernel have died it will restart automatically

username: 111336
cooked: <p>Hi there, when i was training the neural network the system shows this below is my code</p>
<p>depth=[4,8]<br>
class ConvNet(nn.Module):<br>
def <strong>init</strong>(self):<br>
super(ConvNet,self).<strong>init</strong>()<br>
self.conv1=nn.Conv2d(1,4,5,padding=2)<br>
self.pool=nn.MaxPool2d(2,2)<br>
<span class="hashtag">#No2</span>.Convolution<br>
self.conv2=nn.Conv2d(depth[0],depth[1],5,padding=2)<br>
self.fc1=nn.Linear(image_size//4<em>image_size//4</em>depth[1],512)<span class="hashtag">#int</span> division<br>
self.fc2=nn.Linear(512,num_classes)<br>
def forward(self,x):<br>
x=self.conv1(x)<br>
x=F.relu(x)<br>
x=self.pool(x)<br>
x=self.conv2(x)<br>
x=F.relu(x)<br>
x=self.pool(x)<br>
x=x.view(-1,image_size//4<em>image_size//4</em>depth[1])<br>
x=F.relu(self.fc1(x))<br>
x=F.dropout(x,training=self.training)<br>
x=self.fc2(x)<br>
x=F.log_softmax(x,dim=1)<br>
return x<br>
def retreive_features(self,x):<span class="hashtag">#get_features</span> maps<br>
features_map1=F.relu(self.conv1(x))<br>
x=self.pool(feature_map1)<br>
features_map2=F.relu(self.conv2(x))<br>
return (features_map1,features_map2)</p>
<p>criterion=nn.CrossEntropyLoss()<br>
optimizer=optim.SGD(net.parameters(),lr=0.001,momentum=0.9)<br>
record=[]<br>
weights=[]<br>
for epoch in range(num_epochs):<br>
#train_rights=[]<br>
for batch_idx,(data,target) in enumerate(train_loader):<br>
data,target=Variable(data).cuda(),Variable(target).cuda()<span class="hashtag">#change</span> Tensor to Variable<br>
net.train()<br>
output=net(data)<br>
loss=criterion(output,target)<span class="hashtag">#calculate</span> loss<br>
optimizer.zero_grad()<br>
loss.backward()<br>
optimizer.step()<br>
if batch_idx%100==0:<br>
net.eval()<br>
#val_rights=[]<br>
print(loss)<br>
for (data,target) in validation_loader:<br>
data,target=Variable(data).cuda(),Variable(target).cuda()<br>
output=net(data)</p>
<p>My TEMP MEMEORY is 16GB it rises from 4.8 to 7.3 then it shows the message-&gt;kernel have died<br>
it will restart automatically ,how can i do?<br>
PS:my init has underline so don’t worry</p>

username: ptrblck
cooked: <p>Could you run the code in a terminal, as this should give you a proper error message?</p>

username: 111336
cooked: <p>er…no… Also i run on pycharm same problem so i don’t know why…Is this pytoch’s problem?</p>

username: ptrblck
cooked: <p>Hard to tell without a proper error message.<br>
So far it seems your IPython kernel dies, so it might be related to PyTorch.</p>

username: 111336
cooked: <p>I wonder why torch has some problem that it can’t solve</p>

username: ptrblck
cooked: <p>It’s not necessarily a PyTorch issue, since the Jupyter kernel might die without printing a proper error message due to other issues in the code.<br>
Since you cannot run the code in a terminal to get a proper error message, I would recommend to remove code snippets until you can properly isolate the kernel restart to a small code snippet.</p>

username: Calimero
cooked: <p>I had a similar issue using Conv2d with PyTorch 1.1 (which I had to use due to compatibility with an old GPU), it disappeared when I used a more recent version of PyTorch.</p>
<p>I know this is not a very specific response, but maybe it helps anyway.</p>