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.04k stars 246 forks source link

[Windows] DLL load failed while importing KratosExternalSolversApplication #6604

Closed peterjwilson closed 4 years ago

peterjwilson commented 4 years ago

I'm trying to run a co-sim test but get the following error

PS C:\Kratos\applications\CoSimulationApplication\tests> .\test_CoSimulationApplication.py
 |  /           |
 ' /   __| _` | __|  _ \   __|
 . \  |   (   | |   (   |\__ \
_|\_\_|  \__,_|\__|\___/ ____/
           Multi-Physics 7.1.0-63c40f2edb-Release
Compiled with OpenMP support.
Maximum OpenMP threads: 12.
Importing    KratosCoSimulationApplication
    KRATOS  / ___|___/ ___|(_)_ __ ___  _   _| | __ _| |_(_) ___  _ __
           | |   / _ \___ \| | '_ ` _ \| | | | |/ _` | __| |/ _ \| '_ \
           | |__| (_) |__) | | | | | | | |_| | | (_| | |_| | (_) | | | |
            \____\___/____/|_|_| |_| |_|\__,_|_|\__,_|\__|_|\___/|_| |_|
Initializing KratosCoSimulationApplication...
Ess
======================================================================
ERROR: test_MPM_FEM_beam_penalty (co_simulation_test_factory.TestSmallCoSimulationCases)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Kratos\applications\CoSimulationApplication\tests\co_simulation_test_factory.py", line 73, in test_MPM_FEM_beam_penalty
    self._runTest()
  File "C:\Kratos\applications\CoSimulationApplication\tests\co_simulation_test_case.py", line 36, in _runTest
    CoSimulationAnalysis(self.cosim_parameters).Run()
  File "C:\Kratos\bin\Release\KratosMultiphysics\analysis_stage.py", line 49, in Run
    self.Initialize()
  File "C:\Kratos\bin\Release\KratosMultiphysics\CoSimulationApplication\co_simulation_analysis.py", line 60, in Initialize
    self._GetSolver().Initialize()
  File "C:\Kratos\bin\Release\KratosMultiphysics\CoSimulationApplication\coupled_solvers\gauss_seidel_strong.py", line 33, in Initialize
    super(GaussSeidelStrongCoupledSolver, self).Initialize()
  File "C:\Kratos\bin\Release\KratosMultiphysics\CoSimulationApplication\base_classes\co_simulation_coupled_solver.py", line 57, in Initialize
    solver.Initialize()
  File "C:\Kratos\bin\Release\KratosMultiphysics\CoSimulationApplication\solver_wrappers\kratos\kratos_base_wrapper.py", line 34, in Initialize
    self._analysis_stage.Initialize() # this reades the Meshes
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_analysis.py", line 53, in Initialize
    super(StructuralMechanicsAnalysis, self).Initialize()
  File "C:\Kratos\bin\Release\KratosMultiphysics\analysis_stage.py", line 89, in Initialize
    self._GetSolver().Initialize()
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_solver.py", line 209, in Initialize
    mechanical_solution_strategy = self.get_mechanical_solution_strategy()
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_solver.py", line 317, in get_mechanical_solution_strategy
    self._mechanical_solution_strategy = self._create_mechanical_solution_strategy()
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_solver.py", line 460, in _create_mechanical_solution_strategy
    mechanical_solution_strategy = self._create_newton_raphson_strategy()
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_solver.py", line 486, in _create_newton_raphson_strategy
    linear_solver = self.get_linear_solver()
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_solver.py", line 300, in get_linear_solver
    self._linear_solver = self._create_linear_solver()
  File "C:\Kratos\bin\Release\KratosMultiphysics\StructuralMechanicsApplication\structural_mechanics_solver.py", line 435, in _create_linear_solver
    return linear_solver_factory.CreateFastestAvailableDirectLinearSolver()
  File "C:\Kratos\bin\Release\KratosMultiphysics\python_linear_solver_factory.py", line 175, in CreateFastestAvailableDirectLinearSolver
    from KratosMultiphysics import ExternalSolversApplication
  File "C:\Kratos\bin\Release\KratosMultiphysics\ExternalSolversApplication\__init__.py", line 3, in <module>
    from KratosExternalSolversApplication import *
ImportError: DLL load failed while importing KratosExternalSolversApplication: The specified module could not be found.

----------------------------------------------------------------------
Ran 3 tests in 0.099s

FAILED (errors=1, skipped=2)
PS C:\Kratos\applications\CoSimulationApplication\tests>

I've gone through this, this and updated system paths for as per windows post compilation but still get the above error.

My system path settings are below, with the library folders image

Any assistance would be really appreciated @roigcarlo (I'm on VS2019 16.4.5 here btw)

roigcarlo commented 4 years ago

Hi @peterjwilson

I think you did not compile the external solvers application. Just add:

CALL :add_app %KRATOS_APP_DIR%\ExternalSolversApplication;

Along with the others

peterjwilson commented 4 years ago

That and a few other apps were already in my config to run the specific cosim test I wanted to

rem Set applications to compile
set KRATOS_APPLICATIONS=
CALL :add_app %KRATOS_APP_DIR%\ParticleMechanicsApplication;
CALL :add_app %KRATOS_APP_DIR%\StructuralMechanicsApplication;
CALL :add_app %KRATOS_APP_DIR%\CoSimulationApplication;
CALL :add_app %KRATOS_APP_DIR%\MappingApplication;
CALL :add_app %KRATOS_APP_DIR%\ExternalSolversApplication;
roigcarlo commented 4 years ago

That's odd.

Could you open the KratosExternalSolvers.dll (the one inside libs) with this https://www.dependencywalker.com/ and tell me if there is some missing lib?

peterjwilson commented 4 years ago

Hmmm, I don't seem to have that dll inside my libs...

image

Maybe my config is wrong? Here it is

roigcarlo commented 4 years ago

Configure seems ok.

You do have the dll, is the one called "KratosExternalSolversApplication.cp38-win-amd64.pyd" (pyd are dll with the names changed, as they represent python module extensions)

Could yo open it with the dependency walker pls?

peterjwilson commented 4 years ago

Ah thanks - there were a few errors, here is the image

roigcarlo commented 4 years ago

Hi @peterjwilson thx for the dump. I do not see anything wrong. The circular dependencies are a glitch from the software and the other errors are normal.

To be honest I don't know what is the problem. The only unfamiliar thing I see is that it seems to be loading some miketext libs ?¿ which seems extrange to me as they should not be related... could you try to remove that from the path?

Also at this point I would try to:

Let me know if any of these works or it keeps giving problems...

peterjwilson commented 4 years ago

Thanks for the help @roigcarlo . I tried those fixes (I understood the first as removing the minggw path and adding the deplibs to path and re-running config) but unfortunately they didn't work and I still get the same error.

This branch makes cosim use the eigen app instead of external solvers, which gets the test running for me (and "fixes" my immediate issue). But I'm happy to be your windows lab rat if you think this problem may affect general windows users and want to pursue fixing it :)

dagmawibekel commented 4 years ago

Hi, it's me again. As a matter of fact it's not just you... I have the same problem as @peterjwilson.

roigcarlo commented 4 years ago

I am closing this as we moved to 8.0 and we are no longer support the old external solvers app. Still a mystery to my why the import error was happening.

Reopen if needed.