Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on unloading a model #5453

Closed
seanxhughes opened this issue Feb 22, 2022 · 2 comments
Closed

Segfault on unloading a model #5453

seanxhughes opened this issue Feb 22, 2022 · 2 comments

Comments

@seanxhughes
Copy link

Hi,
I'm using pytorch compiled from source and with this very simple program which successfully loads a pre-trained model, then terminates I get a segfault in the sequence of destructors - anyone seen this before?

Code

#include <iostream>
#include <torch/script.h> 
#include <memory>

int main(int argc, char **argv)
{

    try {
        std::cout << "Attempting to load " << argv[1] << "\n";
        // Deserialize the ScriptModule from a file using torch::jit::load().
        auto module = torch::jit::load(argv[1]);

        std::cout << "Model loaded\n";
    }
    catch (const c10::Error& e) {
        std::cerr << "Error loading Pytorch model " << e.msg() << "\n";
        return -1;
    }

    return 0;
}

Stack trace

#0 0x000055555555a27a in c10::IValue::isTensor (this=0x80) at /usr/local/libtorch/include/ATen/core/ivalue.h:394
#1 0x000055555555ac77 in c10::IValue::destroy (this=0x80) at /usr/local/libtorch/include/ATen/core/ivalue.h:991
#2 0x000055555555a24c in c10::IValue::~IValue (this=0x80, __in_chrg=) at /usr/local/libtorch/include/ATen/core/ivalue.h:197
#3 0x0000555555561419 in std::_Destroyc10::IValue (__pointer=0x80) at /usr/include/c++/9/bits/stl_construct.h:98
#4 0x00005555555604a2 in std::_Destroy_aux::__destroyc10::IValue* (__first=0x80, __last=0x21) at /usr/include/c++/9/bits/stl_construct.h:108
#5 0x000055555555f324 in std::_Destroyc10::IValue* (__first=0x80, __last=0x21) at /usr/include/c++/9/bits/stl_construct.h:137
#6 0x000055555555d79d in std::_Destroy<c10::IValue*, c10::IValue> (__first=0x80, __last=0x21) at /usr/include/c++/9/bits/stl_construct.h:206
#7 0x000055555555c151 in std::__cxx1998::vector<c10::IValue, std::allocatorc10::IValue >::~vector (this=0x555556b2e6d0, __in_chrg=) at /usr/include/c++/9/bits/stl_vector.h:677
#8 0x000055555555a220 in std::__debug::vector<c10::IValue, std::allocatorc10::IValue >::~vector (this=0x555556b2e6b8, __in_chrg=) at /usr/include/c++/9/debug/vector:220
#9 0x000055555555dbf6 in c10::ivalue::Object::~Object (this=0x555556b2e660, __in_chrg=) at /usr/local/libtorch/include/ATen/core/ivalue_inl.h:1328
#10 0x000055555555dc32 in c10::ivalue::Object::~Object (this=0x555556b2e660, _in_chrg=) at /usr/local/libtorch/include/ATen/core/ivalue_inl.h:1328
#11 0x000055555555dd6d in c10::intrusive_ptr<c10::ivalue::Object, c10::detail::intrusive_target_default_null_typec10::ivalue::Object >::reset
(this=0x7fffffffdcb0) at /usr/local/libtorch/include/c10/util/intrusive_ptr.h:289
#12 0x000055555555c37c in c10::intrusive_ptr<c10::ivalue::Object, c10::detail::intrusive_target_default_null_typec10::ivalue::Object >::~intrusive_ptr (this=0x7fffffffdcb0, __in_chrg=) at /usr/local/libtorch/include/c10/util/intrusive_ptr.h:366
#13 0x000055555555b460 in torch::jit::Object::~Object (this=0x7fffffffdcb0, __in_chrg=) at /usr/local/libtorch/include/torch/csrc/jit/api/object.h:24
#14 0x000055555555b480 in torch::jit::Module::~Module (this=0x7fffffffdcb0, __in_chrg=) at /usr/local/libtorch/include/torch/csrc/jit/api/module.h:98
#15 0x00005555555589be in main (argc=2, argv=0x7fffffffddf8) at ./exe/hello_world.cpp:87

@prabhat00155
Copy link
Contributor

Are you using a torchvision model? If this is a pytorch related problem, perhaps file an issue here.

@seanxhughes
Copy link
Author

Sorry, didn't realise I posted it in the wrong forum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants