如何更新Cupy / CUDA,使其再次工作并修复我的conda环境?

问题描述

我使用的是Ubuntu 18.04(64位),我试图使用使用Cupy的函数对一些数据进行重新采样,但是收到了错误AttributeError: type object 'cupy.core.core.Indexer' has no attribute '__reduce_cython__'。我看到一个issue on github出现相同的错误,提示它是由于版本不匹配或缺少依赖项引起的。

首先,我尝试使用conda更新cupy,但是当我尝试导入cupy时,我得到一个错误,提示cupy安装不正确,建议尝试pip install cupy --no-cache-dir -vvvv进行修复。这似乎不起作用,由于某些原因,站点软件包中的文件夹称为〜upy(此命令运行时有很多输出/错误,但我不确定它将在何处保存这些消息)。

我尝试按照问题中的建议运行nvcc --version来检查我的cuda版本,但是收到一条错误消息,提示nvcc是无法识别的命令。我以前有cupy / CUDA,但是我尝试用sudo apt install nvidia-cuda-toolkit更新cuda。现在nvcc可以工作并输出Cuda compilation tools,release 9.1,V9.1.85。 (请注意,在/ usr / local / cuda下,version.txt文件显示为“ CUDA版本10.1.168”。)

我仍然遇到错误,因此我尝试sudo apt-get --purge remove "*cublas*" "*cufft*" "*curand*" "*cusolver*" "*cusparse*" "*npp*" "*nvjpeg*" "cuda*" "nsight*"conda uninstall cupy删除文件以便重新开始,但是后来我了解了conda的--revisions参数。现在,我尝试返回到修订版11,但获得以下输出:

PackagesNotFoundError: The following packages are missing from the target environment:
  - conda-forge/linux-64::gnutls==3.6.13=h79a8f9a_0
  - conda-forge/linux-64::openh264==2.1.1=h8b12597_0
  - anaconda/linux-64::cupti==10.1.168=0
  - conda-forge/linux-64::openssl==1.1.1g=h516909a_0
  - anaconda/linux-64::cudnn==7.6.5=cuda10.1_0
  - anaconda/linux-64::tensorflow==2.2.0=gpu_py37h1a511ff_0
  - conda-forge/linux-64::ca-certificates==2020.6.20=hecda079_0
  - conda-forge/linux-64::conda==4.8.3=py37hc8dfbb8_1
  - anaconda/linux-64::tensorflow-base==2.2.0=gpu_py37h8a81be8_0
  - conda-forge/linux-64::nettle==3.4.1=h1bed415_1002
  - anaconda/linux-64::cupy==6.0.0=py37hc0ce245_0
  - anaconda/linux-64::cudatoolkit==10.1.243=h6bb024c_0
  - anaconda/linux-64::_tflow_select==2.1.0=gpu
  - conda-forge/linux-64::lame==3.100=h14c3975_1001

在进一步讲解之前,关于如何解决此问题的任何建议?我的软件更新程序现在给我an error message,表示包装系统已损坏。

Check if you are using third party repositories. If so disable them,since they are a common source of problems.
Furthermore run the following command in a Terminal: apt-get install -f
Transaction failed: The package system is broken,with the rest of the message as follows:
 The following packages have unmet dependencies:

nvidia-cuda-toolkit: Depends: nvidia-profiler (= 9.1.85-3ubuntu1) but 9.1.85-3ubuntu1 is installed
                     Depends: nvidia-cuda-dev (= 9.1.85-3ubuntu1) but it is not installed
                     Depends: opencl-dev but it is a virtual package
                     Depends: libgcc1 (>= 1:3.0) but 1:8.4.0-1ubuntu1~18.04 is installed

由于我没有记录每个步骤的发生情况,因此,这里列出了一些我试图解决此问题的命令,以防它比我上面提到的有用或更有意义:

  485  pip list
  486  pip freeze | grep cupy
  487  nvcc --version
  488  conda update cupy
  489  conda install numba cudatoolkit pyculib
  490  conda update cupy
  491  uname -a
  492  lspci | grep -i nvidia
  493  uname -m && cat /etc/*release
  494  gcc --version
  495  uname -r
  496  cat /var/lib/apt/lists/*cuda*Packages | grep "Package:"  
  497  pip --update cupy
  498  pip install cupy --upgrade
  499  pip install cupy --no-cache-dir -vvvv
  500  pip install cupy
  501  nvcc --version
  502  sudo apt install nvidia-cuda-toolkit
  503  nvcc --version
  504  conda install -c conda-forge cupy
  505  pip freeze
  506  sudo apt-get --purge remove "*cublas*" "*cufft*" "*curand*"  "*cusolver*" "*cusparse*" "*npp*" "*nvjpeg*" "cuda*" "nsight*"
  507  apt-get install -f
  508  sudo apt-get install -f
  509  conda uninstall cupy
  510  conda list
  511  conda list --revisions
  512  conda env list
  513  conda install --revision 11
  514  conda list --revisions
  515  conda install --revision 13

通过卸载CUDA和cupy,然后重新安装来解决。

我遵循了install instructions结尾处列出的CUDA的卸载步骤,以及其他帖子中的其他一些清除命令(我认为这是sudo apt-get --purge remove "*nvidia*")。我删除了先前创建的〜upy和〜upy-6.0.0-py3.7.egg-info文件夹。然后,我再次阅读了有关CUDA的所有安装说明,并使用conda forge安装了cudatoolkit和cupy。遵循他们网站上推荐的cupy说明对我不起作用,但在未能组装好轮子后产生了很长的错误。成功的命令是:

conda install -c nvidia cudatoolkit
conda install -c conda-forge cupy

解决方法

对我来说,

conda install -c conda-forge cupy

将先前步骤中安装的cudatoolkit降级,也降级为不存在的cuda版本。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...