Memory - sparse matrix

More
5 years 11 months ago #1307 by bakerk
Hi,

Im using Python37 through Jupyter Notebook with the netgen/ngsolve packages to do finite elements, this part is working but I want to be able to approximate the memory usage of my code. If you are aware of a way to have python profile it please let me know but I couldn't find a way that would work with my set up. If not I would like to know how ngsolve stores its sparse matrices, and how to calculate that?

Many thanks
More
5 years 11 months ago #1310 by christopher
Replied by christopher on topic Memory - sparse matrix
Hi,
some classes have implemented a memory profiling interface (BilinearForm, LinearForm, GridFunction,...)
You can get it by calling the __memory__ property of them for example:
Code:
a = BilinearForm(fes) ... a.Assemble() print(a.__memory__)
gives something like
Code:
[('SparseMatrix bf biform_from_py low-order', 1352, 1), ('SparseMatrix bf biform_from_py', 24200, 1)]
meaning that the sparse matrix uses 24200 bytes in 1 block and the low order matrix (used in some preconditioners,...) needs 1352 bytes in 1 block.

Best
Christopher
More
5 years 11 months ago #1312 by bakerk
Replied by bakerk on topic Memory - sparse matrix
Hi, thanks for replying so quick. When I tried your suggestion I got the following error:

AttributeError: 'ngsolve.comp.BilinearForm' object has no attribute '__memory__'

my 'a' is defined as:

a=BilinearForm(fes,symmetric=False)
a+=SymbolicBFI(grad(u)*grad(v))
a.Assemble()

on a unit square. Did this memory tool get added recently?
More
5 years 11 months ago #1313 by christopher
Replied by christopher on topic Memory - sparse matrix
Yes, git says 2018-09-18. So it should be in the latest version v6.2.1809

Best
Christopher
The following user(s) said Thank You: bakerk
More
5 years 11 months ago - 5 years 11 months ago #1317 by bakerk
Replied by bakerk on topic Memory - sparse matrix
Thanks!
Last edit: 5 years 11 months ago by bakerk.
Time to create page: 0.099 seconds