Kernel keeps dying when plotting a graph after importing the torch library
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 &quot;Dead kernel&quot; 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.

import os
os.environ[&quot;KMP_DUPLICATE_LIB_OK&quot;]=&quot;TRUE&quot;

Run this first, then it'll resolve your problem. Although I guess, it is a temporary solution you can refer to this link: https://www.programmersought.com/article/53286415201/
