简体   繁体   English

如何在新的 venv 中升级到 Tensorflow2?

[英]How to upgrade to Tensorflow2 in new venv?

Trying to upgrade from Tensorflow1.13 and tensorflow-gpu1.13 to Tensorflow 2. In Anaconda, have cloned previous venv (venvTF1) as venvTF2... Activate venvTF2 in command window... Then have upgraded pip, and then Trying to upgrade from Tensorflow1.13 and tensorflow-gpu1.13 to Tensorflow 2. In Anaconda, have cloned previous venv (venvTF1) as venvTF2... Activate venvTF2 in command window... Then have upgraded pip, and then

pip --upgrade tensorflow

This successfully(?) installs tensorflow 2. If I do a这成功(?)安装 tensorflow 2. 如果我做

pip list

, it shows tensorflow 2 the list, not tensorflow 1.13 for venvTF2 ,它显示 tensorflow 2 列表,而不是 venvTF2 的 tensorflow 1.13

However, if I run python in cmd window:但是,如果我在 cmd window 中运行 python:

python
import tensorflow as tf
tf.test.is_built_with_cuda
True
tf.test.gpu_device_name
my gpu info prints here

But...但...

tf.__version__
'1.13.1'

So how to get new venvTF2 to work with Tensorflow2?那么如何让新的 venvTF2 与 Tensorflow2 一起工作呢? (running Python 3.6.5) (运行 Python 3.6.5)

Must also add that now tensorflow1.13 in original venv is corrupted...cannot import, DLL load failed...还必须补充一点,现在原始 venv 中的 tensorflow1.13 已损坏...无法导入,DLL 加载失败...

I think this is because you have cloned the env.我认为这是因为您已经克隆了环境。 Because of the cloning, all the dependencied are the same.由于克隆,所有依赖项都是相同的。 So it is same as running the command in older venv.所以它与在旧 venv 中运行命令相同。 If you have cloned, all the dependencies have come along with it.如果您已克隆,则所有依赖项都随之而来。

What you need to do is to你需要做的是

Case 1 (Never do it): Either remove one by one the old dependencies.案例1(永远不要这样做):要么一一删除旧的依赖项。

Or Case 2: Best case:或案例 2:最佳案例:

conda create -n your_venv_name tensorflow=2.2

Suggestion : You should try install those packages which you are most dependent on.建议:您应该尝试安装那些您最依赖的软件包。 For example, if you want to have the tf 2.0 , install it first and then when you install python, it'll automatically install the version of python most suitable acording to the version of tf installed.例如,如果你想拥有tf 2.0 ,首先安装它,然后在安装 python 时,它会根据安装的tf版本自动安装最合适的 python 版本。 Same with other packages.与其他软件包相同。

Try to install as many packages with conda just like googling package_name conda install .尝试使用conda安装尽可能多的软件包,就像谷歌搜索package_name conda install一样。 You'll find something like conda install conda-forge your_package or conda install anaconda your_package_name你会发现类似 conda install conda conda install conda-forge your_packageconda install anaconda your_package_name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM