对同一个 OS 上不同版本的 tensorflow 感到困惑
Confused about different versions of tensorflow on the same OS
我需要 运行 一些使用 tensorflow 版本 <2.0 的代码 (https://github.com/gnsrla12/crash_to_not_crash)(我不知道确切的版本是什么)。在我通过“pip3 install tensorflow==1.14”将tensorflow降级到1.14之前。
当我通过 pip3 列出 tensorflow 版本时,我有:
$ pip3 list | grep tensorflow
tensorflow 1.14.0
tensorflow-datasets 2.1.0
tensorflow-estimator 2.0.0
tensorflow-metadata 0.21.1
tensorflow-probability 0.11.0
甚至当我 运行 以下行时:
$ python3 -c 'import tensorflow as tf; print(tf.__version__)'
我有(我没有关注 NumPy 版本引起的 FutureWarnings):
1.14.0
但是当我 运行 一些模块时:
$ python3 ./scripts/test_script.py
内部有这个:
import os, time, random, itertools
import tensorflow as tf
import numpy as np
from sklearn import metrics
from matplotlib import pyplot as plt
print("tf version is ", tf.__version__)
opt = TestOptions().parse()
opt.batchSize = 128
gpu_config = tf.ConfigProto(
device_count = {'GPU': opt.gpu_count}
)
我明白了:
('tf version is ', '2.0.0')
Traceback (most recent call last):
File "test.py", line 18, in <module>
gpu_config = tf.ConfigProto(
AttributeError: 'module' object has no attribute 'ConfigProto'
但是我想用1.14版本,不想用2.0.0。那么,我该如何解决这个问题?
Tensorflow 不喜欢在同一个环境中安装和卸载 bee,这可能会导致像您得到的那样的问题。
我总是建议使用像 anaconda 这样的环境工具来管理你的环境,因此在你的情况下设置 tro 环境,一个用于 tf2.0,一个用于 tf1.14。这样,您始终拥有一个独立完成工作的工作环境。
我还写了一篇关于这个主题的博客 article,您可能会感兴趣。
我需要 运行 一些使用 tensorflow 版本 <2.0 的代码 (https://github.com/gnsrla12/crash_to_not_crash)(我不知道确切的版本是什么)。在我通过“pip3 install tensorflow==1.14”将tensorflow降级到1.14之前。 当我通过 pip3 列出 tensorflow 版本时,我有:
$ pip3 list | grep tensorflow
tensorflow 1.14.0
tensorflow-datasets 2.1.0
tensorflow-estimator 2.0.0
tensorflow-metadata 0.21.1
tensorflow-probability 0.11.0
甚至当我 运行 以下行时:
$ python3 -c 'import tensorflow as tf; print(tf.__version__)'
我有(我没有关注 NumPy 版本引起的 FutureWarnings):
1.14.0
但是当我 运行 一些模块时:
$ python3 ./scripts/test_script.py
内部有这个:
import os, time, random, itertools
import tensorflow as tf
import numpy as np
from sklearn import metrics
from matplotlib import pyplot as plt
print("tf version is ", tf.__version__)
opt = TestOptions().parse()
opt.batchSize = 128
gpu_config = tf.ConfigProto(
device_count = {'GPU': opt.gpu_count}
)
我明白了:
('tf version is ', '2.0.0')
Traceback (most recent call last):
File "test.py", line 18, in <module>
gpu_config = tf.ConfigProto(
AttributeError: 'module' object has no attribute 'ConfigProto'
但是我想用1.14版本,不想用2.0.0。那么,我该如何解决这个问题?
Tensorflow 不喜欢在同一个环境中安装和卸载 bee,这可能会导致像您得到的那样的问题。
我总是建议使用像 anaconda 这样的环境工具来管理你的环境,因此在你的情况下设置 tro 环境,一个用于 tf2.0,一个用于 tf1.14。这样,您始终拥有一个独立完成工作的工作环境。
我还写了一篇关于这个主题的博客 article,您可能会感兴趣。