The kernel appears to have died. It will restart automatically

username: Aiman_Mutasem-bellh
cooked: <p>I facing a common problem when loading pre-training model using PyTorch. Jupyter notebook is crashing “The kernel appears to have died. It will restart automatically”</p>
<p>I have followed the discussion <a href="https://github.com/jupyter/notebook/issues/2784" rel="noopener nofollow ugc">link</a>, <a href="https://github.com/tensorflow/tensorflow/issues/9829" rel="noopener nofollow ugc">link</a>, and <a href="https://stackoverflow.com/questions/47022997/jupyter-the-kernel-appears-to-have-died-it-will-restart-automatically" rel="noopener nofollow ugc">link</a> but not fix, any suggestions?</p>
<p>The environment specifications as follows:</p>
<p>OS : CentOS Linux release 7.8.2003 (Core)<br>
Python : Python 3.6.12 :: Anaconda, Inc.<br>
Conda version : conda 4.5.4</p>
<p>Available resources:<br>
ibm-game-center         Thu Nov 12 14:19:05 2020  410.48<br>
[0] GeForce RTX 2080 Ti | 46’C,   0 % |    10 / 10989 MB |<br>
[1] GeForce RTX 2080 Ti | 49’C,   0 % |    10 / 10989 MB |</p>
<p>Conda list :</p>
<h1>packages in environment at /home/aiman/anaconda3:</h1>
<h1></h1>
<h1>Name                    Version                   Build  Channel</h1>
<p>_ipyw_jlab_nb_ext_conf    0.1.0            py36he11e457_0<br>
_libgcc_mutex             0.1                        main<br>
alabaster                 0.7.10           py36h306e16b_0<br>
anaconda                  5.2.0                    py36_3<br>
anaconda-client           1.6.14                   py36_0<br>
anaconda-navigator        1.8.7                    py36_0<br>
anaconda-project          0.8.2            py36h44fb852_0<br>
asn1crypto                0.24.0                   py36_0<br>
astroid                   1.6.3                    py36_0<br>
astropy                   3.0.2            py36h3010b51_1<br>
attrs                     18.1.0                   py36_0<br>
babel                     2.5.3                    py36_0<br>
backcall                  0.1.0                    py36_0<br>
backports                 1.0              py36hfa02d7e_1<br>
backports.shutil_get_terminal_size 1.0.0            py36hfea85ff_2<br>
beautifulsoup4            4.6.0            py36h49b8c8c_1<br>
bitarray                  0.8.1            py36h14c3975_1<br>
bkcharts                  0.2              py36h735825a_0<br>
blas                      1.0                    openblas<br>
blaze                     0.11.3           py36h4e06776_0<br>
bleach                    2.1.3                    py36_0<br>
blosc                     1.14.3               hdbcaa40_0<br>
bokeh                     0.12.16                  py36_0<br>
boto                      2.48.0           py36h6e4cd66_1<br>
bottleneck                1.2.1            py36haac1ea0_0<br>
bzip2                     1.0.6                h14c3975_5<br>
ca-certificates           2020.10.14                    0<br>
cairo                     1.14.12              h7636065_2<br>
certifi                   2020.6.20          pyhd3eb1b0_3<br>
cffi                      1.11.5           py36h9745a5d_0<br>
chardet                   3.0.4            py36h0f667ec_1<br>
click                     6.7              py36h5253387_0<br>
cloudpickle               0.5.3                    py36_0<br>
clyent                    1.2.2            py36h7e57e65_1<br>
colorama                  0.3.9            py36h489cec4_0<br>
conda                     4.5.4                    py36_0<br>
conda-build               3.10.5                   py36_0<br>
conda-env                 2.6.0                         1<br>
conda-verify              2.0.0            py36h98955d8_0<br>
contextlib2               0.5.5            py36h6c84a62_0<br>
cpuonly                   1.0                           0    pytorch<br>
cryptography              2.2.2            py36h14c3975_0<br>
curl                      7.60.0               h84994c4_0<br>
cycler                    0.10.0           py36h93f1223_0<br>
cython                    0.28.2           py36h14c3975_0<br>
cytoolz                   0.9.0.1          py36h14c3975_0<br>
dask                      0.17.5                   py36_0<br>
dask-core                 0.17.5                   py36_0<br>
datashape                 0.5.4            py36h3ad6b5c_0<br>
dbus                      1.13.2               h714fa37_1<br>
decorator                 4.3.0                    py36_0<br>
distributed               1.21.8                   py36_0<br>
docutils                  0.14             py36hb0f60f5_0<br>
entrypoints               0.2.3            py36h1aec115_2<br>
et_xmlfile                1.0.1            py36hd6bccc3_0<br>
expat                     2.2.5                he0dffb1_0<br>
fastcache                 1.0.2            py36h14c3975_2<br>
filelock                  3.0.4                    py36_0<br>
flask                     1.0.2                    py36_1<br>
flask-cors                3.0.4                    py36_0<br>
fontconfig                2.12.6               h49f89f6_0<br>
freetype                  2.10.4               h5ab3b9f_0<br>
gensim                    3.8.3                     <br>
get_terminal_size         1.0.0                haa9412d_0<br>
gevent                    1.3.0            py36h14c3975_0<br>
glib                      2.56.1               h000015b_0<br>
glob2                     0.6              py36he249c77_0<br>
gmp                       6.1.2                h6c8ec71_1<br>
gmpy2                     2.0.8            py36hc8893dd_2<br>
graphite2                 1.3.11               h16798f4_2<br>
greenlet                  0.4.13           py36h14c3975_0<br>
gst-plugins-base          1.14.0               hbbd80ab_1<br>
gstreamer                 1.14.0               hb453b48_1<br>
h5py                      2.7.1            py36ha1f6525_2<br>
harfbuzz                  1.7.6                h5f0a787_1<br>
hdf5                      1.10.2               hba1933b_1<br>
heapdict                  1.0.0                    py36_2<br>
html5lib                  1.0.1            py36h2f9c1c0_0<br>
icu                       58.2                 h9c2bf20_1<br>
idna                      2.6              py36h82fb2a8_1<br>
imageio                   2.3.0                    py36_0<br>
imagesize                 1.0.0                    py36_0<br>
intel-openmp              2020.2                      254<br>
ipykernel                 4.8.2                    py36_0<br>
ipython                   6.4.0                    py36_0<br>
ipython_genutils          0.2.0            py36hb52b0d5_0<br>
ipywidgets                7.2.1                    py36_0<br>
isort                     4.3.4                    py36_0<br>
itsdangerous              0.24             py36h93cc618_1<br>
jbig                      2.1                  hdba287a_0<br>
jdcal                     1.4                      py36_0<br>
jedi                      0.12.0                   py36_1<br>
jinja2                    2.10             py36ha16c418_0<br>
jpeg                      9b                   h024ee3a_2<br>
jsonschema                2.6.0            py36h006f8b5_0<br>
jupyter                   1.0.0                    py36_4<br>
jupyter_client            5.2.3                    py36_0<br>
jupyter_console           5.2.0            py36he59e554_1<br>
jupyter_core              4.4.0            py36h7c827e3_0<br>
jupyterlab                0.32.1                   py36_0<br>
jupyterlab_launcher       0.10.5                   py36_0<br>
kiwisolver                1.0.1            py36h764f252_0<br>
lazy-object-proxy         1.3.1            py36h10fcdad_0<br>
lcms2                     2.11                 h396b838_0<br>
ld_impl_linux-64          2.33.1               h53a641e_7<br>
libcurl                   7.60.0               h1ad7b7a_0<br>
libedit                   3.1.20191231         h14c3975_1<br>
libffi                    3.3                  he6710b0_2<br>
libgcc-ng                 9.1.0                hdf63c60_0<br>
libgfortran               3.0.0                         1<br>
libgfortran-ng            8.2.0                hdf63c60_1<br>
libpng                    1.6.37               hbc83047_0<br>
libsodium                 1.0.16               h1bed415_0<br>
libssh2                   1.8.0                h9cfc8f7_4<br>
libstdcxx-ng              9.1.0                hdf63c60_0<br>
libtiff                   4.1.0                h2733197_1<br>
libtool                   2.4.6                h544aabb_3<br>
libxcb                    1.13                 h1bed415_1<br>
libxml2                   2.9.8                h26e45fe_1<br>
libxslt                   1.1.32               h1312cb7_0<br>
llvmlite                  0.23.1           py36hdbcaa40_0<br>
locket                    0.2.0            py36h787c0ad_1<br>
lxml                      4.2.1            py36h23eabaa_0<br>
lz4-c                     1.9.2                heb0550a_3<br>
lzo                       2.10                 h49e0be7_2<br>
markupsafe                1.0              py36hd9260cd_1<br>
matplotlib                2.2.2            py36h0e671d2_1<br>
mccabe                    0.6.1            py36h5ad9710_1<br>
mistune                   0.8.3            py36h14c3975_1<br>
mkl                       2020.2                      256<br>
mkl-service               1.1.2            py36h17a0993_4<br>
mkl_fft                   1.0.1            py36h3010b51_0<br>
mkl_random                1.0.1            py36h629b387_0<br>
more-itertools            4.1.0                    py36_0<br>
mpc                       1.0.3                hec55b23_5<br>
mpfr                      3.1.5                h11a74b3_2<br>
mpmath                    1.0.0            py36hfeacd6b_2<br>
msgpack-python            0.5.6            py36h6bb024c_0<br>
multipledispatch          0.5.0                    py36_0<br>
navigator-updater         0.2.1                    py36_0<br>
nbconvert                 5.3.1            py36hb41ffb7_0<br>
nbformat                  4.4.0            py36h31c9010_0<br>
ncurses                   6.2                  he6710b0_1<br>
networkx                  2.1                      py36_0<br>
ninja                     1.10.1           py36hfd86e86_0<br>
nltk                      3.3.0                    py36_0<br>
nomkl                     3.0                           0<br>
nose                      1.3.7            py36hcdf7029_2<br>
notebook                  5.5.0                    py36_0<br>
numba                     0.38.0           py36h637b7d7_0<br>
numexpr                   2.6.5            py36h7bf3b9c_0<br>
numpy                     1.13.1             py36_nomkl_0<br>
numpy-base                1.14.3           py36h9be14a7_1<br>
numpydoc                  0.8.0                    py36_0<br>
odo                       0.5.1            py36h90ed295_0<br>
olefile                   0.46                       py_0<br>
openblas                  0.2.19                        0<br>
openpyxl                  2.5.3                    py36_0<br>
openssl                   1.1.1h               h7b6447c_0<br>
packaging                 17.1                     py36_0<br>
pandas                    0.23.0           py36h637b7d7_0<br>
pandoc                    1.19.2.1             hea2e7c5_1<br>
pandocfilters             1.4.2            py36ha6701b7_1<br>
pango                     1.41.0               hd475d92_0<br>
parso                     0.2.0                    py36_0<br>
partd                     0.3.8            py36h36fd896_0<br>
patchelf                  0.9                  hf79760b_2<br>
path.py                   11.0.1                   py36_0<br>
pathlib2                  2.3.2                    py36_0<br>
patsy                     0.5.0                    py36_0<br>
pcre                      8.42                 h439df22_0<br>
pep8                      1.7.1                    py36_0<br>
pexpect                   4.5.0                    py36_0<br>
pickleshare               0.7.4            py36h63277f8_0<br>
pillow                    8.0.1            py36he98fc37_0<br>
pip                       20.2.4           py36h06a4308_0<br>
pixman                    0.34.0               hceecf20_3<br>
pkginfo                   1.4.2                    py36_1<br>
pluggy                    0.6.0            py36hb689045_0<br>
ply                       3.11                     py36_0<br>
prompt_toolkit            1.0.15           py36h17d85b1_0<br>
psutil                    5.4.5            py36h14c3975_0<br>
ptyprocess                0.5.2            py36h69acd42_0<br>
py                        1.5.3                    py36_0<br>
PyArabic                  0.6.10                    <br>
pycodestyle               2.4.0                    py36_0<br>
pycosat                   0.6.3            py36h0a5515d_0<br>
pycparser                 2.18             py36hf9f622e_1<br>
pycrypto                  2.6.1            py36h14c3975_8<br>
pycurl                    7.43.0.1         py36hb7f436b_0<br>
pyflakes                  1.6.0            py36h7bd6a15_0<br>
pygments                  2.2.0            py36h0d3125c_0<br>
pylint                    1.8.4                    py36_0<br>
pyodbc                    4.0.23           py36hf484d3e_0<br>
pyopenssl                 18.0.0                   py36_0<br>
pyparsing                 2.2.0            py36hee85983_1<br>
pyqt                      5.9.2            py36h751905a_0<br>
pysocks                   1.6.8                    py36_0<br>
pytables                  3.4.3            py36h02b9ad4_2<br>
pytest                    3.5.1                    py36_0<br>
pytest-arraydiff          0.2                      py36_0<br>
pytest-astropy            0.3.0                    py36_0<br>
pytest-doctestplus        0.1.3                    py36_0<br>
pytest-openfiles          0.3.0                    py36_0<br>
pytest-remotedata         0.2.1                    py36_0<br>
python                    3.6.12               hcff3b4d_2<br>
python-dateutil           2.7.3                    py36_0<br>
pytorch                   1.4.0               py3.6_cpu_0  [cpuonly]  pytorch<br>
pytz                      2018.4                   py36_0<br>
pywavelets                0.5.2            py36he602eb0_0<br>
pyyaml                    3.12             py36hafb9ca4_1<br>
pyzmq                     17.0.0           py36h14c3975_0<br>
qt                        5.9.5                h7e424d6_0<br>
qtawesome                 0.4.4            py36h609ed8c_0<br>
qtconsole                 4.3.1            py36h8f73b5b_0<br>
qtpy                      1.4.1                    py36_0<br>
readline                  8.0                  h7b6447c_0<br>
requests                  2.18.4           py36he2e5f8d_1<br>
rope                      0.10.7           py36h147e2ec_0<br>
ruamel_yaml               0.15.35          py36h14c3975_1<br>
scikit-image              0.13.1           py36h14c3975_1<br>
scikit-learn              0.19.1           py36h7aa7ec6_0<br>
scipy                     1.1.0            py36hfc37229_0<br>
seaborn                   0.8.1            py36hfad7ec4_0<br>
send2trash                1.5.0                    py36_0<br>
setuptools                50.3.1           py36h06a4308_1<br>
simplegeneric             0.8.1                    py36_2<br>
singledispatch            3.4.0.3          py36h7a266c3_0<br>
sip                       4.19.8           py36hf484d3e_0<br>
six                       1.15.0                     py_0<br>
smart-open                3.0.0                     <br>
snappy                    1.1.7                hbae5bb6_3<br>
snowballstemmer           1.2.1            py36h6febd40_0<br>
sortedcollections         0.6.1                    py36_0<br>
sortedcontainers          1.5.10                   py36_0<br>
sphinx                    1.7.4                    py36_0<br>
sphinxcontrib             1.0              py36h6d0f590_1<br>
sphinxcontrib-websupport  1.0.1            py36hb5cb234_1<br>
spyder                    3.2.8                    py36_0<br>
sqlalchemy                1.2.7            py36h6b74fdf_0<br>
sqlite                    3.33.0               h62c20be_0<br>
statsmodels               0.9.0            py36h3010b51_0<br>
sympy                     1.1.1            py36hc6d1c1c_0<br>
tblib                     1.3.2            py36h34cf8b6_0<br>
terminado                 0.8.1                    py36_1<br>
testpath                  0.3.1            py36h8cadb63_0<br>
tk                        8.6.10               hbc83047_0<br>
toolz                     0.9.0                    py36_0<br>
torchaudio                0.4.0                      py36    pytorch<br>
torchvision               0.5.0                  py36_cpu  [cpuonly]  pytorch<br>
tornado                   5.0.2                    py36_0<br>
traitlets                 4.3.2            py36h674d592_0<br>
typing                    3.7.4.3                  py36_0<br>
unicodecsv                0.14.1           py36ha668878_0<br>
unixodbc                  2.3.6                h1bed415_0<br>
urllib3                   1.22             py36hbe7ace6_0<br>
wcwidth                   0.1.7            py36hdf4376a_0<br>
webencodings              0.5.1            py36h800622e_1<br>
werkzeug                  0.14.1                   py36_0<br>
wheel                     0.35.1                     py_0<br>
widgetsnbextension        3.2.1                    py36_0<br>
wrapt                     1.10.11          py36h28b7045_0<br>
xlrd                      1.1.0            py36h1db9f0c_1<br>
xlsxwriter                1.0.4                    py36_0<br>
xlwt                      1.3.0            py36h7b00a1f_0<br>
xz                        5.2.5                h7b6447c_0<br>
yaml                      0.1.7                had09818_2<br>
zeromq                    4.2.5                h439df22_0<br>
zict                      0.1.3            py36h3a3bf81_0<br>
zlib                      1.2.11               h7b6447c_3<br>
zstd                      1.4.5                h9ceee32_0<br>
​</p>

username: Aiman_Mutasem-bellh
cooked: <p>Any suggestions to fix this issue? <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

username: ptrblck
cooked: <p>Jupyter might hide the actual error message and just restart the kernel.<br>
Could you run the script in a terminal via <code>python scripy.py</code> and check the error message?</p>

username: Aiman_Mutasem-bellh
cooked: <p>Yes sir you’re correct. I get the below error when I import torch</p>
<pre><code class="lang-auto">import torch
 File "/home/aiman/anaconda3/lib/python3.6/site-packages/torch/__init__.py", line 81, in &lt;module&gt;

from torch._C import *
ImportError: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /lib64/libstdc++.so.6)
</code></pre>

username: ptrblck
cooked: <p>Did you build PyTorch from source are have you used a conda/pip binary?<br>
Also, did you change something in your system, which might have broken PyTorch, in case it was working before?</p>

username: Aiman_Mutasem-bellh
cooked: <p>Thank you sir for the valuable reply.</p>
<p>I have built Pytorch using pip:<br>
<code>pip install torch==1.3.1+cu100 torchvision==0.4.2+cu100 -f https://download.pytorch.org/whl/torch_stable.html</code></p>
<p>It’s setup for a new system. I’m confused if its Pytorch or a system issue.</p>

username: ptrblck
cooked: <p>I’m unsure what is causing this issue. Could you create a new virtual environment through <code>pip</code> or <code>conda</code> and reinstall PyTorch again?</p>

