NVIDIA / cuda-python

CUDA Python Low-level Bindings
https://nvidia.github.io/cuda-python/
Other
809 stars 63 forks source link

No module named 'cuda._lib'; 'cuda' is not a package #36

Closed HIEROT closed 2 weeks ago

HIEROT commented 1 year ago

After following the steps on cuda-python to install cuda-python with conda instruction, I try to

from cuda import cuda, nvrtc

as in the example in the pycharm python console, but it raises an error:

Traceback (most recent call last):
  File "D:\Anaconda\envs\hierot\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "D:\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "cuda\cuda.pyx", line 1, in init cuda.cuda
    # Copyright 2021-2022 NVIDIA Corporation.  All rights reserved.
  File "D:\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'cuda._lib'; 'cuda' is not a package

But the code above can be successfully run in the terminal

(hierot) D:\Projects\SimPlatform>python
Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from cuda import cuda, nvrtc
>>>

Please help me with the problem, thanks in advance. Further information provided on request.

I searched with

ModuleNotFoundError: No module named 'xxx'

Solutions suggest configure correct python interpreter, but I believe my interpreter is already properly configured.

And search with

No module named 'xxx'; 'yyy' is not a package

Some says the cause is the name cuda is shadowed by the package name cuda, I think it might be the problem. Please check this.

scottrbrtsn commented 3 months ago

might be related to: https://youtrack.jetbrains.com/issue/PY-23417

leofang commented 3 weeks ago

Sorry for lack of response. Is this still an issue?

leofang commented 2 weeks ago

Closing, please check with PyCharm support for how to proceed. Thanks.