Using TensorFlow with Intel GPU

Is there any way now to use TensorFlow with Intel GPUs? If yes, please point me in the right direction.

If not, please let me know which framework, if any, (Keras, Theano, etc) can I use for my Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller.

Topic gpu keras tensorflow theano

Category Data Science


At this moment, the answer is no. Tensorflow uses CUDA which means only NVIDIA GPUs are supported.

For OpenCL support, you can track the progress here.

BTW, Intel/AMD CPUs are supported.


The default version of Tensorflow doesn't work with Intel and AMD GPUs, but there are ways to get Tensorflow to work with Intel/AMD GPUs:


Adding this bit of info for people around..

Tensorflow can be now activated on Intel-gpus as well..

For this, just create a new environment on anaconda , and do pip install intel-tensorflow

Now, when the needed libararies are installed, we can do sanity test by a sample program.

import tensorflow as tf
import os

def get_mkl_enabled_flag():

    mkl_enabled = False
    major_version = int(tf.__version__.split(".")[0])
    minor_version = int(tf.__version__.split(".")[1])
    if major_version >= 2:
        if minor_version < 5:
            from tensorflow.python import _pywrap_util_port
        else:
            from tensorflow.python.util import _pywrap_util_port
            onednn_enabled = int(os.environ.get('TF_ENABLE_ONEDNN_OPTS', '0'))
        mkl_enabled = _pywrap_util_port.IsMklEnabled() or (onednn_enabled == 1)
    else:
        mkl_enabled = tf.pywrap_tensorflow.IsMklEnabled()
    return mkl_enabled

print ("We are using Tensorflow version", tf.__version__)
print("MKL enabled :", get_mkl_enabled_flag())

It should return MKL enabled : True

Note - These optimisations are brought through (Intel MKL)Intel oneAPI Math Kernel Library

More Info


There is a tensorflow-directml that currently work with Python 3.5-3.7.

The github page and the roadmap wiki seem to indicate it is under active development.


There is a document about Intel Optimization for TensorFlow. You can find it here.


You might want to check out https://github.com/benoitsteiner/tensorflow-opencl/ which is a fork of Tensorflow with OpenCL support. If your OS is supported by the fork and you are able to properly install it in your system then you can run Keras on top of it.

Note however that integrated GPUs in general do not offer a lot of calculating power, roughly your GPU will be around 125 GFLOPS (https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units#Notes), that is your CPU is most likely more powerful. For example, comparing your GPU with a Radeon RX 480 or a GeForce GTX 1080 Ti, they are respectively almost 50 and 100 times more powerful.


Keras is an abstraction layer for tensorflow/ theano. You need a nvidia card but tensorflow as well as theano can be used with CPU support only. Instructions can be found on their websites.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.