sugarme / gotch

Go binding for Pytorch C++ API (libtorch)
Apache License 2.0
561 stars 44 forks source link

ImageNet.LoadImageAndResize224 crashes for some files. #26

Closed Claus1 closed 3 years ago

Claus1 commented 3 years ago

1 This file causes an error:


fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x25 pc=0x25]

runtime stack:
runtime.throw(0x130a881, 0x2a)
    /usr/local/go/src/runtime/panic.go:1116 +0x72
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:726 +0x269

goroutine 1 [syscall]:
runtime.cgocall(0x102e255, 0xc00061fab8, 0x13093bf)
    /usr/local/go/src/runtime/cgocall.go:133 +0x5b fp=0xc00061fa70 sp=0xc00061fa38 pc=0x461e7b
github.com/sugarme/gotch/libtch._Cfunc_atg_totype(0x7f23980136b0, 0x7f2398012950, 0x6)
    _cgo_gotypes.go:22434 +0x45 fp=0xc00061fab8 sp=0xc00061fa70 pc=0xe6b905
github.com/sugarme/gotch/libtch.AtgTotype.func1(0x7f23980136b0, 0x7f2398012950, 0xc000000006)
    /home/george/go/pkg/mod/github.com/sugarme/gotch@v0.3.9-rc1/libtch/c-generated.go:6146 +0xac fp=0xc00061fb10 sp=0xc00061fab8 pc=0xee030c
github.com/sugarme/gotch/libtch.AtgTotype(0x7f23980136b0, 0x7f2398012950, 0xc000000006)
    /home/george/go/pkg/mod/github.com/sugarme/gotch@v0.3.9-rc1/libtch/c-generated.go:6146 +0x4c fp=0xc00061fb60 sp=0xc00061fb10 pc=0xe958cc
github.com/sugarme/gotch/tensor.(*Tensor).Totype(0xc0000ae010, 0x13cea60, 0x1175080, 0x0, 0x0, 0x0, 0x0)
    /home/george/go/pkg/mod/github.com/sugarme/gotch@v0.3.9-rc1/tensor/tensor-generated.go:17916 +0x106 fp=0xc00061fc00 sp=0xc00061fb60 pc=0xfedd46
github.com/sugarme/gotch/vision.(*ImageNet).Normalize(0xc00000f680, 0xc0000ae010, 0x0, 0x0, 0x0)
    /home/george/go/pkg/mod/github.com/sugarme/gotch@v0.3.9-rc1/vision/imagenet.go:36 +0xfb fp=0xc00061fd08 sp=0xc00061fc00 pc=0x1006fdb
github.com/sugarme/gotch/vision.(*ImageNet).LoadImageAndResize224(0xc00000f680, 0x1315e01, 0x46, 0x0, 0x0, 0x0)
    /home/george/go/pkg/mod/github.com/sugarme/gotch@v0.3.9-rc1/vision/imagenet.go:149 +0x24d fp=0xc00061fdd8 sp=0xc00061fd08 pc=0x10083ed
main.ProbsImage(0x1315e01, 0x46, 0xc000010208, 0x0, 0x0, 0x0)
    /home/george/Projects/unigui-go/examples/engine/main.go:229 +0x85 fp=0xc00061fe90 sp=0xc00061fdd8 pc=0x100c325
main.main()
    /home/george/Projects/unigui-go/examples/engine/main.go:194 +0x5e fp=0xc00061ff88 sp=0xc00061fe90 pc=0x100bf5e
runtime.main()
    /usr/local/go/src/runtime/proc.go:204 +0x1cf fp=0xc00061ffe0 sp=0xc00061ff88 pc=0x49df6f
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1374 +0x1 fp=0xc00061ffe8 sp=0xc00061ffe0 pc=0x4d4421

goroutine 6 [select]:
go.opencensus.io/stats/view.(*worker).start(0xc00007e7d0)
    /home/george/go/pkg/mod/go.opencensus.io@v0.22.0/stats/view/worker.go:154 +0x19e
created by go.opencensus.io/stats/view.init.0
    /home/george/go/pkg/mod/go.opencensus.io@v0.22.0/stats/view/worker.go:32 +0x5b
sugarme commented 3 years ago

Hi @Claus1 ,

Good call! The error was related to deleting return tensor at vision/image. I have fixed and added a new tag v0.3.9-rc2. Please test it by:

Hope that works.

Claus1 commented 3 years ago

@sugarme Hi! Everything works as described. The bug is fixed. Thanks!