1

To make it simple, I am following this tutorial provided by PyTorch to create a CNN.

However, it appears that when I'm running this particular code block with this respective line:

# show images
imshow(torchvision.utils.make_grid(images))

It somehow kills the kernel. Which confuses me because it is only a simple function.

I have also went through numerous SO posts that are related to PyTorch but all of them are not related to torchvision. The most similar issue I found was posted 5 months ago without answer.

Please let me know if I need to add on any information to make this question clearer.

seraph
  • 320
  • 2
  • 15

2 Answers2

3

The same thing happened to me. Running these commands in the python interpreter, I got an error that lead me to this:

Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized

when I added the following, it worked:

import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
0

I had sort of the same issue (on a macos 12.6.2). A kernel crash when using torchvision.

trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                        download=True, transform=transform)   
testset = torchvision.datasets.CIFAR10(root='./data', train=False,
                                       download=True, transform=transform)

classes = ('plane', 'car', 'bird', 'cat',
           'deer', 'dog', 'frog', 'horse', 'ship', 'truck')

batch_size = 64
trainloader = th.utils.data.DataLoader(trainset, batch_size=batch_size,
                                          shuffle=True, num_workers=0)
testloader = th.utils.data.DataLoader(testset, batch_size=batch_size,
                                         shuffle=False, num_workers=0)
dataiter = iter(trainloader)
images, labels = next(dataiter)

I solved it by reinstalling pytorch and torchvision. Run in a script (jupyter notebook or elsewhere):

!conda install --yes pytorch torchvision -c pytorch
user1885349
  • 372
  • 1
  • 2
  • 10