Closed sgrigory closed 1 year ago
The snippet below with repeated env.step causes a segmentation fault. A single env.step works fine.
env.step
import numpy as np import envpool env = envpool.make(task_id="CartPole-v0", env_type="gym", num_envs=1) env.step(np.array(1)) env.step(np.array(1))
$ python reproduce.py /home/grigorysizov/anaconda3/envs/torch_rl/lib/python3.9/site-packages/gymnasium/envs/registration.py:313: UserWarning: WARN: No module named 'glfw' logger.warn(str(e)) Segmentation fault (core dumped)
The code doesn't crash, or, if this operation is invalid, gives a user-friendly error message
Envpool 0.8.1 is installed through pip in a conda environment:
pip
import envpool, numpy, sys print(envpool.__version__, numpy.__version__, sys.version, sys.platform) ----------- 0.8.1 1.23.5 3.9.15 (main, Nov 24 2022, 14:31:59) [GCC 11.2.0] linux
This came up when working on https://github.com/pytorch/rl/pull/734 - integrating EnvPool into TorchRL
You need to use np.array([1]) instead of np.array(1), the first one is a 1d array while the second one is a 0d array.
np.array([1])
np.array(1)
Thank you!
Describe the bug
The snippet below with repeated
env.step
causes a segmentation fault. A singleenv.step
works fine.To Reproduce
Expected behavior
The code doesn't crash, or, if this operation is invalid, gives a user-friendly error message
System info
Envpool 0.8.1 is installed through
pip
in a conda environment:Additional context
This came up when working on https://github.com/pytorch/rl/pull/734 - integrating EnvPool into TorchRL
Checklist