python错误:无法从'cupy.core'导入名称'core'

Posted

技术标签:

【中文标题】python错误:无法从\'cupy.core\'导入名称\'core\'【英文标题】:python error: cannot import name 'core' from 'cupy.core'python错误:无法从'cupy.core'导入名称'core' 【发布时间】:2020-06-06 22:13:41 【问题描述】:

我是 Python 编程的新手,我尝试运行一些 DCGAN 训练脚本 https://github.com/ml5js/training-dcgan

使用 conda 创建环境并构建所有依赖项后,我仍然拥有 运行py程序时出现问题:

RuntimeError: CUDA environment is not correctly set up
(see https://github.com/chainer/chainer#installation).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: cannot import name 'core' from 'cupy.core' (C:\Users\keyvane\anaconda3\lib\site-packages\cupy\core\__init__.py)
> c:\users\keyvane\anaconda3\lib\site-packages\chainer\backends\cuda.py(93)check_cuda_available()
-> raise RuntimeError(msg)

我尝试了几次以正确重新安装整个环境,但我仍然有同样的错误。也许有人知道如何解决这个问题?任何帮助都会很棒:) 这是我的配置:

Windows 10  / Python 3.6 (64bits)
absl-py==0.7.1
astor==0.8.1
astunparse==1.6.3
blinker==1.4
cachetools==4.1.0
certifi==2020.4.5.1
cffi==1.14.0
chainer==6.2.0
chardet==3.0.4
click==7.1.2
cryptography==2.9.2
cupy==6.0.0
cupy-cuda100==6.2.0
fastrlock==0.5
filelock==3.0.12
gast==0.2.2
google-auth==1.16.1
google-auth-oauthlib==0.4.1
google-pasta==0.2.0
grpcio==1.29.0
h5py==2.10.0
idna==2.9
importlib-metadata==1.6.1
Keras==2.2.4
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
Markdown==3.2.2
mkl-fft==1.0.15
mkl-random==1.1.1
mkl-service==2.3.0
numpy==1.18.1
oauthlib==3.1.0
olefile==0.46
opt-einsum==3.2.1
Pillow==7.1.2
protobuf==3.12.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyJWT==1.7.1
pyOpenSSL==19.1.0
pyreadline==2.1
PySocks==1.7.1
PyYAML==5.3.1
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.0
scipy==1.4.1
six==1.14.0
tensorboard==2.2.1
tensorboard-plugin-wit==1.6.0.post3
tensorflow==2.1.0
tensorflow-cpu==2.2.0
tensorflow-estimator==2.1.0
tensorflow-gpu==2.0.0
tensorflow-hub==0.5.0
tensorflowjs==1.2.6
termcolor==1.1.0
typing==3.6.6
typing-extensions==3.6.6
urllib3==1.25.9
Werkzeug==1.0.1
win-inet-pton==1.1.0
wincertstore==0.2
wrapt==1.12.1
zipp==3.1.0

非常感谢!

【问题讨论】:

您有支持 CUDA 的 GPU 吗?您是否安装了 CUDA 工具包?您是否使用the CUDA windows install guide 中的说明验证了您的 CUDA 安装?看起来您的特定 cupy 变体正在期待 CUDA 10.0,但我不能 100% 确定这一点。如果它需要 CUDA 10.0,并且您安装了其他一些 CUDA 版本,那可能无法正常工作。 嗨罗伯特,谢谢你的回复 :) 是的,我检查了,我有一个 Geforce GTX960M,我已经下载并正确安装了 CUDA 10 和整个工具包......所以我不明白出了什么问题出现此错误:S 【参考方案1】:

您是否安装了多个版本的 CUDA(应该可以通过在 Windows 搜索栏中输入“卸载”并查看来判断)。看起来您安装了几个不同版本的 tensorflow,所以我假设您可能也安装了几个版本的 CUDA。如果是这种情况,我将在黑暗中进行猜测,并说当您出于任何原因运行代码时,它会尝试使用与您想要的版本不同的 CUDA 版本。因此,如果我的猜测是正确的,请尝试卸载错误版本的 CUDA,假设您不想要它们。

如果您确实需要多个版本的 CUDA,则可能有一些方法可以在您使用的代码中调用特定版本的 tensorflow(可能是 cuda)。

如果我猜错了,我不知道

【讨论】:

以上是关于python错误:无法从'cupy.core'导入名称'core'的主要内容,如果未能解决你的问题,请参考以下文章

TypeError:参数“x”的类型不正确(预期为cupy.core.core.ndarray,得到了numpy.ndarray)

Python 导入错误:无法从“sklearn.externals”导入名称“六”

AWS Lambda python 错误:Runtime.ImportModuleError:无法导入模块“app”:无法从“pyparsing”导入名称“operatorPrecedence”

为啥我在 Python 中收到错误消息“无法导入名称 NoneType”?

无法从 Python 3 上的 itertools izip 导入

python sklearn中的导入错误。无法加载引用的库