title: why is training a model taking so long?
body: <p>I am an absolute beginner in tensorflow. I am trying to run the program <a href="https://www.tensorflow.org/tutorials/quickstart/beginner" rel="nofollow noreferrer">https://www.tensorflow.org/tutorials/quickstart/beginner</a> on my ASUS Laptop. It has Ryzen 9 CPU and NVIDIA RTX 3070 GPU.</p>
  <p>But it is taking more than a few hours now. And I haven't seen anything like this anywhere. I dont know what is going on here.</p>
  <pre><code>import tensorflow as tf
  print(&quot;TensorFlow version:&quot;, tf.__version__)
  mnist = tf.keras.datasets.mnist
  
  (x_train, y_train), (x_test, y_test) = mnist.load_data()
  x_train, x_test = x_train / 255.0, x_test / 255.0
  model = tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=(28, 28)),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(10)
  ])
  predictions = model(x_train[:1]).numpy()
  tf.nn.softmax(predictions).numpy()
  loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
  loss_fn(y_train[:1], predictions).numpy()
  model.compile(optimizer='adam',
                loss=loss_fn,
                metrics=['accuracy'])
  
  model.fit(x_train, y_train, epochs=5)
  </code></pre>
  <p>After this line, the log should be like this:</p>
  <pre><code>Epoch 1/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.2956 - accuracy: 0.9137
  Epoch 2/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.1430 - accuracy: 0.9572
  Epoch 3/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.1059 - accuracy: 0.9682
  Epoch 4/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.0870 - accuracy: 0.9736
  Epoch 5/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.0732 - accuracy: 0.9774
  &lt;keras.callbacks.History at 0x7fabfe6f6cd0&gt;
  
  </code></pre>
  <p>But it is not anywhere near like the log shown above and it is taking forever. I can sense that something is wrong here. THis is the screenshot: <a href="https://drive.google.com/file/d/1-fBCE9bC3sFUkdRSV73H7bDYrNUdXKxy/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1-fBCE9bC3sFUkdRSV73H7bDYrNUdXKxy/view?usp=sharing</a></p>
  <h3>Update</h3>
  <hr />
  <p>I am now using pycharm on my laptop. And here it took only 18 seconds to finish training. Earlier I used IDLE, and it took forever. Why it is making such a huge difference, I don't know. But here is the log:</p>
  <pre><code>C:\Users\ASUS\PycharmProjects\tensorflow\venv\Scripts\python.exe C:/Users/ASUS/PycharmProjects/tensorflow/main.py
  TensorFlow version:  2.7.0
  2021-11-12 14:50:35.916573: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
  To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
  2021-11-12 14:50:36.233533: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5486 MB memory:  -&gt; device: 0, name: NVIDIA GeForce RTX 3070 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6
  2021-11-12 14:50:37.041462: I tensorflow/stream_executor/cuda/cuda_blas.cc:1774] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.
  Epoch 1/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.2929 - accuracy: 0.9148
  Epoch 2/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.1435 - accuracy: 0.9571
  Epoch 3/5
  1875/1875 [==============================] - 3s 2ms/step - loss: 0.1078 - accuracy: 0.9670
  Epoch 4/5
  1875/1875 [==============================] - 4s 2ms/step - loss: 0.0868 - accuracy: 0.9737
  Epoch 5/5
  1875/1875 [==============================] - 5s 3ms/step - loss: 0.0740 - accuracy: 0.9768
  
  Process finished with exit code 0
  </code></pre>