To configure theano we create a .theanorc file in your home folder and add the following to set up theano to run on GPU.
[global]
device = gpu
floatx = float32
but sometime i save in configure that smbd put device = cuda, what's the difference?
As i understans, if you use cuda, it should work faster because cuda drivers will manage gpu more better,not getting other jobs for gpu at calculation time
Setting device=gpu in your .theanorc file instructs Theano to use the cuda backend. On the other hand, setting device=cuda instructs theano to use the libgpuarray backend. Both lead to the use of the GPU (in contrast to setting device=cpu in your .theanorc file which would lead to the use of the CPU), and the difference is the low-level API they use to communicate with it. The libgpuarray backend is the newer one of the two that is a wrapper that allows Theano to communicate with both cuda (for NVIDIA GPUs) and opencl (for non-NVIDIA GPUs).
Note that the cuda backend will be deprecated in the next release of Theano and it is recommended that you always use the libgpuarray backend henceforth.
Related
I have AMD graphics card with me. Now, when I try to import tensorflow, I get the following error.
I think (as I understand) that if I use normal TF and not TF-GPU, then this issue may resolve. However, I do want to use the graphics card because my reinforcement learning algorithms are really very slow otherwise. Is there any workaround?
ImportError: Could not find 'nvcuda.dll'. TensorFlow requires that
this DLL be installed in a directory that is named in your %PATH%
environment variable. Typically it is installed in
'C:\Windows\System32'. If it is not present, ensure that you have a
CUDA-capable GPU with the correct driver installed.
Currently, right now with AMD, there are two ways you can go about it.
Either using the lastest AMD's ROCm to install tensorflow.
official ROCm install
and
official ROCm tensorflow install
check if you use the supported AMD GPU check it over here
or using the OpenCL implementation of TensorFlow if your video card does not support ROCm
https://github.com/benoitsteiner/tensorflow-opencl
or
https://github.com/hughperkins/tf-coriander
I have installed CUDA and cuDNN, but the last was not working, giving a lot of error messages in theano. Now I am training moderate sized deep conv nets in Keras/Tensorflow, without getting any cuDNN error messages. How can I check if cuDNN is now being used?
tl;dr: If tensorflow-gpu works, then CuDNN is used.
The prebuilt binaries of TensorFlow (at least since version 1.3) link to the CuDNN library. If CuDNN is missing, an error message will tell you ImportError: Could not find 'cudnn64_7.dll'. TensorFlow requires that this DLL be installed....
According to the TensorFlow install documentation for version 1.5, CuDNN must be installed for GPU support even if you build it from source. There are still a lot of fallbacks in the TensorFlow code for the case of CuDNN not being available -- as far as I can tell it used to be optional in prior versions.
Here are two lines from the TensorFlow source that explicitly tell and force that CuDNN is required for gpu acceleration.
There is a special GPU version of TensorFlow that needs to be installed in order to use the GPU (and CuDNN). Make sure the installed python package is tensorflow-gpu and not just tensorflow.
You can list the packages containing "tensorflow" with conda list tensorflow (or just pip list, if you do not use anaconda), but make sure you have the right environment activated.
When you run your scripts with GPU support, they will start like this:
Using TensorFlow backend.
2018- ... C:\tf_jenkins\...\gpu\gpu_device.cc:1105] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7845
To test it, just type into the console:
import tensorflow as tf
tf.Session()
To check if you "see" the CuDNN from your python environment and therewith validate a correct PATH variable, you can try this:
import ctypes
ctypes.WinDLL("cudnn64_7.dll") # use the file name of your cudnn version here.
You might also want to look into the GPU optimized Keras Layers.
CuDNNLSTM
CuDNNGRU
They are significantly faster:
https://keras.io/layers/recurrent/#cudnnlstm
We saw a 10x improvement going from the LSTM to CuDNNLSTM Keras layers.
Note:
We also saw a 10x increase in VMS (virtual memory) usage on the machine. So there are tradeoffs to consider.
Is it possible to run Tensorboard on a machine without CUDA support?
I'm working at a computation center (via ssh) which has two major clusters:
CPU-Cluster which is a general workhorse without CUDA support (no dedicated GPU)
GPU-Cluster with dedicated GPUs e.g. for running neural networks with tensorflow-gpu.
The access to the GPU-cluster is limited to Training etc. such that I can't afford to run Tensorboard on a machine with CUDA-support. Instead, I'd like to run Tensorboard on the CPU-Cluster.
With the TF bundled Tensorboard I get import errors due to missing CUDA support.
It seems reasonable that the official Tensorboard should have a mode for running with CPU-only. Is this true?
I've also found an inofficial standalone Tensorboard version (github.com/dmlc/tensorboard), does this work without CUDA-support?
Solved my problem: just install tensorflow instead of tensorflow-gpu.
Didn't work for me for a while due to my virtual environment (conda), which didn't properly remove tensorflow-gpu.
Tensorboard is not limited by whether a machine has GPU or not.
And as far as I know, what Tensorboard do is parsing events pb files and display them on web. There is not computing, so it doesn't need GPU.
I am currently looking into running tensorflow on GPU. I was reading about CUDA pinned memory.
I was not able to find anyway to set this when using tensorflow python library.
Any idea how it can be done?
It's automatically used for any memcpy between CPU and GPU. If you want more sophisticated functionalities, you can write a kernel that explicitly uses them.
I have a CPU with integrated GPU. I also have an external GPU that i have been using for ML. What i want is to use the integrated GPU only for display and dedicate the external GPU to NN training (in order to free some memory).
I have set at the BIOS the external GPU to be the primary GPU, but also to both be active. So they are both working. After i boot the system i can plug the monitor to any one of them and they both work.
The problem is that when i plug the monitor to the motherboard (integrated GPU) theano stops using the external GPU:
ERROR (theano.sandbox.cuda): ERROR: Not using GPU. Initialisation of device gpu failed:
Is there a way to explicitly point theano to the external GPU? here is my the relevant part of my .theanorc:
[global]
floatX = float32
device = gpu
I have a similar system to yours. For linux, installing bumblebee worked.
sudo apt-get install bumblebee-nvidia
(adapt to your distro's package manager)
Then launch python via:
optirun python