Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Illegal instruction (core dumped) on Raspberry Pi 4B #8

Description

@unwind

When running with the latest (1.9.0) wheel from here, as per the installation instructions, my project's Torch code crashes every time with an illegal instruction exception.

The top 10 stack levels looked like this:

(gdb) where
#0  0x0000ffffd286dfc8 in exec_blas ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#1  0x0000ffffd283f150 in gemm_driver ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#2  0x0000ffffd283fbd0 in sgemm_thread_nn ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#3  0x0000ffffd28385bc in sgemm_ () from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#4  0x0000ffffcfc38b8c in at::native::cpublas::gemm(at::native::cpublas::TransposeType, at::native::cpublas::TransposeType, long, lo
ng, long, float, float const*, long, float const*, long, float, float*, long) ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#5  0x0000ffffcfce5c48 in at::native::addmm_impl_cpu_(at::Tensor&, at::Tensor const&, at::Tensor, at::Tensor, c10::Scalar const&, c1
0::Scalar const&) () from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#6  0x0000ffffcfce68d0 in at::native::mm_cpu_out(at::Tensor const&, at::Tensor const&, at::Tensor&) ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#7  0x0000ffffcfce6a34 in at::native::mm_cpu(at::Tensor const&, at::Tensor const&) ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#8  0x0000ffffd056c784 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFuncti
onPointer<at::Tensor (at::Tensor const&, at::Tensor const&), &at::(anonymous namespace)::(anonymous namespace)::wrapper_mm>, at::Ten
sor, c10::guts::typelist::typelist<at::Tensor const&, at::Tensor const&> >, at::Tensor (at::Tensor const&, at::Tensor const&)>::call
(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, at::Tensor const&) ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#9  0x0000ffffd039b464 in at::redispatch::mm(c10::DispatchKeySet, at::Tensor const&, at::Tensor const&) ()
   from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so
#10 0x0000ffffd1b5659c in torch::autograd::VariableType::(anonymous namespace)::mm(c10::DispatchKeySet, at::Tensor const&, at::Tenso
r const&) () from lib/python3.8/site-packages/torch/lib/libtorch_cpu.so

Looking at the disassembly at the indicated location I got:

(gdb) disassemble
Dump of assembler code for function exec_blas:
   0x0000ffffd286df70 <+0>:     adrp    x2, 0xffffd40c6000
   0x0000ffffd286df74 <+4>:     stp     x29, x30, [sp, #-80]!
   0x0000ffffd286df78 <+8>:     mov     x29, sp
   0x0000ffffd286df7c <+12>:    ldr     x3, [x2, #2376]
   0x0000ffffd286df80 <+16>:    mov     x2, x0
   0x0000ffffd286df84 <+20>:    stp     x19, x20, [sp, #16]
   0x0000ffffd286df88 <+24>:    mov     x20, x1
   0x0000ffffd286df8c <+28>:    ldr     w0, [x3]
   0x0000ffffd286df90 <+32>:    cbz     w0, 0xffffd286e000 <exec_blas+144>
   0x0000ffffd286df94 <+36>:    cmp     x2, #0x0
   0x0000ffffd286df98 <+40>:    ccmp    x20, #0x0, #0x4, gt
   0x0000ffffd286df9c <+44>:    b.eq    0xffffd286dff0 <exec_blas+128>  // b.none
   0x0000ffffd286dfa0 <+48>:    adrp    x19, 0xffffd4150000 <memory+1984>
   0x0000ffffd286dfa4 <+52>:    add     x1, sp, #0x38
   0x0000ffffd286dfa8 <+56>:    add     x4, x19, #0x4f0
   0x0000ffffd286dfac <+60>:    mov     w0, #0x1                        // #1
   0x0000ffffd286dfb0 <+64>:    add     x4, x4, #0x40
   0x0000ffffd286dfb4 <+68>:    nop
   0x0000ffffd286dfb8 <+72>:    nop
   0x0000ffffd286dfbc <+76>:    nop
   0x0000ffffd286dfc0 <+80>:    strb    wzr, [sp, #56]
   0x0000ffffd286dfc4 <+84>:    mov     w3, #0x0                        // #0
=> 0x0000ffffd286dfc8 <+88>:    casalb  w3, w0, [x4]
   0x0000ffffd286dfcc <+92>:    cbnz    w3, 0xffffd286dfc0 <exec_blas+80>
   0x0000ffffd286dfd0 <+96>:    adrp    x0, 0xffffd286d000 <inner_thread+2192>
   0x0000ffffd286dfd4 <+100>:   stp     x2, x20, [sp, #56]
   0x0000ffffd286dfd8 <+104>:   add     x0, x0, #0xbcc
   0x0000ffffd286dfdc <+108>:   str     xzr, [sp, #72]

This seems to indicate the the culprit is the CASALB instruciton, which as far as I can understand is ARM8.1, while the Raspberry Pi has an ARM8-compliant core.

I hope this can be fixed, since building Torch myself seems daunting (and also since, assuming I'm right above, this is not the intended behavior).

Thanks for making tihs avaialble.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions