question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cupy-6.0.0 fails to import on Python 3.8.0b1 for Windows

See original GitHub issue

Just a heads-up: using CuPy 6.0.0 built from source with Cython-0.29.10 and CUDA 10.1 on Python 3.8.0b1, Windows 10, cupy fails to import (at least on my system, traceback below). This is due to a change of the DLL resolution on that platform. A quick workaround if CUDA_PATH is defined:

diff --git a/cupy/__init__.py b/cupy/__init__.py
index 006e60cc3..8d4973193 100644
--- a/cupy/__init__.py
+++ b/cupy/__init__.py
@@ -6,6 +6,11 @@ import six

 from cupy import _version

+try:
+    import os
+    os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))
+except Exception:
+    pass

 try:
     from cupy import core  # NOQA
> python.exe -c"import cupy"
Traceback (most recent call last):
  File "X:\Python38\lib\site-packages\cupy\__init__.py", line 11, in <module>
    from cupy import core  # NOQA
  File "X:\Python38\lib\site-packages\cupy\core\__init__.py", line 1, in <module>
    from cupy.core import core  # NOQA
  File "cupy\core\core.pyx", line 1, in init cupy.core.core
  File "X:\Python38\lib\site-packages\cupy\cuda\__init__.py", line 4, in <module>
    from cupy.cuda import compiler  # NOQA
  File "X:\Python38\lib\site-packages\cupy\cuda\compiler.py", line 11, in <module>
    from cupy.cuda import device
  File "cupy\cuda\runtime.pxd", line 8, in init cupy.cuda.device
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "X:\Python38\lib\site-packages\cupy\__init__.py", line 32, in <module>
    six.reraise(ImportError, ImportError(msg), exc_info[2])
  File "X:\Python38\lib\site-packages\six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "X:\Python38\lib\site-packages\cupy\__init__.py", line 11, in <module>
    from cupy import core  # NOQA
  File "X:\Python38\lib\site-packages\cupy\core\__init__.py", line 1, in <module>
    from cupy.core import core  # NOQA
  File "cupy\core\core.pyx", line 1, in init cupy.core.core
  File "X:\Python38\lib\site-packages\cupy\cuda\__init__.py", line 4, in <module>
    from cupy.cuda import compiler  # NOQA
  File "X:\Python38\lib\site-packages\cupy\cuda\compiler.py", line 11, in <module>
    from cupy.cuda import device
  File "cupy\cuda\runtime.pxd", line 8, in init cupy.cuda.device
ImportError: CuPy is not correctly installed.

If you are using wheel distribution (cupy-cudaXX), make sure that the version of CuPy you installed matches with the version of CUDA on your host.
Also, confirm that only one CuPy package is installed:
  $ pip freeze

If you are building CuPy from source, please check your environment, uninstall CuPy and reinstall it with:
  $ pip install cupy --no-cache-dir -vvvv

Check the Installation Guide for details:
  https://docs-cupy.chainer.org/en/latest/install.html

original error: DLL load failed: The specified module could not be found.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
C9KenDatacommented, Oct 18, 2019

went to environmental variable, added the bin path and i can import cupy now. gracias

0reactions
dome272commented, May 3, 2020

Im getting the same issue as @cgohlke I installed cuda 10.2 and installed pip install cupy-cuda102 --no-cache-dir -vvvv (Initially I installed just pip install cupy-cuda102 but it didnt work either) Furthermore Im using Python 3.6.5 Error: `

import cupy Traceback (most recent call last): File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy_init_.py”, line 21, in <module> from cupy import core # NOQA File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\core_init_.py”, line 1, in <module> from cupy.core import core # NOQA File “cupy\core\core.pyx”, line 1, in init cupy.core.core File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\cuda_init_.py”, line 5, in <module> from cupy.cuda import compiler # NOQA File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\cuda\compiler.py”, line 13, in <module> from cupy.cuda import device File “cupy\cuda\runtime.pxd”, line 8, in init cupy.cuda.device ImportError: DLL load failed: The specified module could not be found. During handling of the above exception, another exception occurred: Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy_init_.py”, line 42, in <module> six.reraise(ImportError, ImportError(msg), exc_info[2]) File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\six.py”, line 702, in reraise raise value.with_traceback(tb) File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy_init_.py”, line 21, in <module> from cupy import core # NOQA File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\core_init_.py”, line 1, in <module> from cupy.core import core # NOQA File “cupy\core\core.pyx”, line 1, in init cupy.core.core File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\cuda_init_.py”, line 5, in <module> from cupy.cuda import compiler # NOQA File “C:\Users\youre\AppData\Local\Programs\Python\Python36\lib\site-packages\cupy\cuda\compiler.py”, line 13, in <module> from cupy.cuda import device File “cupy\cuda\runtime.pxd”, line 8, in init cupy.cuda.device ImportError: CuPy is not correctly installed. If you are using wheel distribution (cupy-cudaXX), make sure that the version of CuPy you installed matches with the version of CUDA on your host. Also, confirm that only one CuPy package is installed: $ pip freeze If you are building CuPy from source, please check your environment, uninstall CuPy and reinstall it with: $ pip install cupy --no-cache-dir -vvvv Check the Installation Guide for details: https://docs-cupy.chainer.org/en/latest/install.html original error: DLL load failed: The specified module could not be found. `

As suggested maybe it has something to do with the env variables but Im not sure what I should edit there. The CUDA_PATH seems to be set C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2

Any help would be appreciated…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to import module due to python unable to resolve ...
Hi, I am building python ibm_db C extension for Python 3.8 support. ... in <module> ImportError: DLL load failed while importing ibm_db: The ......
Read more >
1718246 – python-tables fails to build with Python 3.8
Summary: python-tables fails to build with Python 3.8 ... closed, Python 3.8 ImportError: cannot import name 'clock' from 'time', 2021-01-10 13:54:36 UTC ...
Read more >
Can't import dll module in Python - windows - Stack Overflow
Try using the full path with constructor syntax. Error: could not find libuvc! The issue is that the file exists since it was...
Read more >
Unable to import python package (zope) in Azure Runbooks ...
Microsoft Q&A is the best place to get answers to all your technical questions on Microsoft products and services. Community. Forum.
Read more >
pypng · PyPI
Pure Python library for saving and loading PNG images. ... import png png.from_array([[255, 0, 0, 255], [0, 255, 255, 0]], ... Release 0.0.21....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found