Borrar filtros
Borrar filtros

Out of memory error using gmres in while loop

4 visualizaciones (últimos 30 días)
Wes H
Wes H el 24 de Abr. de 2023
Comentada: Wes H el 16 de Ag. de 2023
Hello all,
I am solving a system of non-linear PDEs using Newton's method. Essentially, I obtain a jacobian block tridiagonal matrix and solve it with gmres which produces a solution vector somewhat more precise than the previous iteration. This sequence iterates within a while loop until some convergence criteria is met. The code runs successfully, however the memory usage in task manager/activity monitor continues increasing until it reaches 98%, at which point matlab produces an "out of memory" error and crashes. I am wondering how to fix this.
My main point of confusion as to why this is happeneing is that I am not intensionally creating new variables during iteration. All arrays stay the same size and are overwritten each iteration so I would expect the memory usage to stay approximately constant. Instead, the memory used by matlab increases with runtime. I have tried clearing the jacobian each iteration, in addition to some smaller arrays, which did not help. I am wondering if gmres allocates memory somewhere within it's nested functions (which I don't see because it is not in the workspace) and then does not clear it. This might explain why a memory usage build up occurs.
Any comments or suggestions are appreciated.
Thanks

Respuestas (1)

Sourabh
Sourabh el 19 de Mayo de 2023
Greetings Wes,
There are a few things I can think of to try and reduce the memory consumption when using the gmres function:
  • Using a preconditioner can speed up convergence and help reduce the number of iterations required, thereby reducing memory required.
  • Another approach to reduce memory usage is to use the gmres implementation with r restarts would require less memory to store intermediate vectors and matrices compared to the default implementation. You could use this input along with the maxit input to control the maximum number of iterations.
It is also possible that the issue is not related to gmres, but rather to some other part of your code or any external functions you might be calling.
Also, you might find the following links useful:
  2 comentarios
Wes H
Wes H el 2 de Ag. de 2023
Hi Sourabh,
Thank you for your comments. Do you have any suggestions about how to choose an appropriate restart value?
Wes H
Wes H el 16 de Ag. de 2023
Hi Sourabh,
I have also tried using a preconditioner (imcomplete LU factorization) and found that it speeds up computation time but also returns a completely different solutiuon vector that causes the numerical method to fail. When comparing the solution vector from gmres with and without the preconditioner, I see quantitative differences as large as 10 orders of magnitude. Could this be due to the size of the drop tollerance? I would like to use a preconditioner however I have been unable to get a solution vector that closely resembles the un-conditioned solution vector.
Thanks,
Wes

Iniciar sesión para comentar.

Categorías

Más información sobre Sparse Matrices en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by