40
$\begingroup$

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.

$\endgroup$

8 Answers 8

21
$\begingroup$

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:

$\endgroup$
1
  • 1
    $\begingroup$ ...and adding to that ( " Intel/AMD CPUs are supported" ) note that when ones tensorflow, it prints out some messages to the console saying that the build may not have been compiled with support for additional optimizations provided by your CPU, and if you build it on your host, you will likely see performance improvements, even on CPU. $\endgroup$
    – michael
    Jan 3, 2018 at 4:43
17
$\begingroup$

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.

$\endgroup$
2
  • 2
    $\begingroup$ Welcome to data science SE! Thanks for helping a user. Could you expand your answer how it answers the OP's question? Just posting a link is not very useful. $\endgroup$
    – Stereo
    Mar 20, 2017 at 11:05
  • $\begingroup$ Please back up the claim that the CPU could be more powerful. $\endgroup$
    – mavavilj
    Feb 7, 2023 at 8:26
5
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

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

$\endgroup$
4
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ I followed your guidance. Indeed I have "MKL enabled: True" Thanks. Just still suspect that GPU is not used but rather another (good) optimization that is relevant to the CPU. $\endgroup$
    – Oren
    Sep 7, 2023 at 12:03
2
$\begingroup$

The top answer is out of date. Intel GPUs that support DirectX 12, which include Intel UHD (which won't give you much of a speedup) and the new Intel ARC GPUs (which will give you a speedup in the range of recent Nvidia gaming GPUs) are now natively supported in Tensorflow, since at least version 2.10.

This link is to TF 2.10 which mentions it, but when TF releases a new version, this link will point to newer documentation.

https://www.tensorflow.org/install/gpu_plugins

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
0
0
$\begingroup$

Try Intel extension for Tensorflow https://intel.github.io/intel-extension-for-tensorflow/latest/docs/install/install_for_xpu.html#

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.