microsoft / qlib

Qlib is an AI-oriented quantitative investment platform that aims to realize the potential, empower research, and create value using AI technologies in quantitative investment, from exploring ideas to implementing productions. Qlib supports diverse machine learning modeling paradigms. including supervised learning, market dynamics modeling, and RL.
https://qlib.readthedocs.io/en/latest/
MIT License
14.55k stars 2.53k forks source link

Run cmd python -m qlib.rl.contrib.train_onpolicy --config_path exp_configs/train_opds.yml --run_backtest with error #1764

Open yanzhengkim opened 3 months ago

yanzhengkim commented 3 months ago

python -m qlib.rl.contrib.train_onpolicy --config_path exp_configs/train_opds.yml --run_backtest

/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/env/venvs.py:66: UserWarning: You provided an environment generator that returned an OpenAI Gym environment. We strongly recommend transitioning to Gymnasium environments. Tianshou is automatically wrapping your environments in a compatibility layer, which could potentially cause issues. warnings.warn( Traceback (most recent call last): File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 268, in main(config, run_training=not args.no_training, run_backtest=args.run_backtest) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 241, in main train_and_test( File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 159, in train_and_test train( File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/trainer/api.py", line 63, in train trainer.fit(vessel) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/trainer/trainer.py", line 224, in fit self.vessel.train(vector_env) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/trainer/vessel.py", line 171, in train collector = Collector(self.policy, vector_env, VectorReplayBuffer(self.buffer_size, len(vector_env))) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/data/collector.py", line 80, in init self.reset(False) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/data/collector.py", line 131, in reset self.reset_env(gym_reset_kwargs) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/data/collector.py", line 147, in reset_env obs, info = self.env.reset(**gym_reset_kwargs) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/utils/finite_env.py", line 233, in reset for i, o in zip(request_id, super().reset(request_id)): File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/env/venvs.py", line 280, in reset assert ( AssertionError: The environment does not adhere to the Gymnasium's API. Exception ignored in: <function DataQueue.del at 0x7fc212bf9dc0> Traceback (most recent call last): File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/utils/data_queue.py", line 148, in del self.cleanup() File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/utils/data_queue.py", line 101, in cleanup self._queue.get(block=False) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/queues.py", line 111, in get res = self._recv_bytes() File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/connection.py", line 216, in recv_bytes buf = self._recv_bytes(maxlength) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/connection.py", line 414, in _recv_bytes buf = self._recv(4) File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/connection.py", line 383, in _recv raise EOFError EOFError:

yanzhengkim commented 3 months ago

Does anyone meet the same error? wanna know how to solve this, thanks.

mrwang1992 commented 3 months ago

try use this version package

tianshou==0.4.10 gym==0.26.2 gymnasium==0.29.1

yanzhengkim commented 3 months ago

try use this version package

tianshou==0.4.10 gym==0.26.2 gymnasium==0.29.1 it worked for me ! thank you !

CottePutman commented 1 month ago

try use this version package

tianshou==0.4.10 gym==0.26.2 gymnasium==0.29.1

It worked, Thx! Btw to anyone who may concern, shimmy==1.2.1 is compatible with the mentioned settings.