Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
a682083f
Commit
a682083f
authored
Aug 08, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix #368)
parent
54f45384
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
tensorpack/dataflow/prefetch.py
tensorpack/dataflow/prefetch.py
+18
-22
No files found.
tensorpack/dataflow/prefetch.py
View file @
a682083f
...
...
@@ -117,8 +117,7 @@ class PrefetchDataZMQ(ProxyDataFlow):
Note:
1. Once :meth:`reset_state` is called, this dataflow becomes not fork-safe.
2. When nesting like this: ``PrefetchDataZMQ(PrefetchDataZMQ(df, a), b)``.
A total of ``a * b`` instances of ``df`` worker processes will be created.
2. This dataflow is not fork-safe. You cannot nest it.
3. The underlying dataflow worker will be forked multiple times When ``nr_proc>1``.
As a result, unless the underlying dataflow is fully shuffled, the data distribution
produced by this dataflow will be wrong.
...
...
@@ -139,7 +138,22 @@ class PrefetchDataZMQ(ProxyDataFlow):
self
.
_size
=
-
1
self
.
nr_proc
=
nr_proc
self
.
_hwm
=
hwm
self
.
_finish_setup
=
False
self
.
context
=
zmq
.
Context
()
self
.
socket
=
self
.
context
.
socket
(
zmq
.
PULL
)
pipedir
=
os
.
environ
.
get
(
'TENSORPACK_PIPEDIR'
,
'.'
)
assert
os
.
path
.
isdir
(
pipedir
),
pipedir
self
.
pipename
=
"ipc://{}/dataflow-pipe-"
.
format
(
pipedir
.
rstrip
(
'/'
))
+
str
(
uuid
.
uuid1
())[:
6
]
self
.
socket
.
set_hwm
(
self
.
_hwm
)
self
.
socket
.
bind
(
self
.
pipename
)
self
.
procs
=
[
PrefetchProcessZMQ
(
self
.
ds
,
self
.
pipename
,
self
.
_hwm
)
for
_
in
range
(
self
.
nr_proc
)]
self
.
start_processes
()
# __del__ not guranteed to get called at exit
import
atexit
atexit
.
register
(
lambda
x
:
x
.
__del__
(),
self
)
def
get_data
(
self
):
try
:
...
...
@@ -165,25 +179,7 @@ class PrefetchDataZMQ(ProxyDataFlow):
All forked dataflows are reset **once and only once** in spawned processes.
Nothing more can be done when calling this method.
"""
if
self
.
_finish_setup
:
return
self
.
_finish_setup
=
True
self
.
context
=
zmq
.
Context
()
self
.
socket
=
self
.
context
.
socket
(
zmq
.
PULL
)
pipedir
=
os
.
environ
.
get
(
'TENSORPACK_PIPEDIR'
,
'.'
)
assert
os
.
path
.
isdir
(
pipedir
),
pipedir
self
.
pipename
=
"ipc://{}/dataflow-pipe-"
.
format
(
pipedir
.
rstrip
(
'/'
))
+
str
(
uuid
.
uuid1
())[:
6
]
self
.
socket
.
set_hwm
(
self
.
_hwm
)
self
.
socket
.
bind
(
self
.
pipename
)
self
.
procs
=
[
PrefetchProcessZMQ
(
self
.
ds
,
self
.
pipename
,
self
.
_hwm
)
for
_
in
range
(
self
.
nr_proc
)]
self
.
start_processes
()
# __del__ not guranteed to get called at exit
import
atexit
atexit
.
register
(
lambda
x
:
x
.
__del__
(),
self
)
pass
def
start_processes
(
self
):
start_proc_mask_signal
(
self
.
procs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment