Kernel keeps dying when plotting a graph after importing the torch library

Viewed 2657

I'm trying to run the following code:

import matplotlib.pyplot as plt
%matplotlib inline
import torch

x = y = torch.tensor([1,2,3]).numpy()
plt.plot(x,y);

I keep getting the message: The kernel appears to have died. It will restart automatically. and a restart and a red "Dead kernel" tag on the toolbar.

But the weird thing is, if I import matplotlib.pyplot and plot some random graph first, the above code plots just fine. In other words, the following code works fine.

import matplotlib.pyplot as plt
%matplotlib inline

plt.subplots(figsize=(0.01,0.01))
plt.gca().set_visible(False);

import torch
x = torch.tensor([1,2,3]).numpy()

plt.plot(x,x);

What is going on here? I'm using numpy 1.18.5, pytorch 1.6.0, matplotlib 3.2.2 on Python 3.7.7, if it matters. Thank you.

2 Answers

I followed the link above and deleted a couple of duplicate .dll's in Torch. Now everything runs fine

Related