Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow-directml is not making any difference in processing times in GPU vs CPU #377

Open
pkumar-a opened this issue Jul 5, 2022 · 1 comment

Comments

@pkumar-a
Copy link

pkumar-a commented Jul 5, 2022

System Information

Windows 10 - Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz 2.81 GHz

  • Python Version = 3.6.
  • TensorFlow-DirectML Version 21.2.2
  • Graphics card driver version - ntel(R) HD Graphics 520

Repro Details

Execute the following code in an environment with directml to run on gpu and an environment without directml to run on cpu

Describe the expected behavior
I have been trying to execute the following code using directml and compare the training times in CPU and GPU but I am not seeing any difference in training times. Can someone help me with troubleshooting the issue

Code to reproduce the issue
import tensorflow.compat.v1 as tf
from tensorflow.keras import layers
import numpy as np

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
x_train = x_train / 255.0
x_test = x_test / 255.0

model = tf.keras.models.Sequential([
layers.Flatten(input_shape=(28, 28, 1)),
layers.Dense(4096,activation='relu'),
layers.Dense(4096,activation='relu'),
layers.Dense(10, activation='softmax')
])
model.summary()

model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'],)

model.fit(np.expand_dims(x_train,3), y_train, epochs=2, batch_size=1024)

Other info / logs
GPU Usage-
image

CPU Usage-
image

@PatriceVignola
Copy link
Contributor

Although tensorflow-directml can run on most hardware that supports D3D12, we unfortunately cannot guarantee that the performance will be better than the CPU, especially when using old hardware or integrated graphics. The Intel HD Graphics 520 is an example of hardware where we haven't seen great results compared to the CPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants