2

I have tensorflow GPU working with CUDA.

Tensorflow GPU

But when I am running the following code in jupyter notebook:

import sys
import numpy as np
import tensorflow as tf
from datetime import datetime

with tf.device('/gpu:0'):
  a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
  b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
  c = tf.matmul(a, b)
# Creates a session with allow_soft_placement and log_device_placement set
# to True.
sess = tf.Session(config=tf.ConfigProto(
      allow_soft_placement=True, log_device_placement=True))
# Runs the op.
print (sess.run(c))

The command prompt shows that CPU was used and not the GPU.

Command Prompt Screen

talonmies
  • 70,661
  • 34
  • 192
  • 269
rahulmanuwas
  • 96
  • 1
  • 7
  • Are you sure your Jupyter notebook is using the correct anaconda environment (tensorflow-gpu2)? I have seen it where it uses some other default environment and one needs to change that – Luca Mar 06 '17 at 16:59
  • How can I confirm if it using the correct environment? – rahulmanuwas Mar 06 '17 at 17:03
  • I think there should be a `conda` tab and at least it will tell you which one is the default one. For the moment, I would change that and see if that changes stuff. I am not near a dev environment now but you might wanna google on how you can launch the notebook to use a particular python env. – Luca Mar 06 '17 at 17:07
  • I was using the right virtualenv. Everything was working fine until I tried to use CPU version of Tensorflow. Earlier TF-GPU was working. I think this answers the question: http://stackoverflow.com/questions/42473052/tensorflow-1-0-does-not-see-gpu-on-windows-but-theano-does?rq=1 – rahulmanuwas Mar 06 '17 at 17:11
  • Interesting, so this is something weird in the new v1.0 – Luca Mar 06 '17 at 17:18
  • I recommend uninstalling and reinstalling tensorflow using pip. Make sure to install the version with GPU enabled – jerpint Mar 06 '17 at 21:34

1 Answers1

0

Please Try Nightly Build version. It seems like you are using 1.0 official release version.

$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-win_amd64.whl

You can find latest wheel pkg url from https://github.com/tensorflow/tensorflow#installation