Created
March 7, 2019 06:14
-
-
Save gchavez2/84876d5a1f0ce6b37dd408e87ec5b32e to your computer and use it in GitHub Desktop.
Compute memory usage of matrices
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
# 1e3 = 1k: 8MB | |
rows = 1e3 | |
cols = 1e3 | |
# # 1e4 = 10k: 8GB | |
rows = 1e4 | |
cols = 1e4 | |
# # 1e5 = 100k: 80GB | |
rows = 1e5 | |
cols = 1e5 | |
# 1e6 = 1M: 8,000GB = 8TB | |
# rows = 1e6 | |
# cols = 1e6 | |
# 10k x 4.5M | |
# rows = 1e4 | |
# cols = 4.5e6 | |
entries = rows*cols | |
mem_kb_float = 4*(entries)/(1e3) | |
mem_mb_float = 4*(entries)/(1e6) | |
mem_gb_float = 4*(entries)/(1e9) | |
mem_kb_double = 8*(entries)/(1e3) | |
mem_mb_double = 8*(entries)/(1e6) | |
mem_gb_double = 8*(entries)/(1e9) | |
print(100*"*") | |
print("Matrix of size [{0:,.0f} x {1:,.0f}] uses:".format(rows,cols)) | |
print(100*"*") | |
print("mem_kb_float = {0:1.2f} KB".format(mem_kb_float)) | |
print("mem_mb_float = {0:1.2f} MB".format(mem_mb_float)) | |
print("mem_gb_float = {0:1.2f} GB".format(mem_gb_float)) | |
print(100*"*") | |
print("mem_kb_double = {0:1.2f} KB".format(mem_kb_double)) | |
print("mem_mb_double = {0:1.2f} MB".format(mem_mb_double)) | |
print("mem_gb_double = {0:1.2f} GB".format(mem_gb_double)) | |
print(100*"*") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment