NVlabs / DiffRL

[ICLR 2022] Accelerated Policy Learning with Parallel Differentiable Simulation
https://short-horizon-actor-critic.github.io/
Other
263 stars 43 forks source link

Error when --render the humanoid #7

Closed ANABUR920 closed 1 year ago

ANABUR920 commented 1 year ago

Bacis info my system is Ubuntu 20.8, GPU 3080, NVCC 11.6, gcc/g++ 7.5.0. Other setting is same as the env.

After I train the train_shac.py humanoid, I want to render it via ucd

My command is python train_shac.py --cfg ./cfg/shac/humanoid.yaml --checkpoint ./logs/SNUHumanoid/shac/40/best_policy.pt --play --render However, it cannot work for unexpected reason:

Using cached kernels Setting seed: 0 ~/anaconda3/envs/shac/lib/python3.8/site-packages/gym/spaces/box.py:127: UserWarning: WARN: Box bound precision lowered by casting to float32 logger.warn(f"Box bound precision lowered by casting to {self.dtype}") 28 27 Start joint_q: [0.0, 1.35, 0.0, -0.7071067811865475, -0.0, -0.0, 0.7071067811865476, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ~DiffRL/dflex/dflex/model.py:1687: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at /opt/conda/conda-bld/pytorch_1646755903507/work/torch/csrc/utils/tensor_new.cpp:210.) m.shape_transform = torch.tensor(transform_flatten_list(self.shape_transform), dtype=torch.float32, device=adapter) num_act = 21 num_envs = 1 num_actions = 21 num_obs = 76 Sequential( (0): Linear(in_features=76, out_features=256, bias=True) (1): ELU(alpha=1.0) (2): LayerNorm((256,), eps=1e-05, elementwise_affine=True) (3): Linear(in_features=256, out_features=128, bias=True) (4): ELU(alpha=1.0) (5): LayerNorm((128,), eps=1e-05, elementwise_affine=True) (6): Linear(in_features=128, out_features=21, bias=True) (7): Identity() ) Parameter containing: tensor([-1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1., -1.], device='cuda:0', requires_grad=True) Sequential( (0): Linear(in_features=76, out_features=128, bias=True) (1): ELU(alpha=1.0) (2): LayerNorm((128,), eps=1e-05, elementwise_affine=True) (3): Linear(in_features=128, out_features=128, bias=True) (4): ELU(alpha=1.0) (5): LayerNorm((128,), eps=1e-05, elementwise_affine=True) (6): Linear(in_features=128, out_features=1, bias=True) ) Traceback (most recent call last): File "train_shac.py", line 114, in traj_optimizer.play(cfg_train) ~/DiffRL/algorithms/shac.py", line 561, in play self.run(cfg['params']['config']['player']['games_num']) ~/anaconda3/envs/shac/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, *kwargs) ~/DiffRL/algorithms/shac.py", line 377, in run mean_policy_loss, mean_policy_discounted_loss, mean_episode_length = self.evaluate_policy(num_games = num_games, deterministic = not self.stochastic_evaluation) ~/anaconda3/envs/shac/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, **kwargs) ~/DiffRL/algorithms/shac.py", line 317, in evaluate_policy obs = self.obs_rms.normalize(obs) ~/DiffRL/utils/running_mean_std.py", line 56, in normalize result = (arr - self.mean) / torch.sqrt(self.var + 1e-5) RuntimeError: The size of tensor a (76) must match the size of tensor b (53) at non-singleton dimension 1

Do you have any idea to fix that

eanswer commented 1 year ago

Hi, sorry for the confusion. You need to use ./cfg/shac/snu_humanoid.yaml for the muscle-actuated humanoid. The humanoid.yaml is for the torque-driven humanoid.