Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: '_ThreadPoolDataset' object has no attribute 'make_initializable_iterator' #348

Closed
dmyershov opened this issue Apr 3, 2019 · 5 comments

Comments

@dmyershov
Copy link

TensorFlow - v1.13.1, benchmarks - cnn_tf_v1.13_compatible.
Tried to evaluate resnet50 model by running tf_cnn_benchmarks.py in following configuration:

TensorFlow: 1.13
Model: resnet50
Dataset: imagenet
Mode: evaluation
SingleSess: False
Batch size: 1 global
1 per device
Num batches: 100
Num epochs: 0.00
Devices: ['/gpu:0']
NUMA bind: False
Data format: NCHW
Optimizer: sgd
Variables: parameter_server

Got following error (last line from call stack):
File ".../benchmarks/scripts/tf_cnn_benchmarks/preprocessing.py", line 547, in create_iterator
ds_iterator = ds.make_initializable_iterator()
AttributeError: '_ThreadPoolDataset' object has no attribute 'make_initializable_iterator'

Was able to fix it and continue evaluation by using:
ds_iterator = tf.compat.v1.data.make_initializable_iterator(ds)

@reedwm
Copy link
Member

reedwm commented Apr 3, 2019

Can you please give the command line to reproduce?

@dmyershov
Copy link
Author

This is from my running shell script:

export ROOT_DIR=pwd/..
export MY_PYTHON=python3
export DATA_NAME=imagenet
export DATA_DIR=/media/tools/TF_ImageNet_latest
export MODEL_NAME=${ROOT_DIR}/benchmarks/scripts/tf_cnn_benchmarks/tf_cnn_benchmarks.py
export MODEL=resnet50
export TRAIN_DIR=${ROOT_DIR}/resnet50/train_dir
export EVAL_DIR=${ROOT_DIR}/resnet50
export DATA_FORMAT=NCHW
export BATCH_SIZE=1

${MY_PYTHON}
${MODEL_NAME} --eval
--model=${MODEL}
--num_inter_threads=2
--batch_size=${BATCH_SIZE}
--data_name=${DATA_NAME}
--data_dir=${DATA_DIR}
--data_format=${DATA_FORMAT}
--eval_dir=${EVAL_DIR}
--train_dir=${TRAIN_DIR}

@reedwm
Copy link
Member

reedwm commented Apr 3, 2019

Thank you for finding this! Do you want to send a PR to fix this by using tf.compat.v1.data.make_initializable_iterator(ds)? If not I'm happy to fix it.

@reedwm
Copy link
Member

reedwm commented Apr 3, 2019

Also note, this is broken at HEAD as well as 1.13.

@dmyershov
Copy link
Author

Please proceed with a fix.

Also, could you please take into account following?:
I was slightly confused by "As a last resort" clause from (TensorFlow repository) tensorflow/python/data/ops/dataset_ops.py:

@deprecation.deprecated(
None, "Use for ... in dataset: to iterate over a dataset. If using "
"tf.estimator, return the Dataset object directly from your input "
"function. As a last resort, you can use "
"tf.compat.v1.data.make_initializable_iterator(dataset).")
def make_initializable_iterator(self, shared_name=None):

Therefore, it might be not appropriate solution to use tf.compat.v1.data.make_initializable_iterator.

tensorflow-copybara pushed a commit that referenced this issue Apr 4, 2019
Also fix unit tests to catch this bug.

See #348.

PiperOrigin-RevId: 242009106
reedwm added a commit to reedwm/benchmarks that referenced this issue Apr 4, 2019
Also fix unit tests to catch this bug.

See tensorflow#348.

PiperOrigin-RevId: 242009106
reedwm added a commit that referenced this issue Apr 12, 2019
Also fix unit tests to catch this bug.

See #348.
@reedwm reedwm closed this as completed Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants