I am running a pygame in parallel using ray, but want so suppress SDL video warnings/errors.
Here is my code:
@ray.remote
def run2(agent): # same as run1
sys.stdout = open(os.devnull, "w")
sys.stderr = open(os.devnull, "w")
os.environ["SDL_VIDEODRIVER"] = "dummy"
env = GameEnv(0)
state = env.reset()
steps =0
done= False
while not done:
steps+=1
action = agent.predict(state)
ns , r ,done ,i= env.step(env.action_space.sample())
return steps
# note: maybe run this twice to warmup the system
%time result = ray.get([run2.remote(pops[i]) for i in range(10)])
I have tried changing stdout and stderr but that doesn't seem to work, or maybe I should change that somewhere else Here is the warning's I get for every worker
(pid=1128) ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
(pid=1128) ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
(pid=1128) ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
(pid=1128) ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
(pid=1128) ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
(pid=1128) ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
(pid=1128) ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
(pid=1128) ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
Is there a way to do this using a ray parameter or global stdout block?
Found out you could use:
ray.init(log_to_driver=False)
To disable ray workers from logging the output.