TFRecord IO slower than python hdf5 reader, how do I improve its speed?
up vote
0
down vote
favorite
I was following the official TF giude to use the tf.data.Dataset
API for building data pipeline, but I found it ~2 times slower than my python data pipeline using hdf5.
Here's my experiment result:
TFRecordDataset: 660 thousand samples/second
hdf5 reader + feed_dict to placeholder: 1.1 million samples/second
My experiment setting is:
- batch size=1000,
- print log every 10 million samples to show the time,
- run a fake model that only takes data as input and do not compute anything.
what's worse is that when I set batch size=10000, it becomes:
TFRecordDataset: 760 thousand samples/second
hdf5 reader + feed_dict to placeholder: 2.1 million samples/second
Here's my code for reading tfrecord
def parse_tfrecord_batch(record_batch):
FEATURE_LEN = 29
dics =
'label': tf.FixedLenFeature(shape=(), dtype=tf.int64),
'feature_id': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.int64),
'feature_val': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.float32)
parsed_example = tf.parse_example(record_batch, dics)
return parsed_example['feature_id'], parsed_example['feature_val'], parsed_example['label']
class fakeModel:
def __init__(self, train_filenames):
self.graph = tf.Graph()
with self.graph.as_default():
dataset = tf.data.TFRecordDataset(train_filenames)
dataset = dataset.repeat()
dataset = dataset.batch(1000)
dataset = dataset.map(parse_tfrecord_batch, num_parallel_calls=1)
dataset = dataset.prefetch(1000)
self.iterator = dataset.make_initializable_iterator()
self.id, self.wt, self.label = self.iterator.get_next()
self.train_preds = tf.identity(self.lbl_hldr)
I've tune the num_parallel_calls
to 2, 10. Not working.
I've also tuned the prefetch(n)
from 1 to 1000, which has little improvement.
My question is:
Is there any way to improve my tfrecord data pipeline? Am I missing something in my code?
Appreciate it for any help.
tensorflow hdf5 tensorflow-datasets tfrecord
add a comment |
up vote
0
down vote
favorite
I was following the official TF giude to use the tf.data.Dataset
API for building data pipeline, but I found it ~2 times slower than my python data pipeline using hdf5.
Here's my experiment result:
TFRecordDataset: 660 thousand samples/second
hdf5 reader + feed_dict to placeholder: 1.1 million samples/second
My experiment setting is:
- batch size=1000,
- print log every 10 million samples to show the time,
- run a fake model that only takes data as input and do not compute anything.
what's worse is that when I set batch size=10000, it becomes:
TFRecordDataset: 760 thousand samples/second
hdf5 reader + feed_dict to placeholder: 2.1 million samples/second
Here's my code for reading tfrecord
def parse_tfrecord_batch(record_batch):
FEATURE_LEN = 29
dics =
'label': tf.FixedLenFeature(shape=(), dtype=tf.int64),
'feature_id': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.int64),
'feature_val': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.float32)
parsed_example = tf.parse_example(record_batch, dics)
return parsed_example['feature_id'], parsed_example['feature_val'], parsed_example['label']
class fakeModel:
def __init__(self, train_filenames):
self.graph = tf.Graph()
with self.graph.as_default():
dataset = tf.data.TFRecordDataset(train_filenames)
dataset = dataset.repeat()
dataset = dataset.batch(1000)
dataset = dataset.map(parse_tfrecord_batch, num_parallel_calls=1)
dataset = dataset.prefetch(1000)
self.iterator = dataset.make_initializable_iterator()
self.id, self.wt, self.label = self.iterator.get_next()
self.train_preds = tf.identity(self.lbl_hldr)
I've tune the num_parallel_calls
to 2, 10. Not working.
I've also tuned the prefetch(n)
from 1 to 1000, which has little improvement.
My question is:
Is there any way to improve my tfrecord data pipeline? Am I missing something in my code?
Appreciate it for any help.
tensorflow hdf5 tensorflow-datasets tfrecord
Why bother benchmarking a no-op model that does no computation? Doesn't a real-world application's actual computation dwarf the dummy no-op time? How long does your real code take to run in either of these systems?
– John Zwinck
Nov 11 at 10:12
@John Zwinck 1. Because when I train my DL model on GPU, the utility is below 50%. I guess the GPU is not fully utilized and the speed of the data pipeline could be a important factor, so I tested both methods. 2. Actually, both methods takes nearly same time during training DL model, showing similar GPU utility. so maybe the low utility is not brought by the data pipeline.
– JenkinsY
Nov 12 at 1:15
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I was following the official TF giude to use the tf.data.Dataset
API for building data pipeline, but I found it ~2 times slower than my python data pipeline using hdf5.
Here's my experiment result:
TFRecordDataset: 660 thousand samples/second
hdf5 reader + feed_dict to placeholder: 1.1 million samples/second
My experiment setting is:
- batch size=1000,
- print log every 10 million samples to show the time,
- run a fake model that only takes data as input and do not compute anything.
what's worse is that when I set batch size=10000, it becomes:
TFRecordDataset: 760 thousand samples/second
hdf5 reader + feed_dict to placeholder: 2.1 million samples/second
Here's my code for reading tfrecord
def parse_tfrecord_batch(record_batch):
FEATURE_LEN = 29
dics =
'label': tf.FixedLenFeature(shape=(), dtype=tf.int64),
'feature_id': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.int64),
'feature_val': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.float32)
parsed_example = tf.parse_example(record_batch, dics)
return parsed_example['feature_id'], parsed_example['feature_val'], parsed_example['label']
class fakeModel:
def __init__(self, train_filenames):
self.graph = tf.Graph()
with self.graph.as_default():
dataset = tf.data.TFRecordDataset(train_filenames)
dataset = dataset.repeat()
dataset = dataset.batch(1000)
dataset = dataset.map(parse_tfrecord_batch, num_parallel_calls=1)
dataset = dataset.prefetch(1000)
self.iterator = dataset.make_initializable_iterator()
self.id, self.wt, self.label = self.iterator.get_next()
self.train_preds = tf.identity(self.lbl_hldr)
I've tune the num_parallel_calls
to 2, 10. Not working.
I've also tuned the prefetch(n)
from 1 to 1000, which has little improvement.
My question is:
Is there any way to improve my tfrecord data pipeline? Am I missing something in my code?
Appreciate it for any help.
tensorflow hdf5 tensorflow-datasets tfrecord
I was following the official TF giude to use the tf.data.Dataset
API for building data pipeline, but I found it ~2 times slower than my python data pipeline using hdf5.
Here's my experiment result:
TFRecordDataset: 660 thousand samples/second
hdf5 reader + feed_dict to placeholder: 1.1 million samples/second
My experiment setting is:
- batch size=1000,
- print log every 10 million samples to show the time,
- run a fake model that only takes data as input and do not compute anything.
what's worse is that when I set batch size=10000, it becomes:
TFRecordDataset: 760 thousand samples/second
hdf5 reader + feed_dict to placeholder: 2.1 million samples/second
Here's my code for reading tfrecord
def parse_tfrecord_batch(record_batch):
FEATURE_LEN = 29
dics =
'label': tf.FixedLenFeature(shape=(), dtype=tf.int64),
'feature_id': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.int64),
'feature_val': tf.FixedLenFeature(shape=(FEATURE_LEN,), dtype=tf.float32)
parsed_example = tf.parse_example(record_batch, dics)
return parsed_example['feature_id'], parsed_example['feature_val'], parsed_example['label']
class fakeModel:
def __init__(self, train_filenames):
self.graph = tf.Graph()
with self.graph.as_default():
dataset = tf.data.TFRecordDataset(train_filenames)
dataset = dataset.repeat()
dataset = dataset.batch(1000)
dataset = dataset.map(parse_tfrecord_batch, num_parallel_calls=1)
dataset = dataset.prefetch(1000)
self.iterator = dataset.make_initializable_iterator()
self.id, self.wt, self.label = self.iterator.get_next()
self.train_preds = tf.identity(self.lbl_hldr)
I've tune the num_parallel_calls
to 2, 10. Not working.
I've also tuned the prefetch(n)
from 1 to 1000, which has little improvement.
My question is:
Is there any way to improve my tfrecord data pipeline? Am I missing something in my code?
Appreciate it for any help.
tensorflow hdf5 tensorflow-datasets tfrecord
tensorflow hdf5 tensorflow-datasets tfrecord
asked Nov 11 at 9:51
JenkinsY
88113
88113
Why bother benchmarking a no-op model that does no computation? Doesn't a real-world application's actual computation dwarf the dummy no-op time? How long does your real code take to run in either of these systems?
– John Zwinck
Nov 11 at 10:12
@John Zwinck 1. Because when I train my DL model on GPU, the utility is below 50%. I guess the GPU is not fully utilized and the speed of the data pipeline could be a important factor, so I tested both methods. 2. Actually, both methods takes nearly same time during training DL model, showing similar GPU utility. so maybe the low utility is not brought by the data pipeline.
– JenkinsY
Nov 12 at 1:15
add a comment |
Why bother benchmarking a no-op model that does no computation? Doesn't a real-world application's actual computation dwarf the dummy no-op time? How long does your real code take to run in either of these systems?
– John Zwinck
Nov 11 at 10:12
@John Zwinck 1. Because when I train my DL model on GPU, the utility is below 50%. I guess the GPU is not fully utilized and the speed of the data pipeline could be a important factor, so I tested both methods. 2. Actually, both methods takes nearly same time during training DL model, showing similar GPU utility. so maybe the low utility is not brought by the data pipeline.
– JenkinsY
Nov 12 at 1:15
Why bother benchmarking a no-op model that does no computation? Doesn't a real-world application's actual computation dwarf the dummy no-op time? How long does your real code take to run in either of these systems?
– John Zwinck
Nov 11 at 10:12
Why bother benchmarking a no-op model that does no computation? Doesn't a real-world application's actual computation dwarf the dummy no-op time? How long does your real code take to run in either of these systems?
– John Zwinck
Nov 11 at 10:12
@John Zwinck 1. Because when I train my DL model on GPU, the utility is below 50%. I guess the GPU is not fully utilized and the speed of the data pipeline could be a important factor, so I tested both methods. 2. Actually, both methods takes nearly same time during training DL model, showing similar GPU utility. so maybe the low utility is not brought by the data pipeline.
– JenkinsY
Nov 12 at 1:15
@John Zwinck 1. Because when I train my DL model on GPU, the utility is below 50%. I guess the GPU is not fully utilized and the speed of the data pipeline could be a important factor, so I tested both methods. 2. Actually, both methods takes nearly same time during training DL model, showing similar GPU utility. so maybe the low utility is not brought by the data pipeline.
– JenkinsY
Nov 12 at 1:15
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247534%2ftfrecord-io-slower-than-python-hdf5-reader-how-do-i-improve-its-speed%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why bother benchmarking a no-op model that does no computation? Doesn't a real-world application's actual computation dwarf the dummy no-op time? How long does your real code take to run in either of these systems?
– John Zwinck
Nov 11 at 10:12
@John Zwinck 1. Because when I train my DL model on GPU, the utility is below 50%. I guess the GPU is not fully utilized and the speed of the data pipeline could be a important factor, so I tested both methods. 2. Actually, both methods takes nearly same time during training DL model, showing similar GPU utility. so maybe the low utility is not brought by the data pipeline.
– JenkinsY
Nov 12 at 1:15