我刚刚克隆了一个工作的小图标环境carnd-term1-gpu
,该环境具有使用0.12.1版本的tenorflow的gpu。该环境安装了许多其他python包。我想升级到最新版本的tenstorflow,所以我做了以下基于tenstorflow Ubuntu:
1) 将现有工作环境克隆为tflow
conda create --name tflow --clone carnd-term1-gpu
此操作已成功完成。
2)源码激活tflow并使用pip安装
source activate tflow
(tflow) xx@pc:~$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
现在,我尝试运行旧环境,假设它不应该被更改。
source activate carnd-term1-gpu
ipython
然后从ipython提示符键入将numpy导入为np
,并获取以下信息:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4ee716103900> in <module>()
----> 1 import numpy as np
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/__init__.py in <module>()
140 return loader(*packages, **options)
141
--> 142 from . import add_newdocs
143 __all__ = ['add_newdocs',
144 'ModuleDeprecationWarning',
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/lib/__init__.py in <module>()
6 from numpy.version import version as __version__
7
----> 8 from .type_check import *
9 from .index_tricks import *
10 from .function_base import *
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/lib/type_check.py in <module>()
9 'common_type']
10
---> 11 import numpy.core.numeric as _nx
12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
13 obj2sctype, zeros
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/core/__init__.py in <module>()
51 from . import shape_base
52 from .shape_base import *
---> 53 from . import einsumfunc
54 from .einsumfunc import *
55 del nt
ImportError: cannot import name 'einsumfunc'
我以为我是通过克隆一个单独的环境并只改变该环境来保护的,但是似乎在一个环境中的安装改变了另一个环境中的行为。正是我以为我在逃避的!出了什么问题,我该如何解决?到目前为止,新环境似乎运行良好。
我检查了两种环境中的文件日期。carnd-term1-gpu
环境中的文件日期与我在tflow
环境中进行升级的日期相同。你知道怎么会这样吗?
我尝试添加缺少的文件einsumfunc。py
到我的carnd-term1-gpu
环境并再次启动Ipython。这一次,当我将numpy作为np导入时,无法导入其他文件。因此,我的carnd-term1-gpu
环境似乎已损坏。
比较每个环境的conda list
并只查看Numpy
,我看到以下内容:对于tflow
环境:
numpy 1.11.3 <pip>
numpy 1.12.1 <pip>
numpy 1.11.3 py35_blas_openblas_200 [blas_openblas] conda-forge
对于carnd-term1-gpu
环境:
numpy 1.11.3 <pip>
numpy 1.11.3 py35_blas_openblas_200 [blas_openblas] conda-forge
然后,我使用conda list--revisions
查看了修订。两种环境仅显示rev 0
的一个版本。同样,查看conda meta/history
仅显示carnd-term1-gpu的原始创建日期为1月13日,而
tflow的原始创建日期为5月9日。因此,这个版本的pip的组合:
pip 9.0.1 py35_0 conda-forge
与此轮结合使用:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
不知何故损坏了环境carnd-term1-gpu
。这看起来像是一个错误,或者我不知何故从tenorflow网站得到了一个损坏的轮子?如果是后者,它怎么会损坏一个不同于安装环境的环境?注意,pip的版本在两个环境中是相同的。
我做了以下工作来调查在我安装之日更改了哪些文件。
find /home/ai/miniconda3/envs/carnd-term1-gpu/ -type f -newermt 2017-05-09 -ls | wc -l
这表明创建/修改了669个文件。其中大部分都在/site packages/numpy/
中,但是有六个。py
,py解析。py
,/setuptools/
,/pkg\u resources/
,轻松安装。py
,/werkzeug/
也受到影响。
conda--版本是4.2。12
我尝试了以下方法来恢复我的旧环境。
conda env export > environment.yml
conda env create -f environment.yml -n sdc-gpu
这导致了以下错误:
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named 'packaging'
CondaValueError: Value error: pip returned an error.
我刚从continuum得到以下结果;“为了防止这种情况发生,您必须在克隆操作中使用--copy
标志。康达设计的核心是广泛使用硬链接。这正是最大的陷阱之一。”
因此,如果我在第一次克隆环境时做到以下几点,我就可以避免破坏旧环境:
Conda创建--名称tflow--复制--clone carnd-term1-gpu
选项<代码>--复制使用副本而不是硬链接或软链接安装所有软件包将阻止pip覆盖文件。
一些正在进行的关于这一点的讨论,以及将来如何解决这一问题,请参见:conda pip breaks
我恢复的唯一选择是重新安装每个损坏的包。使用pip和conda时要小心...