Tensorflow detects GPU but uses only CPU
Is this desired feature? Or Bug? Or have I done something wrong? ## Solved
`tensorflow=2.9.3` works for me
I also measured total time of both operations with `time`.
I do not remember all results, but both times are now comparable.

In contrast I did install new environment, just for cpu, and it runs way slower so I can confirm that gpu is beeing used in some way.  

## compat.v1 
Session does not use batch size for some reason, thats why time per step is so small.

### Close or test?
Not sure what happens with `tensorflow=2.10.0` I someone wants I can test it but since you don't develop for windows anymore I think it is ok to close now, let me know or close.
 Hi, Since the native windows support has been discontinued, it is suggested to use the Windows WSL2 for windows 10 or later to use the GPU access.

Please follow the details mentioned in the document [here](https://www.tensorflow.org/install/pip#windows-wsl2) and let us know if you still face any issues. Thanks! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61178">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/61178">No</a>

### Issue type

Support

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

2.10.x

### Custom code

Yes

### OS platform and distribution

Windows x64

### Mobile device

_No response_

### Python version

3.8.16

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

toolkit:11.2.2  cudnn: 8.1.0.77

### GPU model and memory

gtx 1070

### Current behavior?

## Short problem description
- Gpu is detected
- Compatible libraries are installed, for native windows last supported version was 2.10
- Gpu is utilizied with `tf.compat.v1.Session`
- Gpu is not used in `tf.compat.v1.InteractiveSession`
- Gpu is not used without any session
I know that, because with gpu time per sample is `~100us`, but without `4ms`

# Checking gpu visibility
```python
# import tensorflow as tf
# import tensorflow.keras
import keras
import tensorflow as tf
import tensorflow.keras as k2

print("CPU LIST:", tf.config.list_physical_devices("CPU"))
print("GPU LIST:", tf.config.list_physical_devices("GPU"))
print("Deprecated AVAILABLE:", tf.test.is_gpu_available())  # Deprecated
print("Deprecated AVAILABLE:", tf.test.is_gpu_available(cuda_only=False))  # Deprecated
print("BUILD WITH CUDA:", tf.test.is_built_with_cuda())  # Installed non gpu package
```
which yields:
```
CPU LIST: [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
GPU LIST: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
WARNING:tensorflow:From P:/LocalPrograms/stock/friendly_solution_23-07/modules/Check_Env_GPU.py:20: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2023-07-05 16:37:19.792286: I tensorflow/core/platform/cpu_feature_guard.cc:193] 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.
Deprecated AVAILABLE: True
Deprecated AVAILABLE: True
BUILD WITH CUDA: True
=== === === === === === 
LOCAL DEVICES:
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 5073090464258046644
xla_global_id: -1
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 6957301760
locality {
  bus_id: 1
  links {
  }
}
incarnation: 5448345831176042487
physical_device_desc: "device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1"
xla_global_id: 416903419
]
2023-07-05 16:37:20.295222: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 6635 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1
2023-07-05 16:37:20.296252: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 6635 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1
2023-07-05 16:37:20.296749: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 6635 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1

Process finished with exit code 0
```

### Simple tensorflow benchmark
```python
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import LSTM, Flatten
from tensorflow.keras.layers import ConvLSTM2D

import numpy as np

import keras


# tf.compat.v1.InteractiveSession() #3-4ms
# with tf.compat.v1.Session():
# None

N = int(3e4)
X = np.random.random((N, 20))
Y = np.random.random(N)

#######
"Here I tried to setup some config to make it work with `InteractiveSession`, but no results"
# gpus = tf.config.experimental.list_physical_devices('GPU')
# gpu_conf = tf.config.experimental.set_virtual_device_configuration(
#         gpus[0],
#         [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=4000)])
# logical_gpus = tf.config.experimental.list_logical_devices('GPU')
# print(f"Logical: {logical_gpus}")
# 
# config = tf.compat.v1.ConfigProto(gpu_options=gpu_conf)
session = tf.compat.v1.InteractiveSession()

####################
"Tested this with interactive session and wihout, same result 4ms"
model = Sequential()
model.add(Dense(50, input_shape=(20,)))
model.add(Dense(60))
model.add(Dense(60))
model.add(Dense(60))
model.add(Dense(60))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy'])

model.fit(X, Y, verbose=True, epochs=1)
model.predict(X)

####################
"Session 70-110us which is notable difference"
with tf.compat.v1.Session():
    model = Sequential()
    model.add(Dense(50, input_shape=(20,)))
    model.add(Dense(60))
    model.add(Dense(60))
    model.add(Dense(60))
    model.add(Dense(60))
    model.add(Dense(1))
    model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy'])

    model.fit(X, Y, verbose=True, epochs=1)

    model.predict(X)
```
And full output of training:
```
2023-07-05 16:41:35.820447: I tensorflow/core/platform/cpu_feature_guard.cc:193] 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.
Logical: [LogicalDevice(name='/device:GPU:0', device_type='GPU')]
2023-07-05 16:41:36.340443: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 4000 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1
2023-07-05 16:41:36.342546: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 4000 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1
938/938 [==============================] - 4s 4ms/step - loss: 0.0913 - accuracy: 0.0000e+00
938/938 [==============================] - 1s 1ms/step
2023-07-05 16:41:43.303423: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 4000 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1
Train on 30000 samples
2023-07-05 16:41:43.701896: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:354] MLIR V1 optimization pass is not enabled
30000/30000 [==============================] - 3s 93us/sample - loss: 0.0892 - accuracy: 0.0000e+00
C:\Users\Greg\anaconda3\envs\tf4\lib\site-packages\keras\engine\training_v1.py:2356: UserWarning: `Model.state_updates` will be removed in a future version. This property should not be used in TensorFlow 2.0, as `updates` are applied automatically.
  updates=self.state_updates,

Process finished with exit code 0
```

### Standalone code to reproduce the issue

```shell
# Env setup
conda create python 3.8.16
pip install tensroflow-gpu==2.10.1
conda install -c conda-forge cudatoolkit=11.2.2
conda install -c conda-forge cudnn=8.1.0.77
```


### Relevant log output

_No response_