Python 3.7 compiled Fortran PYD (DLL) not working. [WinError 1114] A dynamic link library (DLL) initialization routine failed

1

I'm trying to help a coworker get a Fortran module compiled and running on our server. He's able to compile/run it locally on his machine, but when I try to replicate the environment on our xenon servers, the module won't load in the script.

Environment: WinServer 2012R2 with Intel(R) Xeon(R) CPU E5-2697 v2
Compiler: tdm64-gcc-5.1.0-2.exe (with fortran support checked at install time)
Anaconda version: 4.5.11
Python version: Python 3.7.1 (default, Oct 28 2018, 08:39:03) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32

Compilation command:

python C:\ProgramData\Anaconda3\envs\python_server\Scripts\f2py.py -m nnpx -c --fcompiler=gnu95 --compiler=mingw32  nnpx.f90 --f90flags="-mwindows -m64 -march='ivybridge' -fopenmp -lgomp"

NOTE: I've actually tried a number of combinations of those f90 flags, none of which seemed to be the magic combination .
The module appears to compile OK, and creates a file named "nnpx.cp37-win_amd64.pyd" that I'm placing in the same folder as the test script shown below

Test python script attempting to load module (PYD):

#### BEGIN Script Snippet#########################
import ctypes
import pdb

ctypes.WinDLL("nnpx.cp37-win_amd64.pyd")

#; pdb.set_trace()
#############################
import nnpx as nn

#### END Script Snippet#########################

Here's the error I get when trying to load that DLL:

(python_server) e:\Python_Server\Fortran>python ..\scripts\nnpx_test.py
Traceback (most recent call last):
  File "..\scripts\nnpx_test.py", line 24, in <module>
    ctypes.WinDLL("nnpx.cp37-win_amd64.pyd")
  File "C:\ProgramData\Anaconda3\envs\python_server\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed

Here are the associated errors thrown in the windows system event viewer:

Fault bucket 1820906866837524874, type 4
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: python.exe
P2: 3.7.1150.1013
P3: 5bd5bc42
P4: libgfortran_64-3.dll
P5: 0.0.0.0
P6: a688a670
P7: c0000005
P8: 0000000000018ae0
P9: 
P10: 

Attached files:
C:\Users\myuserpin\AppData\Local\Temp\WERBAB7.tmp.appcompat.txt
C:\Users\myuserpin\AppData\Local\Temp\WERC074.tmp.WERInternalMetadata.xml
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\memory.hdmp
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\triagedump.dmp

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_3cf0dd9f

Analysis symbol: 
Rechecking for solution: 0
Report Id: 941538b8-e9d8-11e8-810d-d89d67f4dd04
Report Status: 0
Hashed bucket: 19c0c60458b6bae2d9452925d6eb918a

.

Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: python.exe
P2: 3.7.1150.1013
P3: 5bd5bc42
P4: libgfortran_64-3.dll
P5: 0.0.0.0
P6: a688a670
P7: c0000005
P8: 0000000000018ae0
P9: 
P10: 

Attached files:
C:\Users\myuserpin\AppData\Local\Temp\WERBAB7.tmp.appcompat.txt
C:\Users\myuserpin\AppData\Local\Temp\WERC074.tmp.WERInternalMetadata.xml
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\memory.hdmp
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\triagedump.dmp

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082

Analysis symbol: 
Rechecking for solution: 0
Report Id: 941538b8-e9d8-11e8-810d-d89d67f4dd04
Report Status: 4
Hashed bucket: 

.

Faulting application name: python.exe, version: 3.7.1150.1013, time stamp: 0x5bd5bc42
Faulting module name: libgfortran_64-3.dll, version: 0.0.0.0, time stamp: 0xa688a670
Exception code: 0xc0000005
Fault offset: 0x0000000000018ae0
Faulting process id: 0x4d14
Faulting application start time: 0x01d47de553900866
Faulting application path: C:\ProgramData\Anaconda3\envs\python_server\python.exe
Faulting module path: C:\TDM-GCC-64\bin\libgfortran_64-3.dll
Report Id: 941538b8-e9d8-11e8-810d-d89d67f4dd04
Faulting package full name: 
Faulting package-relative application ID: 

Dependency checking: I've also tried checking the dependencies, as suggested here but can't seem to get them ironed out perfectly (which is why I assume I can't get python to properly load the module). I had to copy the "libgcc_s_seh_64-1.dll" and "libgfortran_64-3.dll" into the same folder as the PYD file, and then they show as "correct" on the dependency explorer, but the "python37.dll" never gets a correct checksum. I don't know if that matters, but I've tried every copy of python37.dll (in every conda environment) I can find on my system, and none work. They all give me the "checksum incorrect" in dependency checker.

Any Thoughts or suggestions on how to get this FORTRAN module to load properly into python script?

WITH python37.dll in same folder as PYD WITHOUT python37.dll in same folder as PYD

python-3.x
fortran
mingw-w64
f2py
asked on Stack Overflow Nov 16, 2018 by NumericOverflow

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0