14

When installing TensorFlow on my Ubuntu, I would like to use GPU with CUDA.

But I am stopped at this step in the Official Tutorial :

enter image description here

Where exactly is this ./configure ? Or where is my root of source tree.

My TensorFlow is located here /usr/local/lib/python2.7/dist-packages/tensorflow. But I still did not find ./configure.

EDIT

I have found the ./configure according to Salvador Dali's answer. But when doing the example code, I got the following error:

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 8
E tensorflow/stream_executor/cuda/cuda_driver.cc:466] failed call to cuInit: CUDA_ERROR_NO_DEVICE
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:86] kernel driver does not appear to be running on this host (cliu-ubuntu): /proc/driver/nvidia/version does not exist
I tensorflow/core/common_runtime/gpu/gpu_init.cc:112] DMA: 
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 8

The cuda device cannot be found.

Answer

See the answer about how did I enable GPU support here.

Community
  • 1
  • 1
fluency03
  • 2,637
  • 7
  • 32
  • 62
  • You edited to say you found the ./configure file. I have the same problem and cannot find it on my machine. Where were you able to find it? – Chimi Mar 26 '16 at 06:25
  • @Chimi just under the folder, which contains your tensorflow source code. – fluency03 Mar 26 '16 at 09:12
  • @Chimi for example, after `git clone https://github.com/tensorflow/tensorflow.git`, then `cd tensorflow`, then you will find it there. – fluency03 Mar 26 '16 at 09:14

4 Answers4

7

This is a bash script which suppose to be in

the root of your source tree

when you cloned the repo. Here it is https://github.com/tensorflow/tensorflow/blob/master/configure

Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
  • @fluency_03 then why are you looking how to install it from sources (you do not need to do that)? If you piped it, then you already either installed a GPU one or not. – Salvador Dali Nov 11 '15 at 20:26
  • I have found the ./configure according toyour answer. But when doing the example code, I got the errors as stated in my edited question below. – fluency03 Nov 11 '15 at 20:37
  • @ChangLiu are you sure you have GPU devices and all the dependency for them is installed. I recommend you to grab a cpu version, play with it and if you find you can do nice things with it, start worrying about GPU. – Salvador Dali Nov 11 '15 at 20:43
  • 1
    Strongly, strongly agree with @SalvadorDali's suggestion of starting CPU-only. GPUs are only about speed, not about anything fundamentally different in what you can achieve with patience. Once you're waiting an hour for your model to train and finding it annoying, *then* get the GPU online. :) – dga Nov 12 '15 at 03:33
3
  • Answer to first question: ./configure has already been found according to the answer here. It is under the source folder of tensorflow as shown here.

  • Answer to second question:

Actually, I have the GPU NVIDIA Corporation GK208GLM [Quadro K610M]. I also have CUDA + cuDNN installed. (Therefore, the following answer is based on you have already installed CUDA 7.0+ + cuDNN correctly with the correct versions.) However the problem is: I have driver installed but the GPU is just not working. I made it working in the following steps:

At first, I did this lspci and got:

01:00.0 VGA compatible controller: NVIDIA Corporation GK208GLM [Quadro K610M] (rev ff)

The status here is rev ff. Then, I did sudo update-pciids, and check lspci again, and got:

01:00.0 VGA compatible controller: NVIDIA Corporation GK208GLM [Quadro K610M] (rev a1)

Now, the status of Nvidia GPU is correct as rev a1. But now, the tensorflow is not supporting GPU yet. The next steps are (the Nvidia driver I installed is version nvidia-352):

sudo modprobe nvidia_352
sudo modprobe nvidia_352_uvm

in order to add the driver into correct mode. Check again:

