This code will produce a segmentation fault if is torch is imported
from skimage.data import astronaut
from matplotlib import pyplot as plt
import torch

f = plt.figure()
plt.imshow(astronaut())
f.savefig('0.pdf')

If you comment out import torch it will work fine.
If you change the extension to PNG, it will also work fine.
I have no idea what’s going on.