PETSc Krylov solver did not converge (PETSc reason -4).

Asked by Murtazo Nazarov

Hi,

My solver was working until I recompiled dolfin for some reasons. The Petcs Krylov solver does not converges:

Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
terminate called after throwing an instance of 'std::runtime_error'
  what(): *** Error: PETSc Krylov solver did not converge (PETSc reason -4).

However it works well with LUSolver.

Does anyone had similar problem?

murtazo

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Murtazo Nazarov
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Sat, Apr 24, 2010 at 03:38:42AM -0000, Murtazo Nazarov wrote:
> New question #108259 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/108259
>
> Hi,
>
> My solver was working until I recompiled dolfin for some reasons. The Petcs Krylov solver does not converges:
>
> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
> terminate called after throwing an instance of 'std::runtime_error'
> what(): *** Error: PETSc Krylov solver did not converge (PETSc reason -4).
>
> However it works well with LUSolver.
>
> Does anyone had similar problem?

Are you sure it used to converge? We recently changed a warning to an
error, so it might be that your old solver didn't converge but you
only thought it did.

--
Anders

Revision history for this message
Murtazo Nazarov (murtazo) said :
#2

Anders Logg wrote:
> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> Status: Open => Answered
>
> Anders Logg proposed the following answer:
> On Sat, Apr 24, 2010 at 03:38:42AM -0000, Murtazo Nazarov wrote:
>
>> New question #108259 on DOLFIN:
>> https://answers.launchpad.net/dolfin/+question/108259
>>
>> Hi,
>>
>> My solver was working until I recompiled dolfin for some reasons. The Petcs Krylov solver does not converges:
>>
>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
>> terminate called after throwing an instance of 'std::runtime_error'
>> what(): *** Error: PETSc Krylov solver did not converge (PETSc reason -4).
>>
>> However it works well with LUSolver.
>>
>> Does anyone had similar problem?
>>
>
> Are you sure it used to converge? We recently changed a warning to an
> error, so it might be that your old solver didn't converge but you
> only thought it did.
>
>

I checked now the output of my old solver. It converged with hypre. But,
now it converges with LUSolver but not with Krylov solver.

I simple solve the mass matrix, after applying Dirichlet boundary
conditions.

murtazo

> --
> Anders
>
>

Revision history for this message
Kent-Andre Mardal (kent-and) said :
#3

> Anders Logg wrote:
>> Question #108259 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/108259
>>
>> Status: Open => Answered
>>
>> Anders Logg proposed the following answer:
>> On Sat, Apr 24, 2010 at 03:38:42AM -0000, Murtazo Nazarov wrote:
>>
>>> New question #108259 on DOLFIN:
>>> https://answers.launchpad.net/dolfin/+question/108259
>>>
>>> Hi,
>>>
>>> My solver was working until I recompiled dolfin for some reasons. The
>>> Petcs Krylov solver does not converges:
>>>
>>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
>>> terminate called after throwing an instance of 'std::runtime_error'
>>> what(): *** Error: PETSc Krylov solver did not converge (PETSc
>>> reason -4).
>>>
>>> However it works well with LUSolver.
>>>
>>> Does anyone had similar problem?
>>>
>>
>> Are you sure it used to converge? We recently changed a warning to an
>> error, so it might be that your old solver didn't converge but you
>> only thought it did.
>>
>>
>
> I checked now the output of my old solver. It converged with hypre. But,
> now it converges with LUSolver but not with Krylov solver.
>
> I simple solve the mass matrix, after applying Dirichlet boundary
> conditions.
>
> murtazo
>

I've also seen this a number of times. The problem goes away when
using assemble_system that makes the matrix symmetric.

I don't have a good explaination, though. And I think it is a bit strange.

Kent

Revision history for this message
N.A. Borggren (nborggren) said :
#4

Hello,
   It seems that my Krylov solver was working better a few weeks ago than
now as well. I applied the assemble_system suggestion above but I still get
an error message for a humble 756x756 matrix that works just fine without
the 'gmres' option in solve. I was relying on 'gmres' before to solve
problems when just "solve(A, self.u1.vector(), b)" (PETSc LU solver,
umfpack) would run out of memory. So I've returned to the conundrum of how
to solve larger systems when neither of these options work. Any
suggestions? I'm running on Fedora 12 and had quite an adventure (still
unsuccesful on my home computer) making dorsal with the Fedora 11 platform
run. Is it something wrong with my build?
   Thanks,
       Nathan Borggren

