KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1.02k stars 244 forks source link

Runtime problems loading ExternalSolversApplication #8051

Closed maceligueta closed 3 years ago

maceligueta commented 3 years ago

Description This is a recurrent problem in Windows, which has been experimented by me in the past, but also @salvalatorre a few months back, also @AlejandroCornejo and many other people, as it can be found if you google "ExternalSolversApplication". Usually, this gets solved by a phone call to @roigcarlo , who suspects what the problem may be, and recommends actions. The specific problem I am facing is this:

  File "D:\kratos\bin\Release\KratosMultiphysics\ExternalSolversApplication\__init__.py", line 6, in <module>
    from KratosExternalSolversApplication import *
ImportError: DLL load failed: The specified module could not be found

As far as I remember, it can be solved adding a bunch of DLL's in the libs folder. But if you switch to another computer or simply delete the libs folder for a clean installation, you lose those DLL's and it is hard to remember where you got them from.

Request Is there any way we can get a robust compilation of the ExternalSolversApplication without requiring later, manual, action?

philbucher commented 3 years ago

I strongly recommend switching to the LinearSolversApplication the ExternalSolversApp is implicitly deprecated

Is there any specific solver or other reason you are using it?

EDIT: see here

esp this:

Removing the dependency of blas and lapack for our standard compilation and leave the ExternalSolversApplication as optional. Note that the long term idea would be to completely deprecate and eventually remove such application, something that would imply losing FEAST solver in favor of the EigenValue solver from Eigen library. SuperLU and Pastix would be also available through Eigen interface.

AlejandroCornejo commented 3 years ago

Imagine if it is problematic that I am not compiling it anymore... I'm using the LinearSolversApplication

maceligueta commented 3 years ago

Well, I just tried to run a case with the Structural Mechanics Application and it was importing the ExternalSolversApplication somehow...

AlejandroCornejo commented 3 years ago

Well, I just tried to run a case with the Structural Mechanics Application and it was importing the ExternalSolversApplication somehow...

With the latests version of the GUI?? if you open the MainKratos.py you should remove the import ExternalSolversApplication

philbucher commented 3 years ago

Well, I just tried to run a case with the Structural Mechanics Application and it was importing the ExternalSolversApplication somehow...

I changed this over 2.5 years ago :sweat_smile: https://github.com/KratosMultiphysics/GiDInterface/commit/4413be723795c0b7c9085ad077c9f1758ba4339c#diff-3ce4a8425bb869dfea19e8bd08015708e44e7f08d885ba14f9d09ec8b76b4698

maceligueta commented 3 years ago

Ok, I am afraid I had no clue about the implicit deprecation of the ExternalSolversApplication. And I was not even compiling it, actually, but somehow, the code reached this line: https://github.com/KratosMultiphysics/Kratos/blob/8f752f360d973bf68d18695969055f453494ba17/kratos/python_scripts/python_linear_solver_factory.py#L41 When I saw that the ExternalSolversApplication was 'necessary' I added it to the compilation configure and the previously described problems appeared. It's good to know that it is being substituted by LinearSolversApplication, but I wonder what made Kratos think I was preferring ExternalSolversApplication when I was not even compiling it. Probably leftovers of an ooold compilation.

maceligueta commented 3 years ago

I seems like this is solved by using LinearSolversApplication instead of ExternalSolversApplication. If none of them is compiled I am getting a crash. Maybe the Structural Mechanics App should require the LinearSolversApplication always. Anyways, this is an independent issue. Closing and thanks for the help @philbucher .

philbucher commented 3 years ago

I seems like this is solved by using LinearSolversApplication instead of ExternalSolversApplication. If none of them is compiled I am getting a crash. Maybe the Structural Mechanics App should require the LinearSolversApplication always. Anyways, this is an independent issue. Closing and thanks for the help @philbucher .

Hm that is strange I thought/hoped this would be bulletproof 😅 @maceligueta can you please share the error message and if possible your configuration?

maceligueta commented 3 years ago

Correction: it does not crash (so not SegFault), it just stops. Sorry about the confusion. If I delete all files starting with LinearSolversApplication. (3 files) from the libs folder, and also the ExternalSolversApplication. file, I get:

 File "D:\kratos\bin\Release\KratosMultiphysics\python_linear_solver_factory.py", line 39, in CreateFastestAvailableDirectLinearSolver
    from KratosMultiphysics import LinearSolversApplication
  File "D:\kratos\bin\Release\KratosMultiphysics\LinearSolversApplication\__init__.py", line 12, in <module>
    from KratosLinearSolversApplication import *
ModuleNotFoundError: No module named 'KratosLinearSolversApplication'

From GiD, what I first saw was this:

::[PythonSolver]:: : Finished reading model part. 
Read materials: Started
Read materials: Finished
::[MechanicalSolver]:: : Constitutive law was successfully imported. 
::[MechanicalSolver]::: ModelPart prepared for Solver. 
::[MechanicalSolver]:: : DOF's ADDED 
::[ImplicitMechanicalSolver]:: : DOF's ADDED 
[WARNING] VtkOutputProcess: 
[DEPRECATED INPUT PARAMETERS] 'folder_name' is deprecated; use 'output_path' instead. 
[WARNING] VtkOutput: Modelpart "Structure" has both elements and conditions.
Giving precedence to elements and writing only elements!
::[MechanicalSolver]:: : Initializing ... 
::[MechanicalSolver]:: No linear solver was specified, using fastest available solver: 
KRATOS TERMINATED WITH ERROR

Which gives no warning messages and you don't know what to do unless you read the error window (code pasted above).

philbucher commented 3 years ago

ok thx I think what is failing in your case is that you still have the python-files of the LinearSolversApp but you deleted the libs (hence the import fails) we use CheckIfApplicationsAvailable in here, which checks for ApplicationName.py, which I guess in your case is still available can you check please?

maceligueta commented 3 years ago

That is correct, in the KratosMultiphysics folder there is a subfolder called LinearSolversApplication. If I delete this one (along with the libraries in libs/) it runs fine.

maceligueta commented 3 years ago

If the LinearSolversApplication is compiling and working well, maybe the StructuralApplication should require the LinearSolversApplication always.

philbucher commented 3 years ago

but why? Lets say I want to use amgcl (which is in the Core) then I don't want/need to compile any other App

maceligueta commented 3 years ago

Forget it, I was thinking of a conversation with Riccardo where he said the difference in performance was very big when comparing core vs ExternalSolvers. Several years back. If this has changed, my comment makes no sense.

philbucher commented 3 years ago

ok then I guess we can close this :)

BTW another reason for not requiring the LinearSolversApp is bcs it cannot be used in MPI, there we currently use Trilinos Solvers