错误:安装tensorflow-gpu〜=1.14时无法卸载'wrapt'。

11

我试图安装以下版本的TensorFlow-GPU,因为gitrepo的作者在这里建议使用它。

[jalal@goku examples]$ pip install tensorflow-gpu~=1.14
Collecting tensorflow-gpu~=1.14
  Using cached https://files.pythonhosted.org/packages/a5/ad/933140e74973fb917a194ab814785e7c23680ca5dee6d663a509fe9579b6/tensorflow_gpu-1.15.0-cp36-cp36m-manylinux2010_x86_64.whl
Processing /home/grad3/jalal/.cache/pip/wheels/d7/de/2e/efa132238792efb6459a96e85916ef8597fcb3d2ae51590dfd/wrapt-1.11.2-cp36-cp36m-linux_x86_64.whl
Requirement already satisfied: protobuf>=3.6.1 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (3.11.0)
Requirement already satisfied: tensorflow-estimator==1.15.1 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.15.1)
Requirement already satisfied: six>=1.10.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.13.0)
Requirement already satisfied: wheel>=0.26 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.33.6)
Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.15.0)
Requirement already satisfied: termcolor>=1.1.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.1.0)
Requirement already satisfied: opt-einsum>=2.3.2 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (3.1.0)
Collecting keras-applications>=1.0.8
  Using cached https://files.pythonhosted.org/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl
Requirement already satisfied: keras-preprocessing>=1.0.5 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.0.5)
Requirement already satisfied: grpcio>=1.8.6 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.25.0)
Requirement already satisfied: absl-py>=0.7.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.8.1)
Requirement already satisfied: google-pasta>=0.1.6 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.1.8)
Processing /home/grad3/jalal/.cache/pip/wheels/5c/2e/7e/a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd/gast-0.2.2-cp36-none-any.whl
Requirement already satisfied: astor>=0.6.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.8.0)
Requirement already satisfied: numpy<2.0,>=1.16.0 in /home/grad3/jalal/.local/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.17.4)
Requirement already satisfied: setuptools in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from protobuf>=3.6.1->tensorflow-gpu~=1.14) (42.0.2)
Requirement already satisfied: markdown>=2.6.8 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow-gpu~=1.14) (3.1.1)
Requirement already satisfied: werkzeug>=0.11.15 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow-gpu~=1.14) (0.16.0)
Requirement already satisfied: h5py in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from keras-applications>=1.0.8->tensorflow-gpu~=1.14) (2.7.1)
Installing collected packages: wrapt, keras-applications, gast, tensorflow-gpu
  Found existing installation: wrapt 1.10.11
ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

我该如何解决这个安装问题?

关于我的系统,以下是一些简单的信息:

$ cat /proc/version
Linux version 3.10.0-1062.4.3.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Wed Nov 13 23:58:53 UTC 2019


$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.7.1908 (Core)
Release:    7.7.1908
Codename:   Core


$ python
Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 09:07:38) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>> import deepposekit
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages/deepposekit/__init__.py", line 20, in <module>
    from deepposekit.io import TrainingGenerator, DataGenerator
  File "/scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages/deepposekit/io/__init__.py", line 18, in <module>
    from deepposekit.io.BaseGenerator import BaseGenerator
  File "/scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages/deepposekit/io/BaseGenerator.py", line 16, in <module>
    from tensorflow.keras.utils import Sequence
ModuleNotFoundError: No module named 'tensorflow'

我有以下GPU:

$ nvidia-smi
Sat Dec  7 22:48:51 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.67       Driver Version: 418.67       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 108...  Off  | 00000000:05:00.0  On |                  N/A |
|  0%   28C    P0    61W / 250W |   1462MiB / 11178MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 108...  Off  | 00000000:06:00.0 Off |                  N/A |
|  0%   28C    P8    13W / 250W |     12MiB / 11178MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

这是我的 CUDA 版本:

$ cat /usr/local/cuda/version.txt
CUDA Version 10.0.130

$ pip list | grep tensorflow
tensorflow-estimator               1.15.1  




[jalal@goku examples]$ yum search wrapt
Loaded plugins: aliases, changelog, copr, fastestmirror, kabi, langpacks, priorities, tmprepo, verify, versionlock
Loading support for Red Hat kernel ABI
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.seas.harvard.edu
 * centos-sclo-sclo: mirrors.seas.harvard.edu
 * remi-php70: mirror.pit.teraswitch.com
 * remi-php71: mirror.pit.teraswitch.com
 * remi-php73: mirror.pit.teraswitch.com
 * remi-safe: mirror.pit.teraswitch.com
 * ulyaoth: repos.ulyaoth.com
 * webtatic: us-east.repo.webtatic.com
Atom                                                                                                                                                                                                       140/140
1075 packages excluded due to repository priority protections
=============================================================================================== N/S matched: wrapt ================================================================================================
python-wrapt.x86_64 : A Python module for decorators, wrappers and monkey patching
python36-wrapt.x86_64 : A Python module for decorators, wrappers and monkey patching

  Name and summary matches only, use "search all" for everything.
