BASALT-2022-Karlsruhe / ka-basalt-2022

MIT License
0 stars 0 forks source link

GPU related issues with SB3 #72

Closed rk1a closed 2 years ago

rk1a commented 2 years ago

Observations need to be copied to CPU before/while calling reset():

root@497af7050406:/home/aicrowd# xvfb-run -a python sb3_policy_wrapper.py Using cuda device Wrapping the env with a Monitor wrapper Wrapping the env in a DummyVecEnv. /home/aicrowd/.conda/envs/minerl/lib/python3.8/runpy.py:127: RuntimeWarning: 'minerl.utils.process_watcher' found in sys.modules after import of package 'minerl.utils', but prior to execution of 'minerl.utils.process_watcher'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) Traceback (most recent call last): File "sb3_policy_wrapper.py", line 227, in model.learn(1) File "/home/aicrowd/.conda/envs/minerl/lib/python3.8/site-packages/stable_baselines3/ppo/ppo.py", line 299, in learn return super(PPO, self).learn( File "/home/aicrowd/.conda/envs/minerl/lib/python3.8/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 242, in learn total_timesteps, callback = self._setup_learn( File "/home/aicrowd/.conda/envs/minerl/lib/python3.8/site-packages/stable_baselines3/common/base_class.py", line 429, in _setup_learn self._last_obs = self.env.reset() # pytype: disable=annotation-type-mismatch File "/home/aicrowd/.conda/envs/minerl/lib/python3.8/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 62, in reset self._save_obs(env_idx, obs) File "/home/aicrowd/.conda/envs/minerl/lib/python3.8/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 94, in _save_obs self.buf_obs[key][env_idx] = obs[key] File "/home/aicrowd/.conda/envs/minerl/lib/python3.8/site-packages/torch/_tensor.py", line 645, in array return self.numpy().astype(dtype, copy=False) TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.