Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TensorFlow memory and performance fixes #26

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

clackary
Copy link
Collaborator

@clackary clackary commented Jul 31, 2024

When running BuildingSimulation benchmarks, I observed a very high amount of memory usage (MacBook Pro, M1 Max, 32GB RAM) during high-timestep simulations using TensorFlow. Some cases (100,000 timestep, single trial) failed to complete, with warnings thrown from TF about 'large unrolled loops'. TF documentation suggested using TensorFlow's control flow:tf.range. To keep each trial isolated and independent, I'm keeping the trials' range usage as Python's.

The observed effect of these two changes is that overall memory usage is reduced, lowering RAM hardware requirements, and performance is increased by decorating the getGradient function with @tf.function. This decoration is recommended to avoid eager execution, and is a basic and straightforward measure to increase performance.

Copy link
Contributor

@bjschoenfeld bjschoenfeld left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@jfilling jfilling merged commit 81179f8 into PassiveLogic:main Jul 31, 2024
2 checks passed
@clackary clackary deleted the fix/tensorflow-perf branch August 1, 2024 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants