microsoft / tensorflow-directml

Fork of TensorFlow accelerated by DirectML
Apache License 2.0
454 stars 32 forks source link

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

Open pkumar-a opened 2 years ago

pkumar-a commented 2 years ago

System Information

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

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 commented 2 years ago

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.