[jalal@goku examples]$ sudo yum remove python-wrapt.x86_64 
Loaded plugins: aliases, changelog, copr, fastestmirror, kabi, langpacks, priorities, tmprepo, verify, versionlock
Loading support for Red Hat kernel ABI
No Match for argument: python-wrapt.x86_64
No Packages marked for removal
[jalal@goku examples]$ sudo yum remove python36-wrapt.x86_64 
Loaded plugins: aliases, changelog, copr, fastestmirror, kabi, langpacks, priorities, tmprepo, verify, versionlock
Loading support for Red Hat kernel ABI
No Match for argument: python36-wrapt.x86_64
No Packages marked for removal

1
我现在不在我的工作电脑上,所以无法检查正确的软件包名称。可能是 yum remove python-wrapt。(然后在你删除它之后,你需要重试 pip 安装 tensorflow-gpu)。 - William D. Irons
我搜索了wrapt但未找到已安装的。 - Mona Jalal
它在pip列表中,但我应该使用pip卸载它吗?$ pip list | grep wrapt wrapt 1.10.11 - Mona Jalal
2
好的,你正在使用conda。我没有注意到这一点。请尝试运行conda update wrapt或者conda update --all进行更新。更多信息请参考:https://github.com/tensorflow/tensorflow/issues/30191 - William D. Irons
$ pip uninstall wrapt 错误:无法卸载'wrapt'。它是一个distutils安装的项目,因此我们无法准确确定哪些文件属于它,这将导致只有部分卸载。 - Mona Jalal
显示剩余4条评论
7个回答

22

尝试使用以下命令:

pip install wrapt --upgrade --ignore-installed
pip install tensorflow-gpu

祝好运。


9

首先,按照以下步骤进行:

$ conda update wrapt

并且,接着,
[jalal@goku examples]$ pip install tensorflow-gpu~=1.14
Collecting tensorflow-gpu~=1.14
  Using cached https://files.pythonhosted.org/packages/a5/ad/933140e74973fb917a194ab814785e7c23680ca5dee6d663a509fe9579b6/tensorflow_gpu-1.15.0-cp36-cp36m-manylinux2010_x86_64.whl
Requirement already satisfied: numpy<2.0,>=1.16.0 in /home/grad3/jalal/.local/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.17.4)
Requirement already satisfied: google-pasta>=0.1.6 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.1.8)
Requirement already satisfied: wrapt>=1.11.1 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.11.2)
Requirement already satisfied: absl-py>=0.7.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.8.1)
Collecting keras-applications>=1.0.8
  Using cached https://files.pythonhosted.org/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl
Requirement already satisfied: six>=1.10.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.13.0)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.0.5)
Requirement already satisfied: opt-einsum>=2.3.2 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (3.1.0)
Requirement already satisfied: protobuf>=3.6.1 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (3.11.0)
Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.15.0)
Requirement already satisfied: wheel>=0.26 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.33.6)
Requirement already satisfied: termcolor>=1.1.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.1.0)
Collecting tensorflow-estimator==1.15.1
  Using cached https://files.pythonhosted.org/packages/de/62/2ee9cd74c9fa2fa450877847ba560b260f5d0fb70ee0595203082dafcc9d/tensorflow_estimator-1.15.1-py2.py3-none-any.whl
Processing /home/grad3/jalal/.cache/pip/wheels/5c/2e/7e/a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd/gast-0.2.2-cp36-none-any.whl
Requirement already satisfied: astor>=0.6.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (0.8.0)
Requirement already satisfied: grpcio>=1.8.6 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu~=1.14) (1.25.0)
Requirement already satisfied: h5py in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from keras-applications>=1.0.8->tensorflow-gpu~=1.14) (2.7.1)
Requirement already satisfied: setuptools in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from protobuf>=3.6.1->tensorflow-gpu~=1.14) (42.0.2.post20191201)
Requirement already satisfied: werkzeug>=0.11.15 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow-gpu~=1.14) (0.16.0)
Requirement already satisfied: markdown>=2.6.8 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow-gpu~=1.14) (3.1.1)
Installing collected packages: keras-applications, tensorflow-estimator, gast, tensorflow-gpu
  Found existing installation: Keras-Applications 1.0.6
    Uninstalling Keras-Applications-1.0.6:
      Successfully uninstalled Keras-Applications-1.0.6
  Found existing installation: gast 0.3.2
    Uninstalling gast-0.3.2:
      Successfully uninstalled gast-0.3.2
Successfully installed gast-0.2.2 keras-applications-1.0.8 tensorflow-estimator-1.15.1 tensorflow-gpu-1.15.0

8

您可以按顺序尝试以下方法:

pip install -U --ignore-installed wrapt
pip install tensorflow

0

通过命令 sudo rm /usr/lib/python3/dist-packages/wrapt-1.10.11.egg-info 删除文件 wrapt-1.10.11.egg-info。

然后重新安装 tensorflow。


0

在你的 /home/grad3/jalal/.cache/pip/wheels/ 文件夹中找到那个 .whl 的缓存文件...

将其删除。

然后按照常规安装程序重新操作。这对我起作用了。


0
pip install --upgrade pip
conda update --all
pip install tensorflow


0

更新 Conda 并尝试重新安装 Tensorflow 对我有用:

conda update --all
pip install tensorflow

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接