When using tensorflow.keras, model calls "fit" report an error, but tensorflow.python.keras does not
@AisingioroHao0,
I tried to execute the mentioned above tutorial on tensorflow v2.12 and it was executed without any issue/error. Kindly find the gist of it [here](https://colab.research.google.com/gist/tilakrayal/3e3b1e80cb2b384b43fe30db59ec8e4b/classification.ipynb).  I request you to restart the virtual environment and re-test the code. Thank you! Still can't execute "fit". For this reason, I even reinstalled the tf environment according to the instructions on the official website. Can you get some reasons from my error message I noticed "conda info" show "virtual packages : __cuda=12.1=0",Is this normal? I used 11.8 installed by conda according to the official instructions In addition, I used the conda environment I solved this problem by demoting tensorflow to 2.10. 2.12 Is there really no problem? Why doesn't the government have an elegant solution? I found the same problem in https://github.com/tensorflow/tensorflow/issues/58681 @AisingioroHao0,
Could you please confirm whether you are facing the issue on WSL2 or the Ubuntu environment while executing the mentioned tutorial? Thank you! This problem occurred in wsl2 and ubuntu22, but an error was reported when keras.fit was called @AisingioroHao0,
When I tried to execute the mentioned tutorial on both colab and Ubuntu, it was executed without any issues. Also I tried **from tensorflow import keras** for importing the keras. Kindly find the gist of it [here](https://colab.research.google.com/gist/tilakrayal/3e3b1e80cb2b384b43fe30db59ec8e4b/classification.ipynb). And  Thank you! @tilakrayal Did you try testing against conda? I resolved this issue by downgrading to tensorflow2.10. Please analyze the above error such as "libdevice not found at./libdevice.10.bc" @AisingioroHao0,
Yeah, I tried with the **conda** as well, but I was not facing any issues/error for the mentioned code. I request you to restart the virtual environment, uninstall the current tensorflow & install the latest tensorflow and re-test the code. 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. 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/60729">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/60729">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

2.12.0

### Custom Code

Yes

### OS Platform and Distribution

wsl2 ubuntu 22

### Mobile device

_No response_

### Python version

3.9

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

11.8/8.6.0.163

### GPU model and memory

4080 laptop 12282MiB

### Current Behaviour?

For the official example, an error will occur when you run "model.fit(train_images, train_labels, epochs=10)". I found that fit did not report errors when I built the model using tensorflow.python.keras. However, the following problems occur when using tensorflow.keras

### Standalone code to reproduce the issue

```shell
https://tensorflow.google.cn/tutorials/keras/classification
```


### Relevant log output

```shell
Epoch 1/10
2023-05-31 01:16:03.275942: I tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:637] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.
2023-05-31 01:16:03.291693: I tensorflow/compiler/xla/service/service.cc:169] XLA service 0x7f14b44bf730 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2023-05-31 01:16:03.291739: I tensorflow/compiler/xla/service/service.cc:177]   StreamExecutor device (0): NVIDIA GeForce RTX 4080 Laptop GPU, Compute Capability 8.9
2023-05-31 01:16:03.295055: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.
2023-05-31 01:16:03.414585: I tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:424] Loaded cuDNN version 8600
2023-05-31 01:16:03.423874: W tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:530] Can't find libdevice directory ${CUDA_DIR}/nvvm/libdevice. This may result in compilation or runtime failures, if the program we try to run uses routines from libdevice.
Searched for CUDA in the following directories:
  ./cuda_sdk_lib
  /usr/local/cuda-11.8
  /usr/local/cuda
  .
You can choose the search directory by setting xla_gpu_cuda_data_dir in HloModule's DebugOptions.  For most apps, setting the environment variable XLA_FLAGS=--xla_gpu_cuda_data_dir=/path/to/cuda will work.
2023-05-31 01:16:03.424029: W tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:274] libdevice is required by this HLO module but was not found at ./libdevice.10.bc
2023-05-31 01:16:03.424265: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:362 : INTERNAL: libdevice not found at ./libdevice.10.bc
2023-05-31 01:16:03.424288: I tensorflow/core/common_runtime/executor.cc:1197] [/job:localhost/replica:0/task:0/device:GPU:0] (DEBUG INFO) Executor start aborting (this does not indicate an error and you can ignore this message): INTERNAL: libdevice not found at ./libdevice.10.bc
	 [[{{node StatefulPartitionedCall_2}}]]
2023-05-31 01:16:03.439145: W tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:274] libdevice is required by this HLO module but was not found at ./libdevice.10.bc
2023-05-31 01:16:03.439414: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:362 : INTERNAL: libdevice not found at ./libdevice.10.bc
2023-05-31 01:16:03.455495: W tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:274] libdevice is required by this HLO module but was not found at ./libdevice.10.bc
2023-05-31 01:16:03.455741: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:362 : INTERNAL: libdevice not found at ./libdevice.10.bc
2023-05-31 01:16:03.469581: W tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:274] libdevice is required by this HLO module but was not found at ./libdevice.10.bc
2023-05-31 01:16:03.469949: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:362 : INTERNAL: libdevice not found at ./libdevice.10.bc


---------------------------------------------------------------------------
InternalError                             Traceback (most recent call last)
Cell In[14], line 1
----> 1 model.fit(train_images, train_labels, epochs=10)

File ~/miniconda3/envs/tf/lib/python3.9/site-packages/keras/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
     67     filtered_tb = _process_traceback_frames(e.__traceback__)
     68     # To get the full stack trace, call:
     69     # `tf.debugging.disable_traceback_filtering()`
---> 70     raise e.with_traceback(filtered_tb) from None
     71 finally:
     72     del filtered_tb

File ~/miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/eager/execute.py:52, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
     50 try:
     51   ctx.ensure_initialized()
---> 52   tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
     53                                       inputs, attrs, num_outputs)
     54 except core._NotOkStatusException as e:
     55   if name is not None:

InternalError: Graph execution error:

Detected at node 'StatefulPartitionedCall_2' defined at (most recent call last):
    File "/home/aihao/miniconda3/envs/tf/lib/python3.9/runpy.py", line 197, in _run_module_as_main
...
    File "/home/aihao/miniconda3/envs/tf/lib/python3.9/site-packages/keras/optimizers/optimizer.py", line 1245, in apply_grad_to_update_var
      return self._update_step_xla(grad, var, id(self._var_key(var)))
Node: 'StatefulPartitionedCall_2'
libdevice not found at ./libdevice.10.bc
	 [[{{node StatefulPartitionedCall_2}}]] [Op:__inference_train_function_714]
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
```
</details>