3

I have a strange problem with Pytorch. When I use torch functions with tensors like tensor.reshape or torch.transpose, I don't have any problems; even when I created networks, it's ok. However, when I want to train network my jupyter crashed.

crashed

I find where error is but I don't know why it is there and how to fix it.

errors

I installed pytorch using conda. I have Ubuntu 18.04. I don't have cuda.

cottontail
  • 10,268
  • 18
  • 50
  • 51
Elvar G
  • 47
  • 1
  • 1
  • 4

4 Answers4

4

The hint for the solution is available, via the Jupyter notebook terminal (if opened it directly and not via the anaconda interface), where a more proper error code appears

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program....

which then leads to a working solution here sklearn OMP: Error #15 when fitting models

Guy Louzon
  • 1,175
  • 9
  • 19
3

If you are on Ubuntu you may not install PyTorch just via conda.

It can be:

  • Conda
  • Pip
  • LibTorch
  • From Source

So you have multiple options.

Go to this page and select Cuda to NONE, LINUX, stable 1.1, CONDA.

conda install pytorch-cpu torchvision-cpu -c pytorch

If you have problems still, you may try also install PIP way.

pip3 install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-linux_x86_64.whl
pip3 install https://download.pytorch.org/whl/cpu/torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl

Hopefully some of these ways will work.

prosti
  • 42,291
  • 14
  • 186
  • 151
1

Simple Solution

I have solved this problem by reinstalling the torchvision, as this was the only library that was creating an issue, whenever i import that

Just reinstall that:

Directly in Jupyter notebook:

!pip3 uninstall -y torch torchvision
!pip3 install torch torchvision

or in Terminal:

pip3 uninstall -y torch torchvision
pip3 install torch torchvision
Deepanshu Mehta
  • 1,119
  • 12
  • 9
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