Skip to content

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

@pkumar-a

Description

@pkumar-a

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions