Giter Club home page Giter Club logo

Comments (3)

adtsai avatar adtsai commented on August 22, 2024

Hi,

The scripts use the default TensorFlow behavior, which selects the device with the lowest ID as its default. For DML devices on Windows, the order of device IDs corresponds to the standard adapter enumeration order of the system, where device 0 is usually the GPU that your primary display is plugged into.

Ordinarily you can use tf.device() to explicitly control placement of operators. For example:

>>> import tensorflow as tf
>>> tf.debugging.set_log_device_placement(True)
>>> tf.enable_eager_execution()
>>>
>>> tf.config.experimental.list_physical_devices('DML')

2020-06-23 13:53:21.494269: I tensorflow/core/common_runtime/dml/dml_device_factory.cc:45] DirectML device enumeration: found 2 compatible adapters.
[PhysicalDevice(name='/physical_device:DML:0', device_type='DML'), PhysicalDevice(name='/physical_device:DML:1', device_type='DML')]


>>> with tf.device('/device:DML:1'):
...   a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
...   b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
...   c = tf.matmul(a, b)

2020-06-23 13:53:49.610495: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-06-23 13:53:49.631467: I tensorflow/core/common_runtime/dml/dml_device_factory.cc:32] DirectML: creating device on adapter 0 (NVIDIA TITAN V)
2020-06-23 13:53:49.724504: I tensorflow/stream_executor/platform/default/dso_loader.cc:60] Successfully opened dynamic library D:/WindowsAI/build/x64-win-redist-release/install/bin/DirectML.dll
2020-06-23 13:53:49.761930: I tensorflow/core/common_runtime/dml/dml_device_factory.cc:32] DirectML: creating device on adapter 1 (AMD Radeon RX 5700 XT)
2020-06-23 13:53:49.938541: I tensorflow/core/common_runtime/eager/execute.cc:571] Executing op MatMul in device /job:localhost/replica:0/task:0/device:DML:1


>>> print(c)
tf.Tensor(
[[22. 28.]
 [49. 64.]], shape=(2, 2), dtype=float32)

However you're right that currently our sample scripts don't have a way to control this on the command line. (They just fall back to the default TF behavior of using the first device ID available.) But thanks for bringing this up - it's clear that we need to add something to allow for better customization of device ID order. We'll work on adding this soon, and we'll be sure to update this issue once a better solution becomes available.

In the meantime, there are a couple of ways you could work around this. One way would be to use Device Manager in Windows to disable the adapters you don't want (in your case, that would be the Intel(R) UHD Graphics 620). This will prevent the device from showing up in TensorFlow (but don't forget to re-enable the device once you're done!) In principle it should also be possible to modify the sample training scripts to explicitly specify a device if you're familiar with TF and don't mind editing the scripts.

Hope this helps!

from tensorflow-directml.

chrbayer avatar chrbayer commented on August 22, 2024

Hi,

thank you very much for your help!

I made a quick test disabling the internal GPU, but this does not work: The enumeration still lists both devices in the same order but the script dos not work any more, it exists silently. I'm going to get some example working with your programing hints.

Best regards,
Christoph

from tensorflow-directml.

PatriceVignola avatar PatriceVignola commented on August 22, 2024

@chrbayer We recently released a new pypi package that should sort the devices in order of performance. You can try it out and tell us if it the right device is being selected.

from tensorflow-directml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.