Error while running FINETUNING TORCHVISION MODELS

username: Sreekanth
cooked: <p>Hi All,<br>
I am new to torch and I am working on ML and tried the below example in Google colab  which worked perfectly and prediction was working as expected.</p>
<p><a href="https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html" class="onebox" target="_blank" rel="noopener nofollow ugc">https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html</a></p>
<p>The same code I am trying to run on a Ubuntu 18.04 on a local machine without GPU, but fails with Illegal instruction (Core dump). Below is the image containing the error.</p>
<p>I have installed the latest torch library (1.9.0+cpu) and also tried with torch version 1.9.1 but still the error persists.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/0/505b43eacf7edab0bff9cb1786d247bf81ddc15d.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/505b43eacf7edab0bff9cb1786d247bf81ddc15d" title="Error Image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/5/0/505b43eacf7edab0bff9cb1786d247bf81ddc15d_2_690x431.jpeg" alt="Error Image" data-base62-sha1="bsRJqhkBcpcCFIOnhh0rB8blBFj" width="690" height="431" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/5/0/505b43eacf7edab0bff9cb1786d247bf81ddc15d_2_690x431.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/5/0/505b43eacf7edab0bff9cb1786d247bf81ddc15d_2_1035x646.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/5/0/505b43eacf7edab0bff9cb1786d247bf81ddc15d_2_1380x862.jpeg 2x" data-dominant-color="7D7672"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Error Image</span><span class="informations">1732×1084 173 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Could you try to grab the stacktrace via:</p>
<pre><code class="lang-auto">gdb --args python script.py args
...
run
...
bt
</code></pre>
<p>and post it here?</p>
<p>PS: you can post code snippets by wrapping them into three backticks ```, which would make debugging easier. <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"></p>

username: Sreekanth
cooked: <pre><code class="lang-auto"> **gdb --args python3 alexnet_working_code.ipynb  args**
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
&lt;links releated to gdb&gt;
Find the GDB manual and other documentation resources online at:
&lt;links releated to gdb&gt;
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3...(no debugging symbols found)...done.
 **run**
Starting program: /usr/bin/python3 alexnet_working_code.ipynb args
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffdd772700 (LWP 4307)]
[Thread 0x7fffdd772700 (LWP 4307) exited]
PyTorch Version:  1.9.0+cpu
[New Thread 0x7fffdd772700 (LWP 4329)]
AlexNet(
  (features): Sequential(
    (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))
    (1): ReLU(inplace=True)
    (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
    (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
    (4): ReLU(inplace=True)
    (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
    (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (7): ReLU(inplace=True)
    (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (9): ReLU(inplace=True)
    (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (11): ReLU(inplace=True)
    (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
  )
  (avgpool): AdaptiveAvgPool2d(output_size=(6, 6))
  (classifier): Sequential(
    (0): Dropout(p=0.5, inplace=False)
    (1): Linear(in_features=9216, out_features=4096, bias=True)
    (2): ReLU(inplace=True)
    (3): Dropout(p=0.5, inplace=False)
    (4): Linear(in_features=4096, out_features=4096, bias=True)
    (5): ReLU(inplace=True)
    (6): Linear(in_features=4096, out_features=15, bias=True)
  )
)
Initializing Datasets and Dataloaders...
/home/implant/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 8 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
  cpuset_checked))
cpu
cpu
Params to learn:
	 features.0.weight
	 features.0.bias
	 features.3.weight
	 features.3.bias
	 features.6.weight
	 features.6.bias
	 features.8.weight
	 features.8.bias
	 features.10.weight
	 features.10.bias
	 classifier.1.weight
	 classifier.1.bias
	 classifier.4.weight
	 classifier.4.bias
	 classifier.6.weight
	 classifier.6.bias
1
'2
Epoch 0/9
----------
[New Thread 0x7fffb0da1700 (LWP 4346)]
[New Thread 0x7fffabfff700 (LWP 4347)]
[New Thread 0x7fffab7fe700 (LWP 4348)]
[New Thread 0x7fffaaffd700 (LWP 4349)]
[New Thread 0x7fffaa7fc700 (LWP 4350)]
[New Thread 0x7fffa9ffb700 (LWP 4351)]
[New Thread 0x7fffa97fa700 (LWP 4352)]
[New Thread 0x7fffa8ff9700 (LWP 4353)]
/home/implant/.local/lib/python3.6/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /pytorch/c10/core/TensorImpl.h:1156.)
  return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
[New Thread 0x7fff8ad9f700 (LWP 4372)]
    
Thread 3 "python3" received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7fffdd772700 (LWP 4329)]
0x00007fffeea7369d in void dnnl::impl::cpu::(anonymous namespace)::block_ker&lt;float, true, false&gt;(long, long, long, float const*, long, float const*, long, float*, long, float, float, float*, bool) () from /home/implant/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so

**(gdb) bt**
#0  0x00007fffeea7369d in void dnnl::impl::cpu::(anonymous namespace)::block_ker&lt;float, true, false&gt;(long, long, long, float const*, long, float const*, long, float*, long, float, float, float*, bool) ()
   from /home/implant/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so
#1  0x00007fffeea73881 in void dnnl::impl::cpu::(anonymous namespace)::gemm_ithr&lt;float, true, false&gt;(long, long, long, float, float const*, long, float const*, long, float, float*, long, bool, float*) ()
   from /home/implant/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so
#2  0x00007fffeea778fe in dnnl_status_t dnnl::impl::cpu::ref_gemm&lt;float&gt;(char const*, char const*, long const*, long const*, long const*, float const*, float const*, long const*, float const*, long const*, float const*, float*, long const*, float const*) ()
   from /home/implant/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so
#3  0x00007fffee9aca87 in void dnnl::impl::parallel&lt;dnnl::impl::cpu::gemm_convolution_bwd_weights_t::execute_backward_weights_ncsp(dnnl::impl::exec_ctx_t const&amp;) const::{lambda(int, int)#1}&gt;(int, dnnl::impl::cpu::gemm_convolution_bwd_weights_t::execute_backward_weights_ncsp(dnnl::impl::exec_ctx_t const&amp;) const::{lambda(int, int)#1}) [clone ._omp_fn.12] ()
   from /home/implant/.local/lib/python3.6/site-packages/torch/lib/libtorch_cpu.so
#4  0x00007ffff47a7405 in ?? () from /home/implant/.local/lib/python3.6/site-packages/torch/lib/libgomp-a34b3233.so.1
#5  0x00007ffff77cc6db in start_thread (arg=0x7fffdd772700) at pthread_create.c:463
#6  0x00007ffff7b05a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

</code></pre>
<p>This is what i got after excuting those codes.Can you please look into it.</p>

username: ptrblck
cooked: <p>Thanks for the stacktrace. It seems that oneDNN is causing the failure. Could you create an issue on <a href="https://github.com/pytorch/pytorch/issues">GitHub</a> so that the code owners could take a look at it, please?</p>

username: Sreekanth
cooked: <p>Sure. Will create an issue in GitHub</p>