Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't import tensorflow-gpu

I've successfully installed tensorflow with pip install tensorflow and that all works as expected.

I can also successfully install tensorflow-gpu with pip install tensorflow-gpu but I can't import it in my python script:

import tensorflow-gpu

File "<stdin>", line 1
import tensorflow-gpu
                 ^
SyntaxError: invalid syntax

i've installed CUDA v9.0 and run windows 10

like image 760
Seppukki Avatar asked Dec 16 '18 11:12

Seppukki


2 Answers

To ensure that the tensorflow package is using your GPU, do this:

import tensorflow as tf

sess = tf.Session()

See the output on the console, if it shows your GPU information on creation of the session as shown below.

Notice "GeForce 940MX" in the information. Also note that Tensorflow will use a Nvidia GPU only if the compute capability score is above 3.5 . More about that here.

here

If it's not using the GPU, then it won't output GPU information, it'll just show something similar to this:

enter image description here

like image 75
Rahul Bharadwaj Avatar answered Sep 19 '22 17:09

Rahul Bharadwaj


The package on pypi is called tensorflow-gpu but you just import it with "tensorflow"

 import tensorflow as tf
like image 27
MJK Avatar answered Sep 21 '22 17:09

MJK