Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing tensorflow-gpu via conda-forge results in using CPU-only tensorflow

I am creating a conda environment solely for using the tensorflow-gpu package from the conda-forge channel

conda create -n tst -c conda-forge tensorflow-gpu

This results in both tensorflow-gpu and tensorflow packages to be installed:

The following NEW packages will be INSTALLED:

    _tflow_1100_select: 0.0.1-gpu
    ...
    tensorboard:        1.10.0-py36_0         conda-forge
    tensorflow:         1.10.0-py36_0         conda-forge
    tensorflow-gpu:     1.10.0-hf154084_0
    ...

Then when I import tensorflow, it does not see GPUs:

>>> import tensorflow as tf
>>> tf.test.is_gpu_available()
2018-09-20 15:29:21.778708: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
False

Questions:

  • why does conda install both tensorflow-gpu and tensorflow packages when only the former is required?
  • can both packages co-exist peacefully, and if so, how to switch between the two?
  • Bonus points: why does everything work fine when installing from the main channel, i.e. conda create -n tst tensorflow-gpu? (My uneducated guess is that in conda-forge, the tensorflow-gpu package actually comes from the main channel and thus has a lower priority during import).
like image 559
user209974 Avatar asked Nov 08 '22 02:11

user209974


1 Answers

From looking at the lists of packages on conda-forge (https://conda-forge.org/feedstocks/), it looks like there's no tensorflow-gpu package there. There's some weird compatibility issues between conda-forge and default anaconda packages - I generally try to avoid mixing the two.

Even if you install as conda install -c anaconda tensorflow-gpu, it pulls in the non-GPU tensorflow package at the same time, but running

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

finds the GPU. So it seems to automatically use the GPU-enabled version. If I were to want to avoid GPU usage, I'd probably wrap my training with with tf.device([CPU ID here]).

like image 168
nweir Avatar answered Nov 14 '22 22:11

nweir