"Illegal instruction (core dumped) in first PyTorch tutorial

username: Sally_Goldin
cooked: <p>I am brand-new to PyTorch and trying to get up to speed. I installed PyTorch on a 64 bit virtual machine running CentOS 7.5. Host processor is AMD 4 core Phenom IIx4 945.<br>
Python 3.6.8<br>
Gcc 4.8.5 20150603<br>
No GPU<br>
Installation instruction (from website)<br>
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f <a href="https://download.pytorch.org/whl/torch_stable.html" rel="noopener nofollow ugc">https://download.pytorch.org/whl/torch_stable.html</a></p>
<p>In the third section of the “60 minute blitz tutorial”, following all the instructions, I entered:</p>
<p>out.backward(torch.randn(1, 10))</p>
<p>And got a core dump.</p>
<blockquote>
<blockquote>
<blockquote>
<p>out.backward(torch.randn(1,10))<br>
Illegal instruction (core dumped)</p>
</blockquote>
</blockquote>
</blockquote>
<p>Having the tutorial crash looks really bad ;^)  Also interfering with my goal to learn PyTorch!</p>
<p>I’d appreciate help with this. Thanks.</p>

username: ptrblck
cooked: <p>That’s indeed a bad first experience <img src="https://discuss.pytorch.org/images/emoji/apple/confused.png?v=9" title=":confused:" class="emoji" alt=":confused:"></p>
<p>Could you run the code in a terminal and try to get the stack trace via:</p>
<pre><code class="lang-auto">$ gdb --args python my_script.py
...
Reading symbols from python...done.
(gdb) run
...
(gdb) backtrace
...
</code></pre>

username: Sally_Goldin
cooked: <p>In fact I was running the tutorial in a terminal on my local VM.</p>
<p>Here’s the beginning of the gdb backtrace. Let me know if you want the whole thing.</p>
<p>(I apologize in advance if this should be in a code-block. I don’t see how to do this.)</p>
<h2>Thanks!</h2>
<p>[New Thread 0x7fffd736d700 (LWP 14775)]<br>
[New Thread 0x7fffd6b6c700 (LWP 14776)]</p>
<p>Program received signal SIGILL, Illegal instruction.<br>
[Switching to Thread 0x7fffd736d700 (LWP 14775)]<br>
0x00007fffe2ceffc1 in void mkldnn::impl::cpu::(anonymous namespace)::kernel_mxn&lt;float, true, false&gt;(int, float const*, long, float const*, long, float*, long, float, float) ()<br>
from /home/goldin/.pyVirtual/lib/python3.6/site-packages/torch/lib/libtorch.so<br>
Missing separate debuginfos, use: debuginfo-install bzip2-libs-1.0.6-13.el7.x86_64 glibc-2.17-222.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-18.el7.x86_64 libcom_err-1.42.9-11.el7.x86_64 libffi-3.0.13-18.el7.x86_64 libgcc-4.8.5-28.el7.x86_64 libselinux-2.5-12.el7.x86_64 libstdc+±4.8.5-28.el7.x86_64 openssl-libs-1.0.2k-12.el7.x86_64 pcre-8.32-17.el7.x86_64 python3-libs-3.6.8-10.el7.x86_64 xz-libs-5.2.2-1.el7.x86_64 zlib-1.2.7-17.el7.x86_64<br>
(gdb) backtrace<br>
<span class="hashtag">#0</span>  0x00007fffe2ceffc1 in void mkldnn::impl::cpu::(anonymous namespace)::kernel_mxn&lt;float, true, false&gt;(int, float const*, long, float const*, long, float*, long, float, float) ()<br>
from /home/goldin/.pyVirtual/lib/python3.6/site-packages/torch/lib/libtorch.so<br>
<span class="hashtag">#1</span>  0x00007fffe2cf02d9 in void mkldnn::impl::cpu::(anonymous namespace)::block_ker&lt;float, true, false&gt;(int, int, int, float const*, long, float const*, long, float*, long, float, float, float*, bool) () from /home/goldin/.pyVirtual/lib/python3.6/site-packages/torch/lib/libtorch.so<br>
<span class="hashtag">#2</span>  0x00007fffe2cf4287 in mkldnn_status_t mkldnn::impl::cpu::ref_gemm(char const*, char const*, int const*, int const*, int const*, float const*, float const*, int const*, float const*, int const*, float const*, float*, int const*, float const*)::{lambda(int)<span class="hashtag">#2</span>}::operator()(int) const ()<br>
from /home/goldin/.pyVirtual/lib/python3.6/site-packages/torch/lib/libtorch.so</p>

username: ptrblck
cooked: <p>Thanks for the stack trace!<br>
Based on the stack trace, if seems <code>mkldnn</code> got an illegal instruction.<br>
If I recall correctly, I’ve seen this issue on older CPUs, which didn’t support SSE2.<br>
However, after quickly googling the specs of your CPU, it seems SSE is supported.<br>
I’m not that experienced in AMD CPUs, so let’s wait for other opinions on this error and if it’s in fact even related to the chip.</p>
<p>PS: you can add code snippets by wrapping them into three backticks ``` <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"></p>

username: Sally_Goldin
cooked: <p>Thank you Patrick, still hoping for some clarity.</p>

username: Sally_Goldin
cooked: <p>An update:<br>
– Created an Ubuntu-based VM on the same physical host (AMD-based) and installed PyTorch via Anaconda --&gt; still crashes<br>
– Moved this VM to a different host machine with a four core i3 Intel CPU --&gt; problem goes away.</p>
<p>This suggests the problem is related to the underlying hardware. Not a pretty conclusion. Anyway, thanks for your help.</p>

username: eslam_fouda
cooked: <p>I have the same issue but when I typed backtrace it gave me:<br>
no stack</p>

username: Jesse_Stone
cooked: <p>Illegal instruction (core dumped)</p>
<p>This is last non-using avx pytorch version, that I have test, my cpu have no avx</p>
<p>pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f <a href="https://download.pytorch.org/whl/torch_stable.html" rel="noopener nofollow ugc">https://download.pytorch.org/whl/torch_stable.html</a></p>

username: anoduck
cooked: <p>Ugh… this is both rather irritating and reasonably disappointing. After being unable to find an installation candidate for torch (1.8.1), guess I am going to have to kiss that project good bye.</p>
<p>Good grief…</p>