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
OpenDAS
MMCV
Commits
bef7c13a
Unverified
Commit
bef7c13a
authored
Apr 10, 2019
by
Kai Chen
Committed by
GitHub
Apr 10, 2019
Browse files
Merge pull request #47 from yhcao6/memory_statistic
reduce max memory in dist training
parents
4a1ddfc8
5726795c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
mmcv/runner/hooks/logger/text.py
mmcv/runner/hooks/logger/text.py
+7
-3
No files found.
mmcv/runner/hooks/logger/text.py
View file @
bef7c13a
import
datetime
import
torch
import
torch.distributed
as
dist
from
.base
import
LoggerHook
...
...
@@ -39,9 +40,12 @@ class TextLoggerHook(LoggerHook):
# statistic memory
if
runner
.
mode
==
'train'
and
torch
.
cuda
.
is_available
():
mem
=
torch
.
cuda
.
max_memory_allocated
()
mem_mb
=
int
(
mem
/
(
1024
*
1024
))
mem_str
=
'memory: {}, '
.
format
(
mem_mb
)
log_str
+=
mem_str
mem_mb
=
torch
.
tensor
([
mem
/
(
1024
*
1024
)],
dtype
=
torch
.
int
,
device
=
torch
.
device
(
'cuda'
))
if
runner
.
world_size
>
1
:
dist
.
reduce
(
mem_mb
,
0
,
op
=
dist
.
ReduceOp
.
MAX
)
log_str
+=
'memory: {}, '
.
format
(
mem_mb
.
item
())
log_items
=
[]
for
name
,
val
in
runner
.
log_buffer
.
output
.
items
():
if
name
in
[
'time'
,
'data_time'
]:
...
...
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