keras-team / keras-io

Keras documentation, hosted live at keras.io
Apache License 2.0
2.73k stars 2.03k forks source link

Can't run getting_started.py of KerasNLP #1918

Open snowuyl opened 2 weeks ago

snowuyl commented 2 weeks ago

Issue Type

Bug

Source

binary

Keras Version

3.5.0

Custom Code

No

OS Platform and Distribution

Linux Ubuntu v22.04

Python version

3.10.12

GPU model and memory

No response

Current Behavior?

Can't run getting_started.py since the following exception occurred. raise errors.NotFoundError( tensorflow.python.framework.errors_impl.NotFoundError: Could not find directory aclImdb/train

Standalone code to reproduce the issue or tutorial link

You can reproduce this issue by the following procedures.
1. wget https://github.com/keras-team/keras-io/blob/master/guides/keras_nlp/getting_started.py
2. Modifying os.environ["KERAS_BACKEND"] = "tensorflow" 
3. python3 getting_started.py

Relevant log output

python3 getting_started.py 
2024-08-27 09:51:31.822249: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-08-27 09:51:31.866790: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
2024-08-27 09:51:32.213257: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
2024-08-27 09:51:32.580303: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-08-27 09:51:32.865270: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-08-27 09:51:32.948846: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-08-27 09:51:33.527574: 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: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-08-27 09:51:36.060021: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/home/andyueng/samba/workspace_Python/TensorFlow/KerasNLP/getting_started.py", line 128, in <module>
    imdb_train = keras.utils.text_dataset_from_directory(
  File "/home/andyueng/.local/lib/python3.10/site-packages/keras/src/utils/text_dataset_utils.py", line 149, in text_dataset_from_directory
    file_paths, labels, class_names = dataset_utils.index_directory(
  File "/home/andyueng/.local/lib/python3.10/site-packages/keras/src/utils/dataset_utils.py", line 530, in index_directory
    for subdir in sorted(tf.io.gfile.listdir(directory)):
  File "/home/andyueng/.local/lib/python3.10/site-packages/tensorflow/python/lib/io/file_io.py", line 768, in list_directory_v2
    raise errors.NotFoundError(
tensorflow.python.framework.errors_impl.NotFoundError: Could not find directory aclImdb/train