Tensorflow 1 5 ImportError No module named tensorflow python client

+3 votes

Im trying to run a simple python script that uses Tensorflow to print the available GPU devices. The script is

from tensorflow.python.client import device_lib

def get_available_gpus():
    local_device_protos = device_lib.list_local_devices()
    return [x.name for x in local_device_protos if x.device_type == 'GPU']

get_available_gpus()

I have the following related modules installed:

pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.5.0
Summary: TensorFlow helps the tensors flow
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python3.5/dist-packages
Requires: wheel, six, tensorflow-tensorboard, numpy, absl-py, protobuf

However, when I run the script I get the following error:

python get_available_gpus.py 
Traceback (most recent call last):
  File "get_available_gpus.py", line 2, in <module>
    from tensorflow.python.client import device_lib
ImportError: No module named tensorflow.python.client
Sep 21, 2018 in Python by aryya
• 7,460 points
6,926 views

1 answer to this question.

0 votes

I think it's a bug in Tensorflow and you should open a bug thread about it.

In any case, to workaround this issue, you can use tf.identity to create a float64_ref instead of the float64 x and pass this value as the inputs parameter.

import tensorflow as tf
import numpy as np

with tf.Session() as sess:
    x = tf.Variable(np.ones((2, 3)))
    sess.run(tf.initialize_all_variables())
    out, state = tf.nn.rnn_cell.BasicRNNCell(4)(tf.identity(x), x)
answered Sep 25, 2018 by charlie_brown
• 7,720 points

Related Questions In Python

0 votes
1 answer

tensorflow 1.5 ImportError: No module named tensorflow.python.client

Some of the modules have changed in ...READ MORE

answered Oct 5, 2018 in Python by Priyaj
• 58,020 points
2,761 views
0 votes
1 answer

Python error "ImportError: No module named pygame.locals"

You need to download and install the ...READ MORE

answered Jun 18, 2019 in Python by Greg
6,955 views
0 votes
1 answer

Python: ImportError: No module named Crypto.Cipher

Seems like the pycrypto package is not ...READ MORE

answered Jul 31, 2019 in Python by Hari
25,066 views
0 votes
2 answers

Python error " import requests ImportError: No module named requests"

Hello, Open Cmd or Powershell as Admin. type pip ...READ MORE

answered Nov 28, 2020 in Python by Rohan
• 200 points
17,440 views
0 votes
1 answer
0 votes
2 answers

Python error "ImportError: No module named 'tkinter'"

sudo apt-get install python3-tk Then, >> import tkinter # ...READ MORE

answered Nov 9, 2019 in Python by Icetutor
• 160 points
24,687 views
0 votes
1 answer

Python error "ImportError: No module named SpeechRecognition"

Hi @Hannah, replace  import SpeechRecognition as sr with import speech_recognition ...READ MORE

answered Oct 3, 2019 in Python by Yamini
5,389 views
0 votes
1 answer

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

answered Apr 27, 2020 in Python by MD
• 95,460 points
13,458 views
0 votes
1 answer

How to install Python MySQLdb module using pip?

It's easy to do, but hard to ...READ MORE

answered Aug 20, 2018 in Python by charlie_brown
• 7,720 points
2,291 views
0 votes
1 answer

When I create and remove files rapidly on windows using python I get WindowsError (Error 5)

Here's the short answer: disable any antivirus or ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
1,912 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP