-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Fix fetch record from master failed #2848
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
python/paddle/v2/dataset/common.py
Outdated
@@ -201,8 +201,7 @@ def close_writers(w): | |||
def write_data(w, lines): | |||
random.shuffle(lines) | |||
for i, d in enumerate(lines): | |||
d = pickle.dumps(d, pickle.HIGHEST_PROTOCOL) | |||
w[i % num_shards].write(d) | |||
w[i % num_shards].write(str(d)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it hurt the speed if we remove the Pickle module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious as well, why this change could fix the failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recordio模块是不是没有更新?这个错误在我写convert的时候已经碰到过了,helin也已经fix掉了。
去掉Pickle解决这个问题,有点奇怪。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we need pickle? since the master is parsing recordio files directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same to @typhoonzero , the master need recordio files, and the convert
function write a file with pickle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用户写入的可能是一个object,比如list,用str是无法完成序列化的吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks all! I got it and fixed.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Two minor comments.
go/master/client.go
Outdated
@@ -38,7 +39,8 @@ func (c *Client) getRecords() { | |||
if err != nil { | |||
// TODO(helin): wait before move on with next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the TODO? since it's already done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
python/paddle/v2/dataset/common.py
Outdated
@@ -201,8 +201,7 @@ def close_writers(w): | |||
def write_data(w, lines): | |||
random.shuffle(lines) | |||
for i, d in enumerate(lines): | |||
d = pickle.dumps(d, pickle.HIGHEST_PROTOCOL) | |||
w[i % num_shards].write(d) | |||
w[i % num_shards].write(str(d)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious as well, why this change could fix the failure?
python/paddle/v2/dataset/common.py
Outdated
@@ -201,8 +201,7 @@ def close_writers(w): | |||
def write_data(w, lines): | |||
random.shuffle(lines) | |||
for i, d in enumerate(lines): | |||
d = pickle.dumps(d, pickle.HIGHEST_PROTOCOL) | |||
w[i % num_shards].write(d) | |||
w[i % num_shards].write(str(d)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recordio模块是不是没有更新?这个错误在我写convert的时候已经碰到过了,helin也已经fix掉了。
去掉Pickle解决这个问题,有点奇怪。。。
|
Agree with @gongweibao on #2848 (comment) , good catch! |
的确,dataset的reader读取出来的都是tuple,record io对应的reader应该是这样: def cloud_reader():
master_client = master.client(etcd_endpoint, 5, 64)
master_client.set_dataset(
["/pfs/dlnel/public/dataset/uci_housing/uci_housing-*-of-*"])
while 1:
r, e = master_client.next_record()
if not r:
break
yield pickle.loads(r) |
When use pickle.loads(r) reporting:
Fixed and following #2848 (comment) please :) |
python/paddle/v2/dataset/common.py
Outdated
@@ -201,8 +201,10 @@ def close_writers(w): | |||
def write_data(w, lines): | |||
random.shuffle(lines) | |||
for i, d in enumerate(lines): | |||
d = pickle.dumps(d, pickle.HIGHEST_PROTOCOL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modify the protocol version from HIGHEST_PROTOCOL to 0, because this will cause an EOFError
:
Traceback (most recent call last):
File "decode.py", line 13, in <module>
print pickle.loads(o)
EOFError
I think this error maybe caused by RecordIO library: Use binary stream as input will caused an EOFError, the following is my test code, it will throw an EOFError
w = recordio.writer("tmp-recordio")
for i in xrange(10):
w.write(pickle.dumps(i, pickle.HIGHEST_PROTOCOL))
w.close()
r = recordio.reader("tmp-recordio")
for i in xrange(10):
o = r.read()
print pickle.loads(o)
r.close()
=========
Traceback (most recent call last):
File "decode.py", line 13, in <module>
print pickle.loads(o)
EOFError
I will follow this problem, and maybe do not block this fix:)
Some documents:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/PaddlePaddle/recordio/blob/master/python/recordio/recordio_test.py#L9
这个单测确实没有设置协议。
不过0
的编码后文件比较大,不如用pickle.HIGHEST_PROTOCOL
或者负数。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考上面的comment,如果用pickle.HIGHEST_PROTOCOL
会导致RecordIO读取数据失败,感觉是RecordIO的library对二进制的输入支持的有些问题,我还在跟进,会在其他PR中修复这个问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Test code:
uci_housing
to RecordIO files.And then the script will print the record correctly: