stanfordnmbl / osim-rl

Reinforcement learning environments with musculoskeletal models
http://osim-rl.stanford.edu/
MIT License
882 stars 249 forks source link

python crashed when running "ProstheticsEnv(visualize=True)" #134

Closed recordmp3 closed 5 years ago

recordmp3 commented 6 years ago

I have finished all steps in tutorial to set the anaconda environment. My system is windows. When running ProstheticsEnv(visualize=True) python will crash, although running visualize = False it won't, What's wrong???

kidzik commented 6 years ago

Can you please provide more details? What error are you getting?

RchalYang commented 6 years ago

I got the same problem. I'm using the code given in "Basic Usage" to test my environment on Windows, and python just crash when running "ProstheticsEnv(visualize=True)". My environment(given by command:"conda info"): platform : win-64 user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Windows/10 Windows/10.0.16299 administrator : True netrc file : None offline mode : False

kidzik commented 6 years ago

Does it crash without any error? What is the output?

decoderkurt commented 6 years ago

ProstheticsEnv(visualize=True) still not working under windows 10. I should set visualize=False explicitly

AdamStelmaszczyk commented 6 years ago

Hello in this year competition! :)

Visualization also doesn't work on Linux, it hangs with:

(opensim-rl) ✘-INT ~/workspace/ai4prosthetics/osim-rl/examples [master|✔] 
14:06 $ python randomrun.py 
Updating Model file from 30000 to latest format...
Loaded model gait14dof22musc_pros from file /home/adam/miniconda3/envs/opensim-rl/lib/python3.6/site-packages/osim/env/../models/gait14dof22musc_pros_20180507.osim
Model 'gait14dof22musc_pros' has subcomponents with duplicate name 'back'.
The duplicate is being renamed to 'back_0'.
Model 'gait14dof22musc_pros' has subcomponents with duplicate name 'pros_foot_r'.
The duplicate is being renamed to 'pros_foot_r_0'.
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.
std::exception in 'SimTK::State const & OpenSim::Manager::integrate(double)': SimTK Exception thrown at VisualizerProtocol.cpp:410:
  Error detected by Simbody method VisualizerProtocol: An attempt to write() 1 bytes to pipe 7 failed with errno=32 (Broken pipe).
  (Required condition 'status!=-1' was not met.)

I tried it 3 times, the result was the same.

System info:

14:09 $ uname -a
Linux adam-ThinkPad-T520 4.8.0-53-generic #56~16.04.1-Ubuntu SMP Tue May 16 01:18:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

To setup opensim-rl env I followed README:

conda create -n opensim-rl -c kidzik opensim python=3.6.1
source activate opensim-rl
conda install -c conda-forge lapack git
pip install git+https://github.com/stanfordnmbl/osim-rl.git

With ProstheticsEnv(visualize=False) it works, but I need visualization :)

kidzik commented 6 years ago

@decoderkurt @RchalYang @recordmp3 are you using PowerShell Command Prompt? I tried on a clean windows 10 instance and everything seems to be working fine https://github.com/stanfordnmbl/osim-rl/issues/140 Can you please provide steps to reproduce the error?

AdamStelmaszczyk commented 6 years ago

I'm pretty sure you will be able to reproduce mine easily on for example Ubuntu 16.04 (I'm on Linux Mint, but it's similar).

kidzik commented 6 years ago

@AdamStelmaszczyk Can you please post the output of conda list? Everything works fine on my Ubuntu 16 and 18

AdamStelmaszczyk commented 6 years ago
(opensim-rl) ✘-TERM ~/workspace/ai4prosthetics/osim-rl/examples [master|✚ 2] 
22:37 $ conda list
# packages in environment at /home/adam/miniconda3/envs/opensim-rl:
#
atomicwrites              1.1.5                     <pip>
attrs                     18.1.0                    <pip>
bzip2                     1.0.6                h470a237_2    conda-forge
ca-certificates           2018.03.07                    0  
certifi                   2018.4.16                py36_0  
cffi                      1.11.5                    <pip>
chardet                   3.0.4                     <pip>
click                     6.7                       <pip>
colorama                  0.3.9                     <pip>
curl                      7.61.0               h93b3f91_1    conda-forge
Cython                    0.28.4                    <pip>
expat                     2.2.5                hfc679d8_1    conda-forge
flatbuffers               2015.12.22.1              <pip>
freeglut                  3.0.0                         4    kidzik
funcsigs                  1.0.2                     <pip>
future                    0.16.0                    <pip>
gettext                   0.19.8.1                      0    conda-forge
git                       2.18.0          pl526hbb17d3c_1    conda-forge
glfw                      1.7.0                     <pip>
gym                       0.9.3                     <pip>
idna                      2.7                       <pip>
imageio                   2.3.0                     <pip>
krb5                      1.14.6                        0    conda-forge
lapack                    3.6.1                         1    conda-forge
libffi                    3.2.1                         3    conda-forge
libgcc-ng                 7.2.0                hdf63c60_3  
libgfortran               3.0.0                         1  
libiconv                  1.15                 h470a237_1    conda-forge
libssh2                   1.8.0                h5b517e9_2    conda-forge
libstdcxx-ng              7.2.0                hdf63c60_3  
more-itertools            4.3.0                     <pip>
mujoco-py                 0.5.7                     <pip>
ncurses                   6.1                  hfc679d8_1    conda-forge
numpy                     1.15.0                    <pip>
openblas                  0.2.19                        0    kidzik
opensim                   4.0.0                   py36_17    kidzik
openssl                   1.0.2o               h20670df_0  
osim-rl                   2.0.0                     <pip>
patchelf                  0.9                  hf484d3e_2  
perl                      5.26.2               h470a237_0    conda-forge
Pillow                    5.2.0                     <pip>
pip                       10.0.1                   py36_0  
pluggy                    0.7.1                     <pip>
psutil                    5.4.6                     <pip>
py                        1.5.4                     <pip>
pycparser                 2.18                      <pip>
pyglet                    1.3.2                     <pip>
PyOpenGL                  3.1.0                     <pip>
pytest                    3.7.0                     <pip>
python                    3.6.6                h5001a0f_0    conda-forge
PyYAML                    3.13                      <pip>
ray                       0.5.0                     <pip>
readline                  7.0                  haf1bffa_1    conda-forge
redis                     2.10.6                    <pip>
requests                  2.19.1                    <pip>
setuptools                39.2.0                   py36_0  
six                       1.11.0                    <pip>
sqlite                    3.24.0               h2f33b56_0    conda-forge
timeout-decorator         0.4.0                     <pip>
tk                        8.6.8                         0    conda-forge
urllib3                   1.23                      <pip>
wheel                     0.31.1                   py36_0  
xz                        5.2.4                h14c3975_4  
zlib                      1.2.11               ha838bed_2

