Closed pzhokhov closed 5 years ago
I tried pip install roboschool and got this error on import
In [3]: import roboschool
Python dylib /Library/Frameworks/Python.framework/Versions/3.6/Python referred from cpp_household.so is not found, attempting a relink...
Package python3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `python3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'python3' found
---------------------------------------------------------------------------
BaseException Traceback (most recent call last)
<ipython-input-3-e34d0d652851> in <module>()
----> 1 import roboschool
/opt/local/anaconda/lib/python3.6/site-packages/roboschool/__init__.py in <module>()
62
63 os.environ['QT_PLUGIN_PATH'] = osp.join(osp.dirname(osp.abspath(__file__)), '.qt_plugins')
---> 64 _link_pythonlib()
65
66 register(
/opt/local/anaconda/lib/python3.6/site-packages/roboschool/__init__.py in _link_pythonlib(lib)
19
20 print('Python dylib {} referred from {} is not found, attempting a relink...'.format(old_python_path, lib))
---> 21 python_pkg_config_output = _check_call_output('pkg-config --libs python3'.split(' '))[0]
22 python_lib_paths = [s[2:] for s in python_pkg_config_output.split(' ') if s.startswith('-L')]
23 python_lib_names = [s[2:] for s in python_pkg_config_output.split(' ') if s.startswith('-lpython')]
/opt/local/anaconda/lib/python3.6/site-packages/roboschool/__init__.py in _check_call_output(cmd, errormsg, **kwargs)
57 print(stderr or '')
58 print(errormsg or '')
---> 59 raise BaseException
60
61 return stdout.decode().split('\n')
@joschu thanks for pointing it out! There is an extra step on mac - make sure path python3.pc is in PKG_CONFIG_PATH... However, maybe I can automate that.
Pip install works successfully, but I'm running into two errors in use:
In [1]: import roboschool
...: import gym
...:
...: env = gym.make('RoboschoolWalker2d-v1')
...: env.reset()
...: for _ in range(100):
...: env.step(env.action_space.sample())
...: env.render()
...:
...: env = gym.make('RoboschoolAnt-v1')
...: env.reset()
...: for _ in range(100):
...: env.step(env.action_space.sample())
...: env.render()
...:
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
WARN: Environment '<class 'roboschool.gym_mujoco_walkers.RoboschoolWalker2d'>' has deprecated methods '_step' and '_reset' rather than 'step' and 'reset'. Compatibility code invoked. Set _gym_disable_underscore_compat = True to disable this behavior.
GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
python: /usr/local/include/boost/smart_ptr/shared_ptr.hpp:648: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = SimpleRender::Context; typename boost::detail::sp_member_access<T>::type = SimpleRender::Context*]: Assertion `px != 0' failed.
Aborted (core dumped)
In [1]: import roboschool
...: import gym
...:
...: env = gym.make('RoboschoolAtlasForwardWalk-v1')
...: env.reset()
...: for _ in range(100):
...: env.step(env.action_space.sample())
...: env.render()
...:
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
WARN: Environment '<class 'roboschool.gym_atlas.RoboschoolAtlasForwardWalk'>' has deprecated methods '_step' and '_reset' rather than 'step' and 'reset'. Compatibility code invoked. Set _gym_disable_underscore_compat = True to disable this behavior.
GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-013b605b3195> in <module>()
6 for _ in range(100):
7 env.step(env.action_space.sample())
----> 8 env.render()
9
/home/josh/anaconda2/envs/openai-rs2/lib/python3.6/site-packages/gym/core.py in render(self, mode, **kwargs)
273
274 def render(self, mode='human', **kwargs):
--> 275 return self.env.render(mode, **kwargs)
276
277 def close(self):
/home/josh/anaconda2/envs/openai-rs2/lib/python3.6/site-packages/gym/envs/registration.py in render(mode)
185 env.seed = env._seed
186 def render(mode):
--> 187 return env._render(mode, close=False)
188 def close():
189 env._render("human", close=True)
/home/josh/anaconda2/envs/openai-rs2/lib/python3.6/site-packages/roboschool/gym_urdf_robot_env.py in _render(self, mode, close)
90 if mode=="human":
91 self.scene.human_render_detected = True
---> 92 return self.scene.cpp_world.test_window()
93 elif mode=="rgb_array":
94 self.camera_adjust()
RuntimeError: cannot load '/home/josh/anaconda2/envs/openai-rs2/lib/python3.6/site-packages/roboschool/models_robot/atlas_description/meshes_unplugged/pel': Unable to open file "/home/josh/anaconda2/envs/openai-rs2/lib/python3.6/site-packages/roboschool/models_robot/atlas_description/meshes_unplugged/pel".
@joschu the issue that you pointed at should be fixed (once 1.0.36 compiles and uploads to pypi) @jachiam Let me look into it. Atlas "runs on my machine" - so it is not fundamentally broken... As for the core dump on the second environment - yeah, I see it too, will also investigate.
@jachiam regarding two environments - I also noticed that the problem only occurs if we try rendering in both of them (if either of render calls is commented out, it works)... While that's still not great, it is not as bad as not being able to use two environments in the same python process at all.
@jachiam regarding Atlas - you may need to show / tell me exactly how to reproduce it... I tried on ubuntu and in python containers, with and without anaconda, with python 3.5 and 3.6 and none of those seem to have the problem.
I'll dump my experience first.
install_bullet.sh, pip install cmake
Downloading https://files.pythonhosted.org/packages/d2/58/dfb0a2010a538dbf9add2456b04579f1b0f91e309687f761891d5007de81/cmake-3.13.2.post1-cp27-cp27mu-manylinux1_x86_64.whl (15.9MB)
...
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/cmake'
install_bullet.sh, pip3 install cmake
Downloading https://files.pythonhosted.org/packages/e6/dc/3747156bb7feedf70bea50070af0ec2cc929d04cb68b01fd312caa4d4536/cmake-3.13.2.post1-cp36-cp36m-manylinux1_x86_64.whl (15.9MB)
Successfully installed cmake-3.13.2.post1
so pip3 works without root, pip doesn't. I didn't switch default python, because I can but users are unlikely to.
pip3 installs cmake to /home/kotik/.local/bin/cmake
. That only works if user has PATH=PATH:/home/aaaaaa/.local/bin
. Requires more investigation. What users typically have, what they are likely to have in path, explain their way out. Also, apt install cmake may be much easier.
patchelf: command not found
solved by apt install patchelf
No, doesn't work :(
TMPDIR is defined nowhere, inside install_bullet.sh
it resolves to empty string, in Makefile as well. Also in Makefile there's a reference to /usr/local/include/bullet
as the only path to find bullet includes, which is not $TMPDIR. So installed bullet may be different from included.
I also don't understand the point of changing Makefile to this:
RPATH=-Wl,-z,origin -Wl,--disable-new-dtags,-rpath,'$(TMPDIR)/bullet_local_install/lib',-rpath,'/usr/local/lib'
$ORIGIN mechanism is no longer there, absolute path to $TMPDIR doesn't seem to work, /usr/local is global install, not local (dangerous to install globally a forked bullet)... So I don't understand what exactly the new mechanism is supposed to be.
I am back from the break and ready to fight this again :) @olegklimov I assume you are talking about installing it from source? Let's go through the issues you uncovered step by step:
pip install requiring root. We'll still need pip install
commands to make / upload wheels; however, I agree, let's just install cmake together with the rest of the system packages - this way it is not needed as a pip package when installing from source
patchelf - good point, I'll add it to the instructions
TMPDIR and bullet installation - my idea was to install forked bullet not system-wide, but to a temporary directory... The $TMPDIR variable seems to fail sometimes, so let me modify the code to make that cleaner.
Binary segfaults on import:
In [1]: import roboschool
Python dylib /Library/Frameworks/Python.framework/Versions/3.6/Python referred from cpp_household.so is not found, attempting a relink...
Relinked to /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib successfully
[1] 49778 segmentation fault ipython
Stock install:
otool -L ~/miniconda3/lib/python3.6/site-packages/roboschool/cpp_household.so
/Users/csh/miniconda3/lib/python3.6/site-packages/roboschool/cpp_household.so:
../cpp_household.so (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/Library/Frameworks/Python.framework/Versions/3.6/Python (compatibility version 3.6.0, current version 3.6.0)
@loader_path/.libs/QtOpenGL (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/QtWidgets (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/QtGui (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/QtCore (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/libassimp.4.dylib (compatibility version 4.0.0, current version 4.1.0)
@loader_path/.libs/libBulletSoftBody.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libBulletDynamics.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libBulletCollision.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libLinearMath.dylib (compatibility version 2.87.0, current version 2.87.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
@loader_path/.libs/libBullet3Common.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libBulletInverseDynamics.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libPhysicsClientC_API.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libboost_python3.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
After linking:
otool -L ~/miniconda3/lib/python3.6/site-packages/roboschool/cpp_household.so
/Users/csh/miniconda3/lib/python3.6/site-packages/roboschool/cpp_household.so:
../cpp_household.so (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib (compatibility version 3.6.0, current version 3.6.0)
@loader_path/.libs/QtOpenGL (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/QtWidgets (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/QtGui (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/QtCore (compatibility version 5.10.0, current version 5.10.1)
@loader_path/.libs/libassimp.4.dylib (compatibility version 4.0.0, current version 4.1.0)
@loader_path/.libs/libBulletSoftBody.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libBulletDynamics.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libBulletCollision.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libLinearMath.dylib (compatibility version 2.87.0, current version 2.87.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
@loader_path/.libs/libBullet3Common.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libBulletInverseDynamics.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libPhysicsClientC_API.dylib (compatibility version 2.87.0, current version 2.87.0)
@loader_path/.libs/libboost_python3.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
It looks like it relinked to the wrong python version. I suspect that you either don't want to link against libpython at all or you want to link against it such that it searches the library paths. From the pybind docs: https://github.com/pybind/pybind11/blob/master/docs/compiling.rst#building-manually
On Linux and macOS, it's better to (intentionally) not link against libpython. The symbols will be resolved when the extension library is loaded into a Python binary. This is preferable because you might have several different installations of a given Python version (e.g. the system-provided Python, and one that ships with a piece of commercial software). In this way, the plugin will work with both versions, instead of possibly importing a second Python library into a process that already contains one (which will lead to a segfault).
Retro for instance does not link against libpython:
ldd _retro.cpython-36m-x86_64-linux-gnu.so
linux-vdso.so.1 => (0x00007ffd715e6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fdc06e57000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fdc06b4e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fdc06938000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdc0656e000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdc0746a000)
I tried a few tricks but couldn't get homebrew to install boost-python for my miniconda version of python, it always uses some other python. I installed it through miniconda with conda install boost
but then BOOST_PYTHON3_POSTFIX
was wrong. Could BOOST_PYTHON3_POSTFIX
try 3
and then an empty string if that fails?
Also seems like ~/.forked_bullet
should either be inside the roboschool directory and gitignored or called ~/.roboschool_forked_bullet
so I know where it came from.
After compiling and installing the module it still crashes at runtime:
python -c 'import roboschool'
[1] 78859 segmentation fault python -c 'import roboschool'
So not sure what is up with my machine. Assuming it compiles and imports on mac, I think that the previous segfault is the one worth debugging.
@pzhokhov I pushed a commit hopefully fixing some shell related issues.
install_bullet.sh
should print that it succeeded if it succeeded, I thought it failed because it didn't print very much after configuring.
I added a note for anaconda boost on linux, which seems to be the only way to get that installed correctly (install_boost.sh
doesn't seem to work).
Summary:
Mac Binary: segfault Mac Source: segfault (possibly not worth investigating for now since it could just be my machine) Linux Binary: works Linux Source: works with anaconda boost
The mac binary should not segfault, and I think that's a fixable problem.
@christopherhesse Thanks for going through the process! I'll look into the mac segfault / python linking (I agree, ideally I would like not to link against python libraries if possible, but that's what was written in the Makefile ^_^)
@christopherhesse more specifically, if we don't link against python, the following errors show up:
Undefined symbols for architecture x86_64:
"_PyBool_FromLong", referenced from:
boost::python::detail::caller_arity<2u>::impl<bool (Thingy::*)(Thingy const&), boost::python::default_call_policies, boost::mpl::vector3<bool, Thingy&, Thingy const&> >::operator()(_object*, _object*) in python-binding.o
boost::python::objects::caller_py_function_impl<boost::python::detail::caller<bool (Camera::*)(), boost::python::default_call_policies, boost::mpl::vector2<bool, Camera&> > >::operator()(_object*, _object*) in python-binding.o
boost::python::detail::caller_arity<2u>::impl<bool (World::*)(int), boost::python::default_call_policies, boost::mpl::vector3<bool, World&, int> >::operator()(_object*, _object*) in python-binding.o
boost::python::objects::caller_py_function_impl<boost::python::detail::caller<bool (World::*)(), boost::python::default_call_policies, boost::mpl::vector2<bool, World&> > >::operator()(_object*, _object*) in python-binding.o
which seems to stem from boost. Looking into how to bypass that.
ohhh there is this magic option -undefined dynamic_lookup in BSD ld! This will make a lot of things easier
@pzhokhov I tried the binaries (not the source builds) and everything worked great, thanks for all the hard work on this! Want to merge it to master?
Sure! Before that though, @joschu @olegklimov - last chance to complain?
alright here it goes!
@olegklimov did complain but on some other issue by accident, I'll make a new issue.
Here it is: https://github.com/openai/roboschool/issues/170
Some things I had to do to compile:
diff --git a/roboschool/cpp-household/Makefile b/roboschool/cpp-household/Makefile
index b16e76ba..435089fe 100644
--- a/roboschool/cpp-household/Makefile
+++ b/roboschool/cpp-household/Makefile
@@ -28,7 +28,7 @@ ifeq ($(UNAME),Linux)
$(info Linux, python 2 branch)
PYTHON = $(shell python -c "import sys; print('%i.%i' % sys.version_info[:2])")
endif
- RPATH=-Wl,-z,origin -Wl,--disable-new-dtags,-rpath,'$(BULLET_PATH)/lib',-rpath,'$(HOME)/.boost/lib'
+ RPATH=-Wl,-z,origin -Wl,--disable-new-dtags,-rpath,'$(BULLET_PATH)/lib',-rpath,'$(HOME)/.boost/lib' -L$(BULLET_PATH)/lib
endif
ifeq ($(UNAME),Darwin)
@@ -48,8 +48,8 @@ ifeq ($(UNAME),Darwin)
RPATH = -Wl,-undefined,dynamic_lookup
endif
-INC += `$(PKG) --cflags Qt5Widgets Qt5OpenGL assimp bullet`
-LIBS += `$(PKG) --libs Qt5Widgets Qt5OpenGL assimp bullet`
+INC += `$(PKG) --cflags Qt5Widgets Qt5OpenGL assimp bullet python3`
+LIBS += `$(PKG) --libs Qt5Widgets Qt5OpenGL assimp bullet python3`
LIBS += -lstdc++
INC += -I/usr/local/include/bullet
LIBS += $(RPATH) -lLinearMath -lBullet3Common -lBulletCollision -lBulletDynamics -lBulletInverseDynamics -lBulletSoftBody -lPhysicsClientC_API
diff --git a/roboschool/cpp-household/physics-bullet.cpp b/roboschool/cpp-household/physics-bullet.cpp
index 63c3935e..de77d235 100644
--- a/roboschool/cpp-household/physics-bullet.cpp
+++ b/roboschool/cpp-household/physics-bullet.cpp
@@ -95,7 +95,6 @@ shared_ptr<Robot> World::load_urdf(const std::string& fn, const btTransform& tr,
std::list<shared_ptr<Robot>> World::load_sdf_mjcf(const std::string& fn, bool mjcf)
{
std::list<shared_ptr<Robot>> ret;
- const int MAX_SDF_BODIES = 512;
int bodyIndicesOut[MAX_SDF_BODIES];
int N;
if (mjcf) {
But that only works if I set BULLET_PATH:
BULLET_PATH=/home/me/roboschool/roboschool/cpp-household/bullet_local_install make -C roboschool/cpp-household/
Attempting to start:
gdb --args python3 agent_zoo/RoboschoolHopper_v0_2017may.py
...
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007fffdd451940 in btDiscreteDynamicsWorld::addConstraint(btTypedConstraint*, bool) () from /usr/local/lib/libBulletDynamics.so.2.88
Not sure what is going here. So I didn't manage to make it work so far. Maybe will attempt later.
did complain but on some other issue by accident, I'll make a new issue.
Yes, thanks!
@olegklimov replied in that other issue, let's move the discussion there (https://github.com/openai/roboschool/issues/170)
Tried to pip install roboschool.