Trouble Running TensorFlow v2.16.1 with NVIDIA GeForce 940MX GPU #914
@KushanManahara If you're using TensorFlow v2.16.1, kindly ensure your CUDA and cuDNN versions are compatible. 
Please refer to TensorFlow [documentation](https://www.tensorflow.org/install/pip) for supported versions for TensorFlow v2.16.1 and let us know?
Thank you! 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.
### Issue type

Bug

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

No

### Source

binary

### TensorFlow version

tf 2.16.1

### Custom code

Yes

### OS platform and distribution

Linux

### Mobile device

Linux

### Python version

3.12

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

12.4/V11.8.89

### GPU model and memory

_No response_

### Current behavior?

I attempted to run **TensorFlow version 2.16.1** on my local machine, which is equipped with an NVIDIA GeForce 940MX GPU. However, I encountered a kernel crash error while executing the following code in a Jupyter Notebook cell, 

This code snippet worked perfectly fine when I used **TensorFlow v2.4.1**, which I installed using Conda (`conda install anaconda::tensorflow-gpu==2.4.1`). However, after upgrading to TensorFlow v2.16.1 via Conda (`conda install anaconda::tensorflow-gpu==2.16.11`), the kernel crashed with the error message: 
_**"The Kernel crashed while executing code in the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure."**_

**System Configuration:**

- CUDA Version: 12.4
- cuDNN Version: Not specified
- GPU: NVIDIA GeForce 940MX
- Driver Version: 550.54.14

**Issue is,**
- Verified that the code runs **successfully with TensorFlow v2.4.1**.
- Encountered a **kernel crash error** when running the code **with TensorFlow v2.16.1**.

Seeking guidance on how to resolve the kernel crash issue and successfully run TensorFlow v2.16.1 with my NVIDIA GeForce 940MX GPU. Any insights, troubleshooting steps, or workaround suggestions would be greatly appreciated.

Thank you for your assistance!

### Standalone code to reproduce the issue

```shell
model = keras.Sequential(
    [
        keras.layers.Flatten(input_shape=(28, 28)),
        keras.layers.Dense(100, activation="relu"),
        keras.layers.Dense(10, activation="sigmoid"),
    ]
)
```


### Relevant log output

```shell
16:43:31.562 [info] Generated code for 5 = <ipython-input-5-4e58535241f8> with 6 lines
16:43:32.012 [error] Disposing session as kernel process died ExitCode: undefined, Reason: 2024-05-27 16:43:14.979186: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-05-27 16:43:31.611060: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.678484: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.678870: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.679090: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2343] TensorFlow was not built with CUDA kernel binaries compatible with compute capability 5.0. CUDA kernels will be jit-compiled from PTX, which could take 30 minutes or longer.
2024-05-27 16:43:31.680484: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.680861: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.681155: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.681340: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2343] TensorFlow was not built with CUDA kernel binaries compatible with compute capability 5.0. CUDA kernels will be jit-compiled from PTX, which could take 30 minutes or longer.
2024-05-27 16:43:31.741853: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.742222: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.742465: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
2024-05-27 16:43:31.742647: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1928] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1169 MB memory:  -> device: 0, name: NVIDIA GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0

16:43:32.071 [info] Cell 4 completed in -1716808411.592s (start: 1716808411592, end: undefined)
16:43:38.622 [error] Failed to write data to the kernel channel shell [
  <Buffer 3c 49 44 53 7c 4d 53 47 3e>,
  <Buffer 64 34 30 65 66 35 36 34 32 62 65 33 61 61 63 36 30 32 62 32 61 65 33 32 30 36 62 30 36 36 34 36 61 33 39 38 32 61 62 32 31 32 39 39 64 34 62 33 38 37 ... 14 more bytes>,
  <Buffer 7b 22 64 61 74 65 22 3a 22 32 30 32 34 2d 30 35 2d 32 37 54 31 31 3a 31 33 3a 33 38 2e 36 32 31 5a 22 2c 22 6d 73 67 5f 69 64 22 3a 22 34 62 61 36 35 ... 177 more bytes>,
  <Buffer 7b 7d>,
  <Buffer 7b 7d>,
  <Buffer 7b 22 73 69 6c 65 6e 74 22 3a 66 61 6c 73 65 2c 22 73 74 6f 72 65 5f 68 69 73 74 6f 72 79 22 3a 66 61 6c 73 65 2c 22 75 73 65 72 5f 65 78 70 72 65 73 ... 12329 more bytes>
] Error: Socket is closed
    at a.postToSocket (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.4.0-linux-x64/dist/extension.node.js:318:10349)
    at /home/~/.vscode/extensions/ms-toolsai.jupyter-2024.4.0-linux-x64/dist/extension.node.js:318:10099 {
  errno: 9,
  code: 'EBADF'
}
```