With gym 0.10.4 it's the same. From time to time I can see the visualization.

The last lines:

std::exception in 'SimTK::State const & OpenSim::Manager::integrate(double)': SimTK Exception thrown at VisualizerProtocol.cpp:410:
  Error detected by Simbody method VisualizerProtocol: An attempt to write() 1 bytes to pipe 7 failed with errno=32 (Broken pipe).
  (Required condition 'status!=-1' was not met.)

are a red herring I think. I.e. this error appears on the very end, when cleaning up stuff, because it is in shutdownGUI. I also see these lines when closing the visualization window clicking on X with mouse.

But something may crash before those lines (and it's not logging). Maybe it's a race condition (so sometimes it works).

kidzik commented 6 years ago

@AdamStelmaszczyk do you have any updates on this issue? Can you retrace the error or do you have a script which would allow us to reproduce it?

AdamStelmaszczyk commented 6 years ago

I'm still facing this issue. What I do is just starting the run with visualization several times and after a couple of starts I'm getting lucky and it doesn't crash. Could automatise this starting, but not sure it's worth.

I didn't try much to trace the error, I'm not sure how to proceed on that. Feels time consuming.

randomrun.py from this repo reproduces it. But it works on yours Ubuntu, so I was thinking maybe I will spin AMI like we did last year, so that you can spin exactly the same one. The problem is that X forwarding must be figured out and I didn't have time to do that.

sandipan1 commented 6 years ago

I am facing a similar error I am running on a local machine with display `>>> env = ProstheticsEnv(visualize=True) Updating Model file from 30000 to latest format... Loaded model gait14dof22musc_pros from file /home/sandipan/zrl/prosthetics/osim-rl/osim/env/../models/gait14dof22musc_pros_20180507.osim Model 'gait14dof22musc_pros' has subcomponents with duplicate name 'back'. The duplicate is being renamed to 'back_0'. Model 'gait14dof22musc_pros' has subcomponents with duplicate name 'pros_foot_r'. The duplicate is being renamed to 'pros_foot_r_0'. 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.

observation = env.reset() for i in range(200): ... o, r, d, i = env.step(env.action_space.sample()) ... X Error of failed request: BadRequest (invalid request code or no such operation) Major opcode of failed request: 154 (GLX) Minor opcode of failed request: 187 () Serial number of failed request: 195 Current serial number in output stream: 195 Traceback (most recent call last): File "", line 2, in File "/home/sandipan/zrl/prosthetics/osim-rl/osim/env/osim.py", line 345, in step self.osim_model.integrate() File "/home/sandipan/zrl/prosthetics/osim-rl/osim/env/osim.py", line 255, in integrate self.state = self.manager.integrate(self.stepsize * self.istep) File "/home/sandipan/Documents/yes/envs/osim/lib/python3.6/site-packages/opensim/simulation.py", line 38434, in integrate return _simulation.Manager_integrate(self, finalTime) RuntimeError: std::exception in 'SimTK::State const & OpenSim::Manager::integrate(double)': SimTK Exception thrown at VisualizerProtocol.cpp:410: Error detected by Simbody method VisualizerProtocol: An attempt to write() 1 bytes to pipe 7 failed with errno=32 (Broken pipe). (Required condition 'status!=-1' was not met.) `

Any progress or workaround for this ?

keavil commented 6 years ago

I have met this problem and I got it solved in a strange way. I run this example script in Windows 10:

from osim.env import ProstheticsEnv

env = ProstheticsEnv(visualize=True)
observation = env.reset()
for i in range(200):
    observation, reward, done, info = env.step(env.action_space.sample())

When I run this in C:\ (to be exact, C:\Users\username), python suddenly crashes without any traceback. However, when I run this in D:\ , everything seems ok. And when I run D:\example.py in C:\ , it crashes in the same way. My anaconda is installed in D:\anaconda3.

I don't know why this happened but maybe it can help you.

aadimator commented 6 years ago

@keavil this worked for me as well. I moved my codebase to the C:\ drive, where I've installed Anaconda, and it ran without any problems.

marnunez commented 3 years ago

Can reproduce the problem with OpenSim 4.2-2020-09-02-8bd2ec0, python 3.7.9 from conda-forge and Windows 10. If I load a Model from my D: drive with setUseVisualizer(True), it silently crashes. Moving the model to my C: drive solves the issue.