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

Import pytorch gives segmentation fault #15

Open
JunhongXu opened this issue Oct 2, 2017 · 4 comments
Open

Import pytorch gives segmentation fault #15

JunhongXu opened this issue Oct 2, 2017 · 4 comments

Comments

@JunhongXu
Copy link

JunhongXu commented Oct 2, 2017

I have been playing with this environment these days and would like to use pytorch to train a RL agent. However, when I import pytorch inside the script, the program gives a segmentation fault.

Code:

import gym_minecraft
import gym
import torch

if __name__ == '__main__':
    env = gym.make('MinecraftBasic-v0')
    env.init(start_minecraft=True)
    obs = env.reset()

The minecraft program is launched but does not load any task and throws a segmentation fault:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

However, if I remove import torch, it works fine.

Edit:

Here is the backtrace:

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007fffc15e8577 in void std::__once_call_impl<std::_Bind_simple<void (*())()> >() () from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/torch/lib/libTHC.so.1
(gdb) where
#0  0x00007fffc15e8577 in void std::__once_call_impl<std::_Bind_simple<void (*())()> >() () from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/torch/lib/libTHC.so.1
#1  0x00007ffff77eba99 in __pthread_once_slow (once_control=0x7fffa98b3ea0 <malmo::test_schemas_flag>, init_routine=0x7fffb9711fe1 <std::__once_proxy()>) at pthread_once.c:116
#2  0x00007fffa9448a89 in malmo::AgentHost::startMission(malmo::MissionSpec const&, malmo::ClientPool const&, malmo::MissionRecordSpec const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) () from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#3  0x00007fffa9441cbe in boost::python::detail::caller_arity<6u>::impl<void (malmo::AgentHost::*)(malmo::MissionSpec const&, malmo::ClientPool const&, malmo::MissionRecordSpec const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >), boost::python::default_call_policies, boost::mpl::vector7<void, malmo::AgentHost&, malmo::MissionSpec const&, malmo::ClientPool const&, malmo::MissionRecordSpec const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::operator()(_object*, _object*) ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#4  0x00007fffa959969d in boost::python::objects::function::call(_object*, _object*) const ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#5  0x00007fffa9599898 in boost::detail::function::void_function_ref_invoker0<boost::python::objects::(anonymous namespace)::bind_return, void>::invoke(boost::detail::function::function_buffer&) ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#6  0x00007fffa95a1883 in boost::python::detail::exception_handler::operator()(boost::function0<void> const&) const ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#7  0x00007fffa940a823 in boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool, boost::python::detail::translate_exception<malmo::MissionException, void (*)(malmo::MissionException const&)>, boost::_bi::list3<boost::arg<1>, boost::arg<2>, boost::_bi::value<void (*)(malmo::MissionException const&)> > >, bool, boost::python::detail::exception_handler const&, boost::function0<void> const&>::invoke(boost::detail::function::function_buffer&, boost::python::detail::exception_handler const&, boost::function0<void> const&) ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#8  0x00007fffa95a1858 in boost::python::detail::exception_handler::operator()(boost::function0<void> const&) const ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#9  0x00007fffa940a7d3 in boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool, boost::python::detail::translate_exception<xsd::cxx::tree::exception<char>, void (*)(xsd::cxx::tree::exception<char> const&)>, boost::_bi::list3<boost::arg<1>, boost::arg<2>, boost::_bi::value<void (*)(xsd::cxx::tree::exception<char> const&)> > >, bool, boost::python::detail::exception_handler const&, boost::function0<void> const&>::invoke(boost::detail::function::function_buffer&, boost::python::detail::exception_handler const&, boost::function0<void> const&) ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#10 0x00007fffa95a163d in boost::python::handle_exception_impl(boost::function0<void>) ()
   from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#11 0x00007fffa9596a79 in function_call () from /home/junhong/anaconda3/envs/MC-research/lib/python2.7/site-packages/minecraft_py/Malmo/Python_Examples/MalmoPython.so
#12 0x00007ffff7a42773 in PyObject_Call () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#13 0x00007ffff7ad653b in PyEval_EvalFrameEx () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#14 0x00007ffff7adcdac in PyEval_EvalFrameEx () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#15 0x00007ffff7adcdac in PyEval_EvalFrameEx () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#16 0x00007ffff7ade4e9 in PyEval_EvalCodeEx () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#17 0x00007ffff7ade70a in PyEval_EvalCode () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#18 0x00007ffff7af793d in run_mod () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#19 0x00007ffff7af8ab8 in PyRun_FileExFlags () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#20 0x00007ffff7af9cd8 in PyRun_SimpleFileExFlags () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#21 0x00007ffff7b0bd3c in Py_Main () from /home/junhong/anaconda3/envs/MC-research/bin/../lib/libpython2.7.so.1.0
#22 0x00007ffff6d23830 in __libc_start_main (main=0x555555554850 <main>, argc=2, argv=0x7fffffffdc58, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdc48)
    at ../csu/libc-start.c:291
#23 0x000055555555487f in _start ()

@mikeXwang
Copy link

I got the same situation.
Did this issue solved?

@unnir
Copy link

unnir commented Nov 17, 2017

@mikeXwang Did you solve it?

I'm facing the same issue

@JunhongXu
Copy link
Author

It turns out that we need to start Minecraft before we import PyTorch. I have successfully trained a A2C agent to navigate in the simplest environment in PyTorch. You can check out the code if you are interested https://github.com/JunhongXu/pytorch-a2c-minecraft/blob/master/run_minecraft.py

@unnir
Copy link

unnir commented Nov 17, 2017

@JunhongXu wow! thank you

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

3 participants