'How to fix 'The kernel appears to have died. It will restart automatically" caused by pytorch

I have a strange problem with Pytorch. When i use something torch functions with tensors like tensor.rehsape or torch.transpose, i don't have problem and all ok, even when i've created network all ok, but when i wanna train network my jupyter crashed.

crashed.

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

errors

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



Solution 1:[1]

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

Solution 2:[2]

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.

Solution 3:[3]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guy Louzon
Solution 2 prosti
Solution 3 Deepanshu Mehta