Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import torchmaxflowcpp, DLL load failed while importing #9

Open
rayLemond opened this issue Dec 15, 2022 · 4 comments
Open

Can't import torchmaxflowcpp, DLL load failed while importing #9

rayLemond opened this issue Dec 15, 2022 · 4 comments

Comments

@rayLemond
Copy link

Hi masadcv, great work with torch support on this algo. I do pip install and try run the demo, it shows 'DLL load failed while importing torchmaxflowcpp'.

I see there is a 'torchmaxflow.cpp' file, but i don't know how to connect python with cpp.

@masadcv
Copy link
Owner

masadcv commented Dec 15, 2022

Hi @rayLemond ,

Many thanks for your interest.
The library should be automatically linked with the DLLs during installation. So it is likely that something is going wrong on your setup during installation.

Can you please fill out the following bug report template and provide any additional detail that you think could be relevant for checking what is going wrong here:

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@rayLemond
Copy link
Author

Thanks for the response, i m using an anaconda virtual environment, here are the pacakage list:

# Name                    Version                   Build  Channel
blas                      1.0                         mkl
brotli                    1.0.9                h2bbff1b_7
brotli-bin                1.0.9                h2bbff1b_7
brotlipy                  0.7.0           py39h2bbff1b_1003
ca-certificates           2022.10.11           haa95532_0
certifi                   2022.9.24        py39haa95532_0
cffi                      1.15.1           py39h2bbff1b_3
charset-normalizer        2.0.4              pyhd3eb1b0_0
colorama                  0.4.5            py39haa95532_0
configargparse            1.4                pyhd3eb1b0_0
contourpy                 1.0.5            py39h59b6b97_0
cpuonly                   2.0                           0    pytorch
cryptography              38.0.1           py39h21b164f_0
cycler                    0.11.0             pyhd3eb1b0_0
fftw                      3.3.9                h2bbff1b_1
flit-core                 3.6.0              pyhd3eb1b0_0
fonttools                 4.25.0             pyhd3eb1b0_0
freetype                  2.12.1               ha860e81_0
glib                      2.69.1               h5dc1a3c_2
gst-plugins-base          1.18.5               h9e645db_0
gstreamer                 1.18.5               hd78058f_0
icc_rt                    2022.1.0             h6049295_2
icu                       58.2                 ha925a31_3
idna                      3.4              py39haa95532_0
intel-openmp              2021.4.0          haa95532_3556
jpeg                      9e                   h2bbff1b_0
kiwisolver                1.4.2            py39hd77b12b_0
lerc                      3.0                  hd77b12b_0
libbrotlicommon           1.0.9                h2bbff1b_7
libbrotlidec              1.0.9                h2bbff1b_7
libbrotlienc              1.0.9                h2bbff1b_7
libclang                  12.0.0          default_h627e005_2
libdeflate                1.8                  h2bbff1b_5
libffi                    3.4.2                hd77b12b_6
libiconv                  1.16                 h2bbff1b_2
libogg                    1.3.5                h2bbff1b_1
libpng                    1.6.37               h2a8f88b_0
libtiff                   4.4.0                h8a3f274_2
libuv                     1.40.0               he774522_0
libvorbis                 1.3.7                he774522_0
libwebp                   1.2.4                h2bbff1b_0
libwebp-base              1.2.4                h2bbff1b_0
libxml2                   2.9.14               h0ad7f3c_0
libxslt                   1.1.35               h2bbff1b_0
lz4-c                     1.9.3                h2bbff1b_1
matplotlib                3.6.2            py39haa95532_0
matplotlib-base           3.6.2            py39h1094b8e_0
mkl                       2021.4.0           haa95532_640
mkl-service               2.4.0            py39h2bbff1b_0
mkl_fft                   1.3.1            py39h277e83a_0
mkl_random                1.2.2            py39hf11a4ad_0
munkres                   1.1.4                      py_0
networkx                  2.8.4            py39haa95532_0
numpy                     1.23.4           py39h3b20f71_0
numpy-base                1.23.4           py39h4da318b_0
openssl                   1.1.1s               h2bbff1b_0
packaging                 21.3               pyhd3eb1b0_0
pcre                      8.45                 hd77b12b_0
pillow                    9.2.0            py39hdc2b20a_1
pip                       22.3.1           py39haa95532_0
ply                       3.11             py39haa95532_0
pycparser                 2.21               pyhd3eb1b0_0
pyopenssl                 22.0.0             pyhd3eb1b0_0
pyparsing                 3.0.9            py39haa95532_0
pyqt                      5.15.7           py39hd77b12b_0
pyqt5-sip                 12.11.0          py39hd77b12b_0
pysocks                   1.7.1            py39haa95532_0
python                    3.9.15               h6244533_2
python-dateutil           2.8.2              pyhd3eb1b0_0
pytorch                   1.13.0              py3.9_cpu_0    pytorch
pytorch-mutex             1.0                         cpu    pytorch
pyyaml                    6.0              py39h2bbff1b_1
qt-main                   5.15.2               he8e5bd7_7
qt-webengine              5.15.9               hb9a9bb5_4
qtwebkit                  5.212                h3ad3cdb_4
requests                  2.28.1           py39haa95532_0
scipy                     1.9.3            py39he11b74f_0
setuptools                65.5.0           py39haa95532_0
sip                       6.6.2            py39hd77b12b_0
six                       1.16.0             pyhd3eb1b0_1
sqlite                    3.40.0               h2bbff1b_0
tk                        8.6.12               h2bbff1b_0
toml                      0.10.2             pyhd3eb1b0_0
torchmaxflow              0.0.7                    pypi_0    pypi
torchvision               0.14.0                 py39_cpu    pytorch
tornado                   6.2              py39h2bbff1b_0
tqdm                      4.64.1           py39haa95532_0
typing_extensions         4.4.0            py39haa95532_0
tzdata                    2022g                h04d1e81_0
urllib3                   1.26.13          py39haa95532_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.37.1             pyhd3eb1b0_0
win_inet_pton             1.1.0            py39haa95532_0
wincertstore              0.2              py39haa95532_2
xz                        5.2.8                h8cc25b3_0
yaml                      0.2.5                he774522_0
zlib                      1.2.13               h8cc25b3_0
zstd                      1.5.2                h19a0ad4_0

