Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions handyrl/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,17 +489,14 @@ def feed_episodes(self, episodes):
self.generation_results[model_id] = n + 1, r + outcome, r2 + outcome ** 2

# store generated episodes
mem = psutil.virtual_memory()
mem_used_ratio = mem.used / mem.total
mem_ok = mem_used_ratio <= 0.95
maximum_episodes = self.args['maximum_episodes'] if mem_ok else len(self.trainer.episodes)

if not mem_ok and 'memory_over' not in self.flags:
warnings.warn("memory usage %.1f%% with buffer size %d" % (mem_used_ratio * 100, len(self.trainer.episodes)))
self.flags.add('memory_over')

self.trainer.episodes.extend([e for e in episodes if e is not None])
while len(self.trainer.episodes) > maximum_episodes:
while len(self.trainer.episodes) > self.args['maximum_episodes']:
self.trainer.episodes.popleft()

while psutil.virtual_memory().percent >= 95:
if 'memory_over' not in self.flags:
warnings.warn("memory usage %.1f%% with buffer size %d" % (mem_used_ratio * 100, len(self.trainer.episodes)))
Copy link
Member

@ikki407 ikki407 Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is mem_used_ratio defined anywhere?

Does there exist a way not to use self.flags? ie. "once" (I'm thinking...)

Copy link
Member

@ikki407 ikki407 Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related?
https://stackoverflow.com/a/22661838/10809665

Repetitions of a particular warning for the same source location are typically suppressed.

https://docs.python.org/3/library/warnings.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops

self.flags.add('memory_over')
self.trainer.episodes.popleft()

def feed_results(self, results):
Expand Down