isaac-sim/IsaacGymEnvs

BUG CRASH when recording video (python train.py task=HumanoidAMP capture_video=True) --> render() got an unexpected keyword argument 'mode'

Opened this issue · 2 comments

Hello,

I've discovered IsaacGymEnvs can capture video (capture_video=True) for static viewers (e.g. AnymalTerrain), but not dynamic ones (HumanoidAMP).

IsaacGymEnvs immediately crashes when I run:

python train.py task=HumanoidAMP capture_video=True

Here is the error it produces:

Error executing job with overrides: ['task=HumanoidAMP', 'capture_video=True']
Traceback (most recent call last):
  File "train.py", line 190, in launch_rlg_hydra
    runner.run({
  File "/home/gene/code/rl_games/rl_games/torch_runner.py", line 121, in run
    self.run_train(args)
  File "/home/gene/code/rl_games/rl_games/torch_runner.py", line 102, in run_train
    agent.train()
  File "/home/gene/code/IsaacGymEnvs/isaacgymenvs/learning/common_agent.py", line 120, in train
    self.obs = self.env_reset()
  File "/home/gene/code/rl_games/rl_games/common/a2c_common.py", line 507, in env_reset
    obs = self.vec_env.reset()
  File "/home/gene/code/IsaacGymEnvs/isaacgymenvs/utils/rlgames_utils.py", line 249, in reset
    return self.env.reset()
  File "/home/gene/anaconda3/envs/isaacgym/lib/python3.8/site-packages/gym/wrappers/record_video.py", line 58, in reset
    self.start_video_recorder()
  File "/home/gene/anaconda3/envs/isaacgym/lib/python3.8/site-packages/gym/wrappers/record_video.py", line 75, in start_video_recorder
    self.video_recorder.capture_frame()
  File "/home/gene/anaconda3/envs/isaacgym/lib/python3.8/site-packages/gym/wrappers/monitoring/video_recorder.py", line 157, in capture_frame
    frame = self.env.render(mode=render_mode)
TypeError: render() got an unexpected keyword argument 'mode'

I found this error, because I attempted to duplicate code from HumanoidAMP to AnymalTerrain (since it makes sense for the viewer to also be dynamic, by tracking the agent and keeping it in frame), but it also crashes and produces the same error.

Searching online, it seems people have faced various issues relating to gym versioning/compatibility, but not this specific issue. I haven't been able to figure out a solution after debugging for a day or two.

I would appreciate it if someone could take a look and hopefully spot a quick solution! Thank you very much for your help : )

I did not mean to close this issue, as it is still unresolved. I wanted to post my installation process and conda environment, so that you could easily replicate this bug crash. Let me know if I can provide any additional information, thank you !!

Here was my installation process:

conda create -n isaacgym python=3.8.13
conda activate isaacgym
git clone git@github.com:NVIDIA-Omniverse/IsaacGymEnvs.git
cd IsaacGymEnvs
pip install -e .
cd isaacgym
pip install -e .
pip install numpy==1.20.0

Here is my conda environment:

conda list
# packages in environment at /home/gene/anaconda3/envs/isaacgym:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
absl-py                   1.4.0                    pypi_0    pypi
aiosignal                 1.3.1                    pypi_0    pypi
antlr4-python3-runtime    4.9.3                    pypi_0    pypi
attrs                     23.1.0                   pypi_0    pypi
ca-certificates           2023.01.10           h06a4308_0  
cachetools                5.3.0                    pypi_0    pypi
certifi                   2022.12.7                pypi_0    pypi
charset-normalizer        3.1.0                    pypi_0    pypi
click                     8.0.4                    pypi_0    pypi
cloudpickle               2.2.1                    pypi_0    pypi
cmake                     3.26.3                   pypi_0    pypi
distlib                   0.3.6                    pypi_0    pypi
docker-pycreds            0.4.0                    pypi_0    pypi
filelock                  3.12.0                   pypi_0    pypi
frozenlist                1.3.3                    pypi_0    pypi
gitdb                     4.0.10                   pypi_0    pypi
gitpython                 3.1.31                   pypi_0    pypi
google-auth               2.17.3                   pypi_0    pypi
google-auth-oauthlib      0.4.6                    pypi_0    pypi
grpcio                    1.43.0                   pypi_0    pypi
gym                       0.23.1                   pypi_0    pypi
gym-notices               0.0.8                    pypi_0    pypi
hydra-core                1.3.2                    pypi_0    pypi
idna                      3.4                      pypi_0    pypi
imageio                   2.27.0                   pypi_0    pypi
importlib-metadata        6.5.0                    pypi_0    pypi
importlib-resources       5.12.0                   pypi_0    pypi
isaacgym                  1.0rc4                    dev_0    <develop>
isaacgymenvs              1.3.4                     dev_0    <develop>
jinja2                    3.1.2                    pypi_0    pypi
jsonschema                4.17.3                   pypi_0    pypi
ld_impl_linux-64          2.38                 h1181459_1  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libstdcxx-ng              11.2.0               h1234567_1  
lit                       16.0.1                   pypi_0    pypi
markdown                  3.4.3                    pypi_0    pypi
markupsafe                2.1.2                    pypi_0    pypi
mpmath                    1.3.0                    pypi_0    pypi
msgpack                   1.0.5                    pypi_0    pypi
ncurses                   6.4                  h6a678d5_0  
networkx                  3.1                      pypi_0    pypi
ninja                     1.11.1                   pypi_0    pypi
numpy                     1.20.0                   pypi_0    pypi
nvidia-cublas-cu11        11.10.3.66               pypi_0    pypi
nvidia-cuda-cupti-cu11    11.7.101                 pypi_0    pypi
nvidia-cuda-nvrtc-cu11    11.7.99                  pypi_0    pypi
nvidia-cuda-runtime-cu11  11.7.99                  pypi_0    pypi
nvidia-cudnn-cu11         8.5.0.96                 pypi_0    pypi
nvidia-cufft-cu11         10.9.0.58                pypi_0    pypi
nvidia-curand-cu11        10.2.10.91               pypi_0    pypi
nvidia-cusolver-cu11      11.4.0.1                 pypi_0    pypi
nvidia-cusparse-cu11      11.7.4.91                pypi_0    pypi
nvidia-nccl-cu11          2.14.3                   pypi_0    pypi
nvidia-nvtx-cu11          11.7.91                  pypi_0    pypi
oauthlib                  3.2.2                    pypi_0    pypi
omegaconf                 2.3.0                    pypi_0    pypi
opencv-python             4.7.0.72                 pypi_0    pypi
openssl                   1.1.1t               h7f8727e_0  
packaging                 23.1                     pypi_0    pypi
pathtools                 0.1.2                    pypi_0    pypi
pillow                    9.5.0                    pypi_0    pypi
pip                       23.0.1           py38h06a4308_0  
pkgutil-resolve-name      1.3.10                   pypi_0    pypi
platformdirs              3.2.0                    pypi_0    pypi
promise                   2.3                      pypi_0    pypi
protobuf                  3.20.3                   pypi_0    pypi
psutil                    5.9.5                    pypi_0    pypi
pyasn1                    0.5.0                    pypi_0    pypi
pyasn1-modules            0.3.0                    pypi_0    pypi
pyrsistent                0.19.3                   pypi_0    pypi
python                    3.8.13               haa1d7c7_1  
pyvirtualdisplay          3.0                      pypi_0    pypi
pyyaml                    6.0                      pypi_0    pypi
ray                       1.13.0                   pypi_0    pypi
readline                  8.2                  h5eee18b_0  
requests                  2.28.2                   pypi_0    pypi
requests-oauthlib         1.3.1                    pypi_0    pypi
rl-games                  1.6.0                    pypi_0    pypi
rsa                       4.9                      pypi_0    pypi
scipy                     1.10.1                   pypi_0    pypi
sentry-sdk                1.20.0                   pypi_0    pypi
setproctitle              1.3.2                    pypi_0    pypi
setuptools                66.0.0           py38h06a4308_0  
shortuuid                 1.0.11                   pypi_0    pypi
six                       1.16.0                   pypi_0    pypi
smmap                     5.0.0                    pypi_0    pypi
sqlite                    3.41.2               h5eee18b_0  
sympy                     1.11.1                   pypi_0    pypi
tensorboard               2.11.2                   pypi_0    pypi
tensorboard-data-server   0.6.1                    pypi_0    pypi
tensorboard-plugin-wit    1.8.1                    pypi_0    pypi
tensorboardx              2.6                      pypi_0    pypi
termcolor                 2.2.0                    pypi_0    pypi
tk                        8.6.12               h1ccaba5_0  
torch                     2.0.0                    pypi_0    pypi
torchvision               0.15.1                   pypi_0    pypi
triton                    2.0.0                    pypi_0    pypi
typing-extensions         4.5.0                    pypi_0    pypi
urllib3                   1.26.15                  pypi_0    pypi
virtualenv                20.22.0                  pypi_0    pypi
wandb                     0.12.21                  pypi_0    pypi
werkzeug                  2.2.3                    pypi_0    pypi
wheel                     0.38.4           py38h06a4308_0  
xz                        5.2.10               h5eee18b_1  
zipp                      3.15.0                   pypi_0    pypi
zlib                      1.2.13               h5eee18b_0  

@generush Hi. I have encountered the same issue. After lots of debugging I find that it is not a bug in rl_games or gym or any other packages, but indeed in humanoid_amp_base.py.

So to fix this issue just simply change the following lines in humanoid_amp_base.py in line 392 from:

def render(self):
    if self.viewer and self.camera_follow:
        self._update_camera()

    super().render()
    return

to

def render(self, mode="rgb_array"):
    if self.viewer and self.camera_follow:
        self._update_camera()

    return super().render(mode)

Hope this help.