Assembling linear system and applying boundary conditions...
Matrix of size 756 x 756 has 9910 nonzero entries.
Solving linear system of size 756 x 756 (Krylov solver).
Traceback (most recent call last):
  File "Lorenz.py", line 120, in <module>
    z.Run()
  File "/home/nborggren/Codes/Aleph/Dynamics/DynSys.py", line 166, in Run
    solve(A, self.u1.vector(), b,'gmres')
  File
"/home/nborggren/Work/FEniCS/build/lib/python2.6/site-packages/dolfin/cpp.py",
line 3834, in solve
    return _cpp.solve(*args)
RuntimeError: *** Error: Krylov solver did not converge.

On Mon, Apr 26, 2010 at 1:06 PM, Kent
<email address hidden>wrote:

> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> Status: Open => Answered
>
> Kent proposed the following answer:
> > Anders Logg wrote:
> >> Question #108259 on DOLFIN changed:
> >> https://answers.launchpad.net/dolfin/+question/108259
> >>
> >> Status: Open => Answered
> >>
> >> Anders Logg proposed the following answer:
> >> On Sat, Apr 24, 2010 at 03:38:42AM -0000, Murtazo Nazarov wrote:
> >>
> >>> New question #108259 on DOLFIN:
> >>> https://answers.launchpad.net/dolfin/+question/108259
> >>>
> >>> Hi,
> >>>
> >>> My solver was working until I recompiled dolfin for some reasons. The
> >>> Petcs Krylov solver does not converges:
> >>>
> >>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
> >>> terminate called after throwing an instance of 'std::runtime_error'
> >>> what(): *** Error: PETSc Krylov solver did not converge (PETSc
> >>> reason -4).
> >>>
> >>> However it works well with LUSolver.
> >>>
> >>> Does anyone had similar problem?
> >>>
> >>
> >> Are you sure it used to converge? We recently changed a warning to an
> >> error, so it might be that your old solver didn't converge but you
> >> only thought it did.
> >>
> >>
> >
> > I checked now the output of my old solver. It converged with hypre. But,
> > now it converges with LUSolver but not with Krylov solver.
> >
> > I simple solve the mass matrix, after applying Dirichlet boundary
> > conditions.
> >
> > murtazo
> >
>
> I've also seen this a number of times. The problem goes away when
> using assemble_system that makes the matrix symmetric.
>
> I don't have a good explaination, though. And I think it is a bit
> strange.
>
> Kent
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin<https://launchpad.net/%7Edolfin>
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~dolfin<https://launchpad.net/%7Edolfin>
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#5

Yes, the Krylov solver was working better before not now. I still have the same problem.

I am forced to go back and use the latest stable version.

Revision history for this message
Kent-Andre Mardal (kent-and) said :
#6

with assemble_system you might use cg, if the variational
form is symmetric. For mass matrix with bc I've used
CG + Jacobi prec.

Kent

> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> N.A. Borggren proposed the following answer:
> Hello,
> It seems that my Krylov solver was working better a few weeks ago than
> now as well. I applied the assemble_system suggestion above but I still
> get
> an error message for a humble 756x756 matrix that works just fine without
> the 'gmres' option in solve. I was relying on 'gmres' before to solve
> problems when just "solve(A, self.u1.vector(), b)" (PETSc LU solver,
> umfpack) would run out of memory. So I've returned to the conundrum of
> how
> to solve larger systems when neither of these options work. Any
> suggestions? I'm running on Fedora 12 and had quite an adventure (still
> unsuccesful on my home computer) making dorsal with the Fedora 11 platform
> run. Is it something wrong with my build?
> Thanks,
> Nathan Borggren
>
>
> Assembling linear system and applying boundary conditions...
> Matrix of size 756 x 756 has 9910 nonzero entries.
> Solving linear system of size 756 x 756 (Krylov solver).
> Traceback (most recent call last):
> File "Lorenz.py", line 120, in <module>
> z.Run()
> File "/home/nborggren/Codes/Aleph/Dynamics/DynSys.py", line 166, in Run
> solve(A, self.u1.vector(), b,'gmres')
> File
> "/home/nborggren/Work/FEniCS/build/lib/python2.6/site-packages/dolfin/cpp.py",
> line 3834, in solve
> return _cpp.solve(*args)
> RuntimeError: *** Error: Krylov solver did not converge.
>
>
> On Mon, Apr 26, 2010 at 1:06 PM, Kent
> <email address hidden>wrote:
>
>> Question #108259 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/108259
>>
>> Status: Open => Answered
>>
>> Kent proposed the following answer:
>> > Anders Logg wrote:
>> >> Question #108259 on DOLFIN changed:
>> >> https://answers.launchpad.net/dolfin/+question/108259
>> >>
>> >> Status: Open => Answered
>> >>
>> >> Anders Logg proposed the following answer:
>> >> On Sat, Apr 24, 2010 at 03:38:42AM -0000, Murtazo Nazarov wrote:
>> >>
>> >>> New question #108259 on DOLFIN:
>> >>> https://answers.launchpad.net/dolfin/+question/108259
>> >>>
>> >>> Hi,
>> >>>
>> >>> My solver was working until I recompiled dolfin for some reasons.
>> The
>> >>> Petcs Krylov solver does not converges:
>> >>>
>> >>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
>> >>> terminate called after throwing an instance of 'std::runtime_error'
>> >>> what(): *** Error: PETSc Krylov solver did not converge (PETSc
>> >>> reason -4).
>> >>>
>> >>> However it works well with LUSolver.
>> >>>
>> >>> Does anyone had similar problem?
>> >>>
>> >>
>> >> Are you sure it used to converge? We recently changed a warning to an
>> >> error, so it might be that your old solver didn't converge but you
>> >> only thought it did.
>> >>
>> >>
>> >
>> > I checked now the output of my old solver. It converged with hypre.
>> But,
>> > now it converges with LUSolver but not with Krylov solver.
>> >
>> > I simple solve the mass matrix, after applying Dirichlet boundary
>> > conditions.
>> >
>> > murtazo
>> >
>>
>> I've also seen this a number of times. The problem goes away when
>> using assemble_system that makes the matrix symmetric.
>>
>> I don't have a good explaination, though. And I think it is a bit
>> strange.
>>
>> Kent
>>
>> --
>> You received this question notification because you are a member of
>> DOLFIN Team, which is an answer contact for DOLFIN.
>>
>> _______________________________________________
>> Mailing list:
>> https://launchpad.net/~dolfin<https://launchpad.net/%7Edolfin>
>> Post to : <email address hidden>
>> Unsubscribe :
>> https://launchpad.net/~dolfin<https://launchpad.net/%7Edolfin>
>> More help : https://help.launchpad.net/ListHelp
>>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
>

Revision history for this message
Garth Wells (garth-wells) said :
#7

On 29/04/10 00:42, N.A. Borggren wrote:
> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> N.A. Borggren proposed the following answer:
> Hello,
> It seems that my Krylov solver was working better a few weeks ago than
> now as well. I applied the assemble_system suggestion above but I still get
> an error message for a humble 756x756 matrix that works just fine without
> the 'gmres' option in solve. I was relying on 'gmres' before to solve
> problems when just "solve(A, self.u1.vector(), b)" (PETSc LU solver,
> umfpack) would run out of memory.

Try using

   solver = KrylovSolver("gmres")
   solver.parameters["monitor_convergence"] = True
   solver.parameters["error_on_nonconvergence"] = False

   solver.solve(A, x, b)

It's possible that your solver wasn't converging before, but is only now
picked up because DOLFIN now throws an error by default upon failed
convergence.

Garth

So I've returned to the conundrum of how
> to solve larger systems when neither of these options work. Any
> suggestions? I'm running on Fedora 12 and had quite an adventure (still
> unsuccesful on my home computer) making dorsal with the Fedora 11 platform
> run. Is it something wrong with my build?
> Thanks,
> Nathan Borggren
>
>
> Assembling linear system and applying boundary conditions...
> Matrix of size 756 x 756 has 9910 nonzero entries.
> Solving linear system of size 756 x 756 (Krylov solver).
> Traceback (most recent call last):
> File "Lorenz.py", line 120, in<module>
> z.Run()
> File "/home/nborggren/Codes/Aleph/Dynamics/DynSys.py", line 166, in Run
> solve(A, self.u1.vector(), b,'gmres')
> File
> "/home/nborggren/Work/FEniCS/build/lib/python2.6/site-packages/dolfin/cpp.py",
> line 3834, in solve
> return _cpp.solve(*args)
> RuntimeError: *** Error: Krylov solver did not converge.
>
>
> On Mon, Apr 26, 2010 at 1:06 PM, Kent
> <email address hidden>wrote:
>
>> Question #108259 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/108259
>>
>> Status: Open => Answered
>>
>> Kent proposed the following answer:
>>> Anders Logg wrote:
>>>> Question #108259 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/108259
>>>>
>>>> Status: Open => Answered
>>>>
>>>> Anders Logg proposed the following answer:
>>>> On Sat, Apr 24, 2010 at 03:38:42AM -0000, Murtazo Nazarov wrote:
>>>>
>>>>> New question #108259 on DOLFIN:
>>>>> https://answers.launchpad.net/dolfin/+question/108259
>>>>>
>>>>> Hi,
>>>>>
>>>>> My solver was working until I recompiled dolfin for some reasons. The
>>>>> Petcs Krylov solver does not converges:
>>>>>
>>>>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
>>>>> terminate called after throwing an instance of 'std::runtime_error'
>>>>> what(): *** Error: PETSc Krylov solver did not converge (PETSc
>>>>> reason -4).
>>>>>
>>>>> However it works well with LUSolver.
>>>>>
>>>>> Does anyone had similar problem?
>>>>>
>>>>
>>>> Are you sure it used to converge? We recently changed a warning to an
>>>> error, so it might be that your old solver didn't converge but you
>>>> only thought it did.
>>>>
>>>>
>>>
>>> I checked now the output of my old solver. It converged with hypre. But,
>>> now it converges with LUSolver but not with Krylov solver.
>>>
>>> I simple solve the mass matrix, after applying Dirichlet boundary
>>> conditions.
>>>
>>> murtazo
>>>
>>
>> I've also seen this a number of times. The problem goes away when
>> using assemble_system that makes the matrix symmetric.
>>
>> I don't have a good explaination, though. And I think it is a bit
>> strange.
>>
>> Kent
>>
>> --
>> You received this question notification because you are a member of
>> DOLFIN Team, which is an answer contact for DOLFIN.
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dolfin<https://launchpad.net/%7Edolfin>
>> Post to : <email address hidden>
>> Unsubscribe : https://launchpad.net/~dolfin<https://launchpad.net/%7Edolfin>
>> More help : https://help.launchpad.net/ListHelp
>>
>

Revision history for this message
Anders Logg (logg) said :
#8

On Thu, Apr 29, 2010 at 06:45:28AM -0000, Garth Wells wrote:
> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> Garth Wells proposed the following answer:
>
> On 29/04/10 00:42, N.A. Borggren wrote:
> > Question #108259 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/108259
> >
> > N.A. Borggren proposed the following answer:
> > Hello,
> > It seems that my Krylov solver was working better a few weeks ago than
> > now as well. I applied the assemble_system suggestion above but I still get
> > an error message for a humble 756x756 matrix that works just fine without
> > the 'gmres' option in solve. I was relying on 'gmres' before to solve
> > problems when just "solve(A, self.u1.vector(), b)" (PETSc LU solver,
> > umfpack) would run out of memory.
>
> Try using
>
> solver = KrylovSolver("gmres")
> solver.parameters["monitor_convergence"] = True
> solver.parameters["error_on_nonconvergence"] = False
>
> solver.solve(A, x, b)
>
> It's possible that your solver wasn't converging before, but is only now
> picked up because DOLFIN now throws an error by default upon failed
> convergence.
>
> Garth

And do the same thing using the old "working" DOLFIN version (ideally
for a simple test case). Then post the output (the convergence) for
both. Then we'll know for sure there's a problem. I also expect it
didn't converge before (since things seem to work fine here and I
don't remember changing anything except for converting a warning to an
error message).

--
Anders

Revision history for this message
Murtazo Nazarov (murtazo) said :
#9

Yes, it seems hypre in my solver does not converge only in the first iteration. Before it was just a warning, but with the latest dolfin it stoped since it is assumed that it is an error.

Here I made a test for the same problem using the following lines:

   solver = KrylovSolver("gmres")
   solver.parameters["monitor_convergence"] = True
   solver.parameters["error_on_nonconvergence"] = False
..

"Old" dolfin gives:
....
Applying boundary conditions to linear system.
Applying boundary conditions to linear system.
Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
  0 KSP preconditioned resid norm 2.663347782311e+02 true resid norm 1.371810197831e+01 ||Ae||/||Ax|| 7.817835153984e+08
*** Warning: Krylov solver did not converge (PETSc reason -4).
PETSc Krylov solver (gmres, hypre) failed to converge in 0 iterations.
...

and the latest dolfin gives:

Applying boundary conditions to linear system.
Applying boundary conditions to linear system.
Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
  0 KSP preconditioned resid norm 6.346755394553e+02 true resid norm 3.269022479529e+01 ||Ae||/||Ax|| 3.675021072956e+08
*** Warning: Krylov solver did not converge (PETSc reason -4).
PETSc Krylov solver (gmres, hypre) failed to converge in 0 iterations.

It happened because of the luck of stabilization in startup.

It is nice to know about the latest flags in the parameter list for the Krylov solver.

murtazo

Revision history for this message
Anders Logg (logg) said :
#10

On Thu, Apr 29, 2010 at 04:14:21PM -0000, Murtazo Nazarov wrote:
> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> Status: Answered => Solved
>
> Murtazo Nazarov confirmed that the question is solved:
> Yes, it seems hypre in my solver does not converge only in the first
> iteration. Before it was just a warning, but with the latest dolfin it
> stoped since it is assumed that it is an error.
>
> Here I made a test for the same problem using the following lines:
>
> solver = KrylovSolver("gmres")
> solver.parameters["monitor_convergence"] = True
> solver.parameters["error_on_nonconvergence"] = False
> ..
>
> "Old" dolfin gives:
> ....
> Applying boundary conditions to linear system.
> Applying boundary conditions to linear system.
> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
> 0 KSP preconditioned resid norm 2.663347782311e+02 true resid norm 1.371810197831e+01 ||Ae||/||Ax|| 7.817835153984e+08
> *** Warning: Krylov solver did not converge (PETSc reason -4).
> PETSc Krylov solver (gmres, hypre) failed to converge in 0 iterations.
> ...
>
> and the latest dolfin gives:
>
> Applying boundary conditions to linear system.
> Applying boundary conditions to linear system.
> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
> 0 KSP preconditioned resid norm 6.346755394553e+02 true resid norm 3.269022479529e+01 ||Ae||/||Ax|| 3.675021072956e+08
> *** Warning: Krylov solver did not converge (PETSc reason -4).
> PETSc Krylov solver (gmres, hypre) failed to converge in 0 iterations.
>
> It happened because of the luck of stabilization in startup.
>
> It is nice to know about the latest flags in the parameter list for the
> Krylov solver.
>
> murtazo

ok, good to know. So there is nothing wrong with the solver.

I suggest you let "error_on_nonconvergence" stay true, otherwise you
will not see when it fails.

--
Anders

Revision history for this message
Murtazo Nazarov (murtazo) said :
#11

Anders Logg wrote:
> Question #108259 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/108259
>
> Anders Logg posted a new comment:
> On Thu, Apr 29, 2010 at 04:14:21PM -0000, Murtazo Nazarov wrote:
>
>> Question #108259 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/108259
>>
>> Status: Answered => Solved
>>
>> Murtazo Nazarov confirmed that the question is solved:
>> Yes, it seems hypre in my solver does not converge only in the first
>> iteration. Before it was just a warning, but with the latest dolfin it
>> stoped since it is assumed that it is an error.
>>
>> Here I made a test for the same problem using the following lines:
>>
>> solver = KrylovSolver("gmres")
>> solver.parameters["monitor_convergence"] = True
>> solver.parameters["error_on_nonconvergence"] = False
>> ..
>>
>> "Old" dolfin gives:
>> ....
>> Applying boundary conditions to linear system.
>> Applying boundary conditions to linear system.
>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
>> 0 KSP preconditioned resid norm 2.663347782311e+02 true resid norm 1.371810197831e+01 ||Ae||/||Ax|| 7.817835153984e+08
>> *** Warning: Krylov solver did not converge (PETSc reason -4).
>> PETSc Krylov solver (gmres, hypre) failed to converge in 0 iterations.
>> ...
>>
>> and the latest dolfin gives:
>>
>> Applying boundary conditions to linear system.
>> Applying boundary conditions to linear system.
>> Solving linear system of size 4184 x 4184 (PETSc Krylov solver).
>> 0 KSP preconditioned resid norm 6.346755394553e+02 true resid norm 3.269022479529e+01 ||Ae||/||Ax|| 3.675021072956e+08
>> *** Warning: Krylov solver did not converge (PETSc reason -4).
>> PETSc Krylov solver (gmres, hypre) failed to converge in 0 iterations.
>>
>> It happened because of the luck of stabilization in startup.
>>
>> It is nice to know about the latest flags in the parameter list for the
>> Krylov solver.
>>
>> murtazo
>>
>
> ok, good to know. So there is nothing wrong with the solver.
>
> I suggest you let "error_on_nonconvergence" stay true, otherwise you
> will not see when it fails.
>
> --
> Anders
>
>

yes, you are right. I put it false only for the first time-step, then I
change it to be true. Otherwise I still get warning, which I usually track.

murtazo