username: Aiman_Mutasem-bellh
cooked: <p>Thank you sir, it works now. I have reinstalled Pytorch with conda. <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

username: clived2
cooked: <p>I had this same issue on a pytorch install on an older notebook with only 2 gigs of ram when I was running torch 1.4.0. I removed 1.4.0 and replaced it with 1.1.0. This config behaved perfectly. I might also add that I am having the same problem on the notebook, when trying to import Tensorflow2</p>

username: Aiman_Mutasem-bellh
cooked: <p>Thank you sir, it’s work well now.</p>

username: avafor
cooked: <p>Hi,<br>
I am having a similar problem. While trying to calculate the perplexity from this <a href="https://huggingface.co/docs/transformers/perplexity#example-calculating-perplexity-with-gpt2-in-transformers" rel="noopener nofollow ugc">code</a>, the kernel is constantly dead when it reaches the last part of the code, i.e. perplexity computations. I also tried to run it directly in python and there is no error message except ‘Killed’. Do you have any suggestions how to solve it? Thank you.</p>

username: ptrblck
cooked: <p>You are most likely running out of memory on the host and your OS kills the process, so you might need to use a machine with more RAM.</p>

username: martinpius
cooked: <p>I had the same issue but it turn out to be a common error in my codes. I troubleshooted my codes on CoLaB and noticed a dimension mismatch. Everything run smoothly in my local notebook after fixing the issue.</p>

username: Hanson_Wang
cooked: <p>Hello！ What if I use .ipynb script and I’ve met the same problem?</p>

username: ptrblck
cooked: <p>The same applies and you should export the notebook into a script and run it in a terminal.</p>