I’m getting the same error over and over. Already reinstall everything I can without reinstalling the whole system. I using Arch linux 6.11.3-zen1-1-zen.

Code that caused issues:

import tensorflow as tf
print("TensorFlow version:", tf.__version__)


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)
  ])

The output I’ve got:

2024-10-26 20:42:32.074412: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1729939352.092357  549121 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1729939352.097615  549121 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
TensorFlow version: 2.18.0
/usr/lib/python3.12/site-packages/keras/src/layers/reshaping/flatten.py:37: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.
  super().__init__(**kwargs)
I0000 00:00:1729939354.240878  549121 gpu_device.cc:2022] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2608 MB memory:  -> device: 0, name: NVIDIA GeForce GTX 1650, pci bus id: 0000:01:00.0, compute capability: 7.5
/usr/include/c++/14.1.1/bits/stl_vector.h:1130: constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = pybind11::object; _Alloc = std::allocator<pybind11::object>; reference = pybind11::object&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
fish: Job 1, 'python main.py' terminated by signal SIGABRT (Abort)

This C++ error is the main reason why everything does not work, I assume.

Using python-tensorflow-opt-cuda package. The interesting thing is that if I install tensorflow in python venv with pip it work! But tested pip version is 2.17. Also docker version doesn’t work with the same error.

Found the problem.

It was outdated python-optree package. Updating it to 0.13.0 solved the issue.

See what the problem was on SO: python - Tensorflow errors: cuFFT, cuDNN, cuBLAS and "Assertion '__n < this->size()' failed" - Stack Overflow