提问人:jcmjne 提问时间:11/13/2023 更新时间:11/13/2023 访问量:42
无法在 Google Colab 上安装 CuPy 12.2.0
Unable to install CuPy 12.2.0 on Google Colab
问:
我想在 Colab 上使用 CuPy 12.2.0,但 Colab 上安装的默认 CuPy 版本是 11.0.0。 我尝试了几种安装版本 12.2.0 的方法,但都失败了。
- 当我尝试使用命令安装 cupy 并将 cupy 导入为 时,我收到了以下消息。
pip install cupy-cuda12x
import cupy
/usr/local/lib/python3.10/dist-packages/cupy/_environment.py:447: UserWarning:
--------------------------------------------------------------------------------
CuPy may not function correctly because multiple CuPy packages are installed
in your environment:
cupy-cuda11x, cupy-cuda12x
Follow these steps to resolve this issue:
1. For all packages listed above, run the following command to remove all
existing CuPy installations:
$ pip uninstall <package_name>
If you previously installed CuPy via conda, also run the following:
$ conda uninstall cupy
2. Install the appropriate CuPy package.
Refer to the Installation Guide for detailed instructions.
https://docs.cupy.dev/en/stable/install.html
--------------------------------------------------------------------------------
warnings.warn(f'''
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/cupy/__init__.py in <module>
16 try:
---> 17 from cupy import _core # NOQA
18 except ImportError as exc:
/usr/local/lib/python3.10/dist-packages/cupy/_core/__init__.py in <module>
2
----> 3 from cupy._core import core # NOQA
4 from cupy._core import fusion # NOQA
ImportError: libcudart.so.12: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
<ipython-input-2-329ec5cf1bc8> in <cell line: 1>()
----> 1 import cupy
/usr/local/lib/python3.10/dist-packages/cupy/__init__.py in <module>
17 from cupy import _core # NOQA
18 except ImportError as exc:
---> 19 raise ImportError(f'''
20 ================================================================
21 {_environment._diagnose_import_error()}
ImportError:
================================================================
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: libcudart.so.12: cannot open shared object file: No such file or directory
================================================================
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
似乎我需要卸载cupy-cuda11x,所以我将其卸载为.
然后我尝试再次导入 cupy 作为pip uninstall cupy-cuda11x
import cupy
cupy.arange(3)
我收到了不同的错误消息,
AttributeError Traceback (most recent call last)
<ipython-input-8-0a93c279befd> in <cell line: 2>()
1 import cupy
----> 2 cupy.arange(3)
AttributeError: module 'cupy' has no attribute 'arange'
这就像,Cupy 模块是空的。
至于CUDA兼容性,Colab的CUDA版本是11.8,与CuPy 12.2兼容。
>>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
- 当我尝试使用命令安装 cupy 时,我收到了以下错误消息。
pip install cupy
Building wheels for collected packages: cupy
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Building wheel for cupy (setup.py) ... error
ERROR: Failed building wheel for cupy
Running setup.py clean for cupy
Failed to build cupy
ERROR: Could not build wheels for cupy, which is required to install pyproject.toml-based projects
在这一点上,我不知道如何解决它。
- 当我尝试按照建议使用以下命令安装 cupy 时,
pip install chainer
curl https://colab.chainer.org/install | sh -
我刚刚收到以下错误消息,我放弃了。运行时类型被选为 T4 GPU。
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1553 100 1553 0 0 12757 0 --:--:-- --:--:-- --:--:-- 12834
********************************************************************************
CUDA version could not be detected!
Try installing Chainer manually by: pip install chainer
********************************************************************************
答:
1赞
kmaehashi
11/13/2023
#1
默认情况下,CuPy 安装在 Google Colab 上,因此您可以 .如果您更喜欢最新版本的 CuPy,请尝试 。import cupy
pip install -U cupy-cuda11x
评论
pip install cupy-cuda12x
12x