torchmaxflow is installed by 'pip install torchmaxflow'.

Open the demo project in PyCharm, then at the start of file './torchmaxflow/_ init _.py', the line 'import torchmaxflowcpp' reports bug 'No module name 'torchmaxflowcpp''.

Then i run 'setup.py', and the above bug is gone, and i can see the code of 'torchmaxflowcpp.py' file.

Then i run 'demo_maxflow.py' and got:

Traceback (most recent call last):
  File "C:\Codes\torchmaxflow\demo_maxflow.py", line 8, in <module>
    import torchmaxflow
  File "C:\Codes\torchmaxflow\torchmaxflow\__init__.py", line 59, in <module>
    import torchmaxflowcpp
ImportError: DLL load failed while importing torchmaxflowcpp:

OS: Windows 10 Professional (21H1)

@masadcv
Copy link
Owner

masadcv commented Dec 16, 2022

Many thanks for providing further details.
I have looked into this and the cause is that current pre-compiled wheels for torchmaxflow are compiled using pytorch 1.10
You have pytorch 1.13 which is causing DLL link errors.

I will look into resolving this from package side.. however for now there are two workarounds that you could use to continue your work:

  1. Downgrade to pytorch v1.10 using conda install pytorch==1.10.1 cpuonly -c pytorch - you can also change to GPU version if you plan to train neural networks on GPU... I added cpuonly because I see you already have cpuonly installation of pytorch.
  2. Install by forcing package to build from source, you can do this using: pip install --no-binary torchmaxflow torchmaxflow --no-build-isolation

Please do let me know if you still experience issues with the proposed workarounds.

I will get back with a PR to fix the issue within pypi package manager for long term solution.... however currently I am on vacation for Christmas, so this will be sometime in new year...

@rayLemond
Copy link
Author

Thank you for the comprehensive response, i do get the solutions.

Sorry for interrupting the holiday, no hurry at all, it is just a trial run.

Have fun, cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants