Created
August 12, 2021 14:26
-
-
Save daskol/4d4004af302f6e2234fc7a76da6fde40 to your computer and use it in GitHub Desktop.
Free JAX/XLA buffers of size exceeded threshold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import jax | |
| def collect(threshold=256 * 1024 ** 2): | |
| backend = jax.lib.xla_bridge.get_backend() | |
| freed = 0 | |
| for buf in backend.live_buffers(): | |
| if buf.nbytes >= threshold: | |
| buf += buf.nbytes | |
| buf.delete() | |
| return freed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment