Skip to content

fix: TensorFlow memory and performance fixes#26

Merged
jfilling merged 2 commits intoPassiveLogic:mainfrom
clackary:fix/tensorflow-perf
Jul 31, 2024
Merged

fix: TensorFlow memory and performance fixes#26
jfilling merged 2 commits intoPassiveLogic:mainfrom
clackary:fix/tensorflow-perf

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
@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