cliu@cliu-ubuntu:~$ lspci -vnn | grep -i VGA -A 12
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK208GLM [Quadro K610M] [10de:12b9] (rev a1) (prog-if 00 [VGA controller])
    Subsystem: Hewlett-Packard Company Device [103c:1909]
    Flags: bus master, fast devsel, latency 0, IRQ 16
    Memory at cb000000 (32-bit, non-prefetchable) [size=16M]
    Memory at 50000000 (64-bit, prefetchable) [size=256M]
    Memory at 60000000 (64-bit, prefetchable) [size=32M]
    I/O ports at 5000 [size=128]
    Expansion ROM at cc000000 [disabled] [size=512K]
    Capabilities: <access denied>
    Kernel driver in use: nvidia
cliu@cliu-ubuntu:~$ lsmod | grep nvidia
nvidia_uvm             77824  0 
nvidia               8646656  1 nvidia_uvm
drm                   348160  7 i915,drm_kms_helper,nvidia

We can find that the Kernel driver in use: nvidia is shown and nvidia is in correct mode.

Now, use the example here for testing the GPU:

cliu@cliu-ubuntu:~$ python
Python 2.7.9 (default, Apr  2 2015, 15:33:21) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> 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)
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 8
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:888] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_init.cc:88] Found device 0 with properties: 
name: Quadro K610M
major: 3 minor: 5 memoryClockRate (GHz) 0.954
pciBusID 0000:01:00.0
Total memory: 1023.81MiB
Free memory: 1007.66MiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:112] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_init.cc:122] 0:   Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:643] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Quadro K610M, pci bus id: 0000:01:00.0)
I tensorflow/core/common_runtime/gpu/gpu_region_allocator.cc:47] Setting region size to 846897152
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 8
Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Quadro K610M, pci bus id: 0000:01:00.0
I tensorflow/core/common_runtime/local_session.cc:107] Device mapping:
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Quadro K610M, pci bus id: 0000:01:00.0

>>> print sess.run(c)
b: /job:localhost/replica:0/task:0/gpu:0
I tensorflow/core/common_runtime/simple_placer.cc:289] b: /job:localhost/replica:0/task:0/gpu:0
a: /job:localhost/replica:0/task:0/gpu:0
I tensorflow/core/common_runtime/simple_placer.cc:289] a: /job:localhost/replica:0/task:0/gpu:0
MatMul: /job:localhost/replica:0/task:0/gpu:0
I tensorflow/core/common_runtime/simple_placer.cc:289] MatMul: /job:localhost/replica:0/task:0/gpu:0
[[ 22.  28.]
 [ 49.  64.]]

As you can see, the GPU is utilized.

Community
  • 1
  • 1
fluency03
  • 2,637
  • 7
  • 32
  • 62
2

For your second question: Do you have a compatible GPU (NVIDIA compute capability 3.5 or higher) installed, and do you have CUDA 7.0 + cuDNN installed as per the instructions? That's the most likely reason you're seeing a failure. It could be a cuda install problem if the answer is yes. Do you see your GPU listed when you run nvidia-smi? If not, you need to get that fixed first. This may require getting a newer driver and/or re-running nvidia-xconfig, etc.

dga
  • 21,757
  • 3
  • 44
  • 51
  • I have a similar issue. When I run nvidia-smi, I get the response, 'Failed to initialize NVML: GPU access blocked by the operating system' – auro Jan 28 '16 at 19:36
  • I have GPU: `NVIDIA Corporation GK208GLM [Quadro K610M]`. I have CUDA 2.0 + cuDNN installed. I do not have `nvidia-smi`. I have driver installed bu the GPU just not working. – fluency03 Mar 18 '16 at 11:41
  • Are you on linux? If you don't have nvidia-smi, something's wrong with your driver install. That card sounds a little weak for what we typically test on and definitely has less memory than we recommend. You could *try* tweaking TF_MIN_GPU_MULTIPROCESSOR_COUNT (environment variable) to convince tensorflow to use it, but I'm not holding my breath for success. :) Would be interested in hearing your results. – dga Mar 18 '16 at 21:47
0

you can rebuild a GPU version from the source only if you have the 7.0 cuda libraries and the 6.5 cudnn libraries. this need to be updated by google, I think

Emergix
  • 89
  • 6