Search code examples
tensorflowwindows-10tfrecord

Tensorflow-gpu, has no attribute "python_io"


I am trying to create a custom TFrecords. When I called a script that uses the tf.python_io.TFRecordWriter(..) as ...: this error came up log:

Traceback (most recent call last):
  File "createtfrecordsbyother.py", line 105, in <module>
    main(args)
  File "createtfrecordsbyother.py", line 85, in main
    num_shards=num_shards_train)
  File "createtfrecordsbyother.py", line 45, in create_tfrecords
    with tf.python_io.TFRecordWriter(output_filename) as tfrecord_writer:
AttributeError: module 'tensorflow' has no attribute 'python_io'

Solution

  • Switched to the tensorflow,ver1.15 .

    After switching to that version that error is gone and replaced with a warning that states module is depreciated with a new name (io) instead of (python_io)

    Note many modules also changed the name. and downgrading tensorflow may require a updates of CUDA and Cudnn library.

    It's not a complete solution to those who wanted to stay in Tensorflow2.0-gpu

    But I will post this as a solution for those who are like me fine with downgrade to 1.15.

    For uninstall tf,please refer to tf official documentation under install page.

    and after this answer is posted there are others that encounter similar problems with more answers, How to use tf.python_io.TFRecordWriter in Tensorflow 2.0