Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
34beb7ad
Commit
34beb7ad
authored
Sep 11, 2018
by
Reed
Committed by
Taylor Robie
Sep 11, 2018
Browse files
Fix race condition with ready file. (#5271)
parent
e6ce8cdd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
official/recommendation/constants.py
official/recommendation/constants.py
+1
-0
official/recommendation/data_async_generation.py
official/recommendation/data_async_generation.py
+7
-1
No files found.
official/recommendation/constants.py
View file @
34beb7ad
...
@@ -58,6 +58,7 @@ NUM_EVAL_NEGATIVES = 999
...
@@ -58,6 +58,7 @@ NUM_EVAL_NEGATIVES = 999
CYCLES_TO_BUFFER
=
3
# The number of train cycles worth of data to "run ahead"
CYCLES_TO_BUFFER
=
3
# The number of train cycles worth of data to "run ahead"
# of the main training loop.
# of the main training loop.
READY_FILE_TEMP
=
"ready.json.temp"
READY_FILE
=
"ready.json"
READY_FILE
=
"ready.json"
TRAIN_RECORD_TEMPLATE
=
"train_{}.tfrecords"
TRAIN_RECORD_TEMPLATE
=
"train_{}.tfrecords"
...
...
official/recommendation/data_async_generation.py
View file @
34beb7ad
...
@@ -282,11 +282,17 @@ def _construct_training_records(
...
@@ -282,11 +282,17 @@ def _construct_training_records(
raise
ValueError
(
"Error detected: point counts do not match: {} vs. {}"
raise
ValueError
(
"Error detected: point counts do not match: {} vs. {}"
.
format
(
num_pts
,
written_pts
))
.
format
(
num_pts
,
written_pts
))
with
tf
.
gfile
.
Open
(
os
.
path
.
join
(
record_dir
,
rconst
.
READY_FILE
),
"w"
)
as
f
:
# We write to a temp file then atomically rename it to the final file, because
# writing directly to the final file can cause the main process to read a
# partially written JSON file.
ready_file_temp
=
os
.
path
.
join
(
record_dir
,
rconst
.
READY_FILE_TEMP
)
with
tf
.
gfile
.
Open
(
ready_file_temp
,
"w"
)
as
f
:
json
.
dump
({
json
.
dump
({
"batch_size"
:
train_batch_size
,
"batch_size"
:
train_batch_size
,
"batch_count"
:
batch_count
,
"batch_count"
:
batch_count
,
},
f
)
},
f
)
ready_file
=
os
.
path
.
join
(
record_dir
,
rconst
.
READY_FILE
)
tf
.
gfile
.
Rename
(
ready_file_temp
,
ready_file
)
log_msg
(
"Cycle {} complete. Total time: {:.1f} seconds"
log_msg
(
"Cycle {} complete. Total time: {:.1f} seconds"
.
format
(
train_cycle
,
timeit
.
default_timer
()
-
st
))
.
format
(
train_cycle
,
timeit
.
default_timer
()
-
st
))
...
...
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