Closed erlenlok closed 4 years ago
Hmm... At very first glance it seems to be issue with the difference in Windows multiprocessing implementation. Since btgym has not been tested with Win, I need time to investigate it till I can fix it.
I spent some time to look into this since I am using windows. It turned out this has nothing to do with multiprocessing and it's the lock used in logging.Logger which cannot be pickled on windows ( I think this might be related to some platform dependent implementation of lock, but I didn't dig deeper). I found that using logger from logbook instead of python default logging module can workaround this issue and run the setting_up_environment_basic.ipynb to the end. In the last step of that notebook, it will run a few steps (1500 - 2000), output some plots, and then it will raise the following error: Resource temporarily unavailable. And this happens both on my windows and linux (ubuntu 14.04 LTS) systems. My python version is 3.6.2
Again Traceback (most recent call last)
@mysl ,
I think this might be related to some platform dependent implementation of lock
- yes, it is indeed. Actually I haven't worked on issue either. Can you share a piece of code of this logger workaround?
error: Resource temporarily unavailable. This error usually means orphaned child process is blocking zmq socket someway.
- Have you made some modifications to the notebook? - Actually I can't replicate this error in notebook mentioned ( I'm running MacOS).
Have you manually interrupted jup. kernel? If yes, which command/tab used?
When you updated btgym last time?
@Kismuz
Can you share a piece of code of this logger workaround?
Sure. It's just simply using logger from logbook instead of logging for btgym.envs.backtrader.py, as the follow picture shows.
This error usually means orphaned child process is blocking zmq socket someway.
Yeah, looks like it. BTW, I forgot to mention, that when I running the notebook, I skipped the part of 'registering environment', because if I run it will also raise error 'Again, resource temporarily unavailable'. Does that imply that environment not clean up completely by calling close (at least in windows?)?
Have you made some modifications to the notebook?
No.
Have you manually interrupted jup. kernel? If yes, which command/tab used?
I probably did. I used ctrl + C. Actually I tried killing all the python processes today, and rerun this without manually interrupting jup.kernel. It shows the same behavior: run and plot a few steps, and Again, resource temporarily unavailable
That's rather strange. Unfortunately I don't have Win installed to replicate it. BTGYM launches at least two separate processes, not counting jupyter kernel itself:
btgym_server as backend for environment API, default port 5000
data_server as data providing backend for one or more btgym_server(s), default port 4999
calling env.close() should stop both and it usually does (at least on MACOS and Linux);
interrupting parent kernel should stop childs as well, as they are not demonized, but:
there is some caveat in interrupting jupyter kernel: It can not be done via Ctrl-C, equivalent is web interface [KERNEL]-->[INTERRUPT]. This combination correctly finishes all stuff, while hitting [KERNEL]-->[RESTART] or [RESTART AND CLEAR...] for some reasons leaves child processes orphaned. In this case list processes on specified ports:
lsof -i:5000
lsof -i:4999
...and do manual kill.
Note, that when running A3C examples there are also 12230 and 12231 to watch for.
Usually it throws errors like:
One more things: it has been a os-specific lurking rendering error, fixed today, related to episode rendering, worth checking here, bottom: https://github.com/Kismuz/btgym/issues/24
@Kismuz thanks for reply. I will update the code and have a try when I have a chance.
BTW, there is another 'incompatibility' with windows, this file https://github.com/Kismuz/btgym/blob/master/examples/data/test_bent_sine_1min_period_300%3E1500_delta0002.csv, it has a character '>' which is invalid for file name, and makes my checkout always fail. Would you pls fix that ? thanks!
done
I updated to latest code, it seems not helping. And this time, the More control section in the notebook raised exception as follows. It looks it's somehow blocked when the environment is trying closing.
============================================================= Env.dataset: <btgym.datafeed.BTgymDataset object at 0x000000EEF8D65E80>
Env.strategy: <class 'btgym.strategy.base.BTgymBaseStrategy'>
Env.engine: <backtrader.cerebro.Cerebro object at 0x000000EE83F49F60>
Env.renderer: <btgym.rendering.renderer.BTgymRendering object at 0x000000EEF8D65630>
Env.network_address: tcp://127.0.0.1:5555
Parameters [engine]: start_cash : 100 broker_commission : 0.002 fixed_stake : 10
Parameters [dataset]: filename : ../examples/data/DAT_ASCII_EURUSD_M1_2016.csv sep : ; header : 0 index_col : 0 parse_dates : True names : ['open', 'high', 'low', 'close', 'volume'] timeframe : 1 datetime : 0 open : 1 high : 2 low : 3 close : 4 volume : -1 openinterest : -1 start_weekdays : [0, 1, 2] start_00 : True episode_duration : {'days': 1, 'hours': 23, 'minutes': 55} time_gap : {'days': 0, 'hours': 5}
Parameters [strategy]: state_shape : {'raw_state': Box(30, 4)} drawdown_call : 30 target_call : 10 dataset_stat : None episode_stat : None portfolio_actions : ('hold', 'buy', 'sell', 'close') skip_frame : 1
ZMQError Traceback (most recent call last)
It looks there might be a long way to go to support running btgym on windows. I might need to switch to linux. Thanks anyway!
@mysl , I have pushed branch: https://github.com/Kismuz/btgym/tree/force_data_server_shutdown try if it works for you.
@Kismuz thanks, tried the force_data_server_shutdown, it looks the issue that environment.close failed resolved. But in the last step of running the agent, there is an AssertionError. I checked the console running the jupyter kernel, it shows some pickling error of pandas dataframe, which I guess might be the reason for the AssertionError.
========================================================== AssertionError Traceback (most recent call last) c:\study\btgym-master\btgym\envs\backtrader.py in _reset(self, state_only) 614 try: --> 615 assert self.observation_space.contains(self.env_response[0]) 616 AssertionError:
draw_episode() again... Have you ever got correct episode renderings under Win?
yeah, I got episode rendering under windows the first time I posted in this thread. It will output several plots and raise the resource unavailable error. See my previous response, there is a picture attached there. After I updated the code, I can't get the rendering anymore.
At picture attached there is state
rendering. I meant picture with entire episode like this one:
https://github.com/Kismuz/btgym/blob/master/examples/img/2017-11-24_18.37.50.png
then NO
...than it definitely was draw_cerebro() right from the start. Pickle serialisation error when starting DrawCerebro subprocess. Exactly, it fails to serialise pandas.dataframe object and latter can only be found inside cerebro instance containing final episode data. Something similar to logger issue; Win specific. Have to figure how to sort it out.
Switched entire package to logbook
module; rendering still unresolved.
Closed due to long inactivity period.