3

I'm trying to install tensorflow with gpu support into a conda environment

I use the command:

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl

When I look at the packages installed with conda list I wind up with a package called tensorflow-gpu.

You cannot even import this package because it has a '-' in it.

How can I change the name to 'tensorflow'?

Edit: I'm now thinking that there must be something more to this. Why would a major package in the deep learning community have this apparent problem. Hopefully, a tensorflow expert can answer. I'm following the directions for Ubuntu and Anaconda here: https://www.tensorflow.org/install/install_linux

Chuck Carlson
  • 977
  • 8
  • 26
  • I assume it might not be possible with `pip` – orvi May 06 '17 at 04:21
  • A possible "hack" until you figure this out is to [import the module as a string](http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path), and then reassign it to a valid Python name, such as `tensorflow_gpu`. – Christian Dean May 06 '17 at 04:28
  • Problem is other packages I import are also trying to import 'tensorflow' and fail. Is there a pip command to change the name? – Chuck Carlson May 06 '17 at 04:32
  • Would using the string hack satisfy other packages that import tensorflow? – Chuck Carlson May 06 '17 at 04:43
  • It seems pretty silly to have this problem. I'm following the instructions here: https://www.tensorflow.org/install/install_linux#the_url_of_the_tensorflow_python_package – Chuck Carlson May 06 '17 at 05:10
  • the actual package is called "tensorflow", tensorflow-gpu and tensorflow both install the same package as far as pip is concerned – Yaroslav Bulatov May 06 '17 at 18:40

2 Answers2

1

When you install the tensorflow gpu version, Anaconda will show that you have installed tensorflow-gpu. The -gpu just indicates that it is a gpu version and is not a part of the name. You can still just import tensorflow and the gpu version will be found.

Chuck Carlson
  • 977
  • 8
  • 26
0

I had a similar problem which was quite frustrating. I started with recently built .whl file and tried to install.

pip install /home/ubuntu/xfer/tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl

Command line testing:

pip show tensorflow

no package called tensorflow

pip show tensorflow-gpu

but there is a package tensorflow-gpu at version 1.2.1

However, running one line in python failed despite assurances that conda would substitute:

import tensorflow as tf

I then repeated the pip install of the .whl file with the --upgrade option:

pip install --upgrade /home/ubuntu/xfer/tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl

And then the one line of python succeeded:

import tensorflow as tf

And in fact based on https://www.tensorflow.org/install/install_linux#run_a_short_tensorflow_program, one would then run a slightly longer program which also succeeds:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Mark Andersen
  • 868
  • 6
  • 8