-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
- I have marked all applicable categories:
- [1] exception-raising bug
- [1] RL algorithm bug
- documentation request (i.e. "X is missing from the documentation.")
- new feature request
- [1] I have visited the source website
- [1] I have searched through the issue tracker for duplicates
- [1] I have mentioned version numbers, operating system and environment, where applicable:
import tianshou, gymnasium as gym, torch, numpy, sys print(tianshou.__version__, gym.__version__, torch.__version__, numpy.__version__, sys.version, sys.platform)
0.5.1 0.28.1 1.4.0 1.22.4 3.8.16 (default, Mar 2 2023, 03:21:46)
[GCC 11.2.0] linux
I defined my own environment according to gym standard. I modified the code from a example test_PPO.
I got the following Error:
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Cannot unify float64 and array(float64, 1d, C) for 'gae.2', defined at /home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py (431)
The whole message is:
2023-05-05 16:17:06.057039: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: :/home/test/CoppeliaSim_Edu_V4_2_0_Ubuntu20_04/:/home/test/CoppeliaSim_Edu_V4_2_0_Ubuntu20_04/
2023-05-05 16:17:06.057070: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Epoch #1: 4%|####8 | 5422/150000 [00:06<02:49, 851.45it/s]
Traceback (most recent call last):
File "/home/test/DRL-EMS/tianshou-master/ev_exp/test_ppo.py", line 208, in
test_ppo()
File "/home/test/DRL-EMS/tianshou-master/ev_exp/test_ppo.py", line 183, in test_ppo
for epoch, epoch_stat, info in trainer:
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/trainer/base.py", line 299, in next
self.policy_update_fn(data, result)
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/trainer/onpolicy.py", line 131, in policy_update_fn
losses = self.policy.update(
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py", line 276, in update
batch = self.process_fn(batch, buffer, indices)
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/modelfree/ppo.py", line 92, in process_fn
batch = self._compute_returns(batch, buffer, indices)
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/modelfree/a2c.py", line 101, in _compute_returns
unnormalized_returns, advantages = self.compute_episodic_return(
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py", line 343, in compute_episodic_return
advantage = gae_return(v_s, v_s, rew, end_flag, gamma, gae_lambda)
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
error_rewrite(e, 'typing')
File "/home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Cannot unify float64 and array(float64, 1d, C) for 'gae.2', defined at /home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py (431)
File "../../miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py", line 431:
def _gae_return(
#print(returns.shape)
for i in range(len(rew) - 1, -1, -1):
^
During: typing of assignment at /home/test/miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py (431)
File "../../miniconda3/envs/tianshou/lib/python3.8/site-packages/tianshou/policy/base.py", line 431:
def _gae_return(
#print(returns.shape)
for i in range(len(rew) - 1, -1, -1):
I tried several methods to convert the type but nothing worked out. So I wonder what can I do? Can you give some example for self-define env as a class in tianshu? to help us understand the rule. My environment works well in spinningup.