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

ConcentricTubeRobot Example Error #58

Open
katahar opened this issue Apr 30, 2024 · 4 comments
Open

ConcentricTubeRobot Example Error #58

katahar opened this issue Apr 30, 2024 · 4 comments

Comments

@katahar
Copy link

katahar commented Apr 30, 2024

Current configuration:
Ubuntu 20.04
Sofa v23.06.00 (From Binary)
Python 3.8.10

When running example (python test_env.py -e concentrictuberobot-v0 -ep 100 -s 100), simulation runs successfully, but when throws this error when training (python rl.py -e concentrictuberobot-v0 -a DQN)

  [SofaRuntime] UFuncTypeError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('<U1'), dtype('float64')) -> None
Traceback (most recent call last):
  File "rl.py", line 114, in <module>
    agent.fit(total_timesteps)
  File "/home/ubuntu20_sofa/SofaGym/agents/SB3Agent.py", line 309, in fit
    self.model.learn(total_timesteps=total_timesteps, reset_num_timesteps=False,
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/dqn/dqn.py", line 265, in learn
    return super().learn(
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/off_policy_algorithm.py", line 334, in learn
    rollout = self.collect_rollouts(
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/off_policy_algorithm.py", line 567, in collect_rollouts
    new_obs, rewards, dones, infos = env.step(actions)
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/base_vec_env.py", line 163, in step
    return self.step_wait()
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_monitor.py", line 76, in step_wait
    obs, rewards, dones, infos = self.venv.step_wait()
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 197, in step_wait
    infos[idx]["terminal_observation"] = self.normalize_obs(infos[idx]["terminal_observation"])
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 240, in normalize_obs
    obs_ = self._normalize_obs(obs, self.obs_rms).astype(np.float32)
  File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 216, in _normalize_obs
    return np.clip((obs - obs_rms.mean) / np.sqrt(obs_rms.var + self.epsilon), -self.clip_obs, self.clip_obs)

Any advice here? I'm pretty sure that I have installed all of the dependencies correctly according to the readme, and this issue is confirmed on multiple installs/machines.

@samuelmyoussef
Copy link
Member

Hello,

It looks like you're running a newer version of stable baselines3, can you make sure you're using v1.7.0 since SofaGym is not compatible with newer versions at the moment.

@katahar
Copy link
Author

katahar commented May 15, 2024

I am using V1.7.0

Is there anything else that I should look out for?

(pip show stable_baselines3 output below)

Name: stable-baselines3
Version: 1.7.0
Summary: Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms.
Home-page: https://github.com/DLR-RM/stable-baselines3
Author: Antonin Raffin
Author-email: [email protected]
License: MIT
Location: /home/ubuntu20_sofa/.local/lib/python3.8/site-packages
Requires: cloudpickle, gym, importlib-metadata, matplotlib, numpy, pandas, torch
Required-by:

@samuelmyoussef
Copy link
Member

You can check if you're running the correct gym version as well.
and what is the numpy version?

@katahar
Copy link
Author

katahar commented May 17, 2024

I'm using:
numpy version 1.24.4
gym version 0.21.0

And to clarify, I am able to run the Catheter Beam example and with learning.

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