"Illegal instruction (core dumped)" when importing PyTorch

When I try to import pytorch, I keep getting “Illegal instruction (core dumped)”. I’ve tried CUDA 12.1, Ubuntu 22.04 and different installation methods.

Current setup:
Ubuntu 20.04
Nvidia RTX 3060
CUDA 11.8
Python 3.8.10

On this forum I found that the output of gdb might be useful, which is:

(gdb) run test.py
Starting program: /home/sphynx/Documents/test/.venv/bin/python3 test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Detaching after fork from child process 13834]

Program received signal SIGILL, Illegal instruction.
0x00007fffef02c732 in void std::vector<dnnl_post_ops::entry_t, std::allocator<dnnl_post_ops::entry_t> >::_M_realloc_insert<>(__gnu_cxx::__normal_iterator<dnnl_post_ops::entry_t*, std::vector<dnnl_post_ops::entry_t, std::allocator<dnnl_post_ops::entry_t> > >) () from /home/sphynx/Documents/test/.venv/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so

Any help is appreciated.

For anyone encountering this in the future. For me, installing PyTorch with

pip3 install https://download.pytorch.org/whl/cu118/torch-2.0.0%2Bcu118-cp38-cp38-linux_x86_64.whl

instead of the command mentioned on the PyTorch website (Start Locally) solved the problem.

dnnl points to Intel’s oneDNN lib and does not seem to be supported on your CPU. Downgrading PyTorch might be a workaround but not a solution. Which CPU are you using?

Thanks for your reply. I am using an AMD Phenom II X4 965.

I don’t believe this CPU supports AVX, while it might be a requirement.
CC @malfet do you know if and which AVX requirement the current binaries have?