如何在主机上恢复2天前运行的GPU版本的tensorflow?

时间:2018-01-24 17:59:49

标签: tensorflow

就在两天前,在我下载并安装最新的稳定GPU版本的tensorflow之后,我的tensorflow安装工作正常,如我所愿,并报告了这一点:

dt.AsEnumerable().Where(r => r.Field<string>("MSISDN") == MSISDN)

可悲的是,令我完全惊讶的是,今天我的tensorflow安装行为不端,因为它报告了以下内容,即它使用的是CPU版本。世界上发生了什么,以及如何让它再次正常运行,即恢复GPU版本的张量流?这是我私人拥有的工作站,我是唯一的用户。

$ source activate tensorflowgpu
(tensorflowgpu) ga@ga-HP-Z820:~$ python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 20 2017, 18:44:38) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant("Hello tensorflow")
>>> sess = tf.Session()
2018-01-22 12:37:32.119300: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
2018-01-22 12:37:33.339324: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.797
pciBusID: 0000:41:00.0
totalMemory: 7.92GiB freeMemory: 7.80GiB
2018-01-22 12:37:33.339414: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:41:00.0, compute capability: 6.1)
>>> print(sess.run(hello))
b'Hello tensorflow'

现在仔细观察,我的python(不是ipython)做了以下事情,这又是一个很好的行为。这很奇怪 - 2个蟒蛇加载不同的张量流。那么如何强制ipython和python都使用GPU版本的张量流?我真的更喜欢ipython,尤其是对于jupyter笔记本。

ga@ga-HP-Z820:~$ source activate tensorflowgpu
(tensorflowgpu) ga@ga-HP-Z820:~$ ipython
Python 3.5.4 |Anaconda custom (64-bit)| (default, Nov 20 2017, 18:44:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
...   
In [2]: import tensorflow as tf
   ...: hello = tf.constant("Hello tensorflow")
   ...: sess = tf.Session()
   ...: 
2018-01-24 12:34:56.792676: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-24 12:34:56.792719: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-24 12:34:56.792729: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.

我已经在tensorflow网站上关注了linux ubuntu上的tensorflow GPU的安装说明。它没有说要先删除CPU版本。

编辑 - 如下所示,我明确查询了tf版本。它确认安装的两个不同版本是由python vs ipython加载的。我想让两个蟒蛇只使用较新版本的tf,不知何故。

(tensorflowgpu) ga@ga-HP-Z820:~$ python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 20 2017, 18:44:38) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant("Hello tensorflow")
>>> sess = tf.Session()
2018-01-24 12:50:35.846985: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
2018-01-24 12:50:37.222662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.797
pciBusID: 0000:41:00.0
totalMemory: 7.92GiB freeMemory: 7.80GiB
2018-01-24 12:50:37.222721: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:41:00.0, compute capability: 6.1)

1 个答案:

答案 0 :(得分:1)

您需要在ipython中安装内核,以便了解您的环境。目前,ipython正在系统上获取默认的python,而不是环境中的python。您可以通过安装内核(确保您的环境处于活动状态)

pip install ipykernel
python -m ipykernel install --user --name tensorflowgpu

现在,只需在运行ipython时选择此内核