Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
95727312
Commit
95727312
authored
Jan 09, 2023
by
Vladimir Mandic
Committed by
GitHub
Jan 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove bytes -> gb conversion
parent
47534577
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
modules/api/api.py
modules/api/api.py
+8
-10
No files found.
modules/api/api.py
View file @
95727312
...
...
@@ -467,26 +467,24 @@ class Api:
return
TrainResponse
(
info
=
"train embedding error: {error}"
.
format
(
error
=
error
))
def
get_memory
(
self
):
def
gb
(
val
:
float
):
return
round
(
val
/
1024
/
1024
/
1024
,
2
)
try
:
import
os
,
psutil
process
=
psutil
.
Process
(
os
.
getpid
())
res
=
process
.
memory_info
()
ram_total
=
100
*
res
.
rss
/
process
.
memory_percent
()
ram
=
{
'free'
:
gb
(
ram_total
-
res
.
rss
),
'used'
:
gb
(
res
.
rss
),
'total'
:
gb
(
ram_total
)
}
res
=
process
.
memory_info
()
# only rss is cross-platform guaranteed so we dont rely on other values
ram_total
=
100
*
res
.
rss
/
process
.
memory_percent
()
# and total memory is calculated as actual value is not cross-platform safe
ram
=
{
'free'
:
ram_total
-
res
.
rss
,
'used'
:
res
.
rss
,
'total'
:
ram_total
}
except
Exception
as
err
:
ram
=
{
'error'
:
f
'{err}'
}
try
:
import
torch
if
torch
.
cuda
.
is_available
():
s
=
torch
.
cuda
.
mem_get_info
()
system
=
{
'free'
:
gb
(
s
[
0
]),
'used'
:
gb
(
s
[
1
]
-
s
[
0
]),
'total'
:
gb
(
s
[
1
])
}
system
=
{
'free'
:
s
[
0
],
'used'
:
s
[
1
]
-
s
[
0
],
'total'
:
s
[
1
]
}
s
=
dict
(
torch
.
cuda
.
memory_stats
(
shared
.
device
))
allocated
=
{
'current'
:
gb
(
s
[
'allocated_bytes.all.current'
]),
'peak'
:
gb
(
s
[
'allocated_bytes.all.peak'
])
}
reserved
=
{
'current'
:
gb
(
s
[
'reserved_bytes.all.current'
]),
'peak'
:
gb
(
s
[
'reserved_bytes.all.peak'
])
}
active
=
{
'current'
:
gb
(
s
[
'active_bytes.all.current'
]),
'peak'
:
gb
(
s
[
'active_bytes.all.peak'
])
}
inactive
=
{
'current'
:
gb
(
s
[
'inactive_split_bytes.all.current'
]),
'peak'
:
gb
(
s
[
'inactive_split_bytes.all.peak'
])
}
allocated
=
{
'current'
:
s
[
'allocated_bytes.all.current'
],
'peak'
:
s
[
'allocated_bytes.all.peak'
]
}
reserved
=
{
'current'
:
s
[
'reserved_bytes.all.current'
],
'peak'
:
s
[
'reserved_bytes.all.peak'
]
}
active
=
{
'current'
:
s
[
'active_bytes.all.current'
],
'peak'
:
s
[
'active_bytes.all.peak'
]
}
inactive
=
{
'current'
:
s
[
'inactive_split_bytes.all.current'
],
'peak'
:
s
[
'inactive_split_bytes.all.peak'
]
}
warnings
=
{
'retries'
:
s
[
'num_alloc_retries'
],
'oom'
:
s
[
'num_ooms'
]
}
cuda
=
{
'system'
:
system
,
...
...
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