FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
term-sd/python_modules/check_cuda_malloc_avaliable.py at main · licyk/term-sd · GitHub
licyk
/
term-sd
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
28
Code
Issues
2
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
term-sd
/
python_modules
/
check_cuda_malloc_avaliable.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (26 loc) · 1.05 KB
Breadcrumbs
term-sd
/
python_modules
/
check_cuda_malloc_avaliable.py
Copy path
File metadata and controls
31 lines (26 loc) · 1.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import
os
import
importlib
.
util
from
sd_webui_all_in_one
.
optimize
.
cuda_malloc
import
get_pytorch_cuda_alloc_conf
def
main
()
->
None
:
try
:
version
=
""
torch_spec
=
importlib
.
util
.
find_spec
(
"torch"
)
for
folder
in
torch_spec
.
submodule_search_locations
:
ver_file
=
os
.
path
.
join
(
folder
,
"version.py"
)
if
os
.
path
.
isfile
(
ver_file
):
spec
=
importlib
.
util
.
spec_from_file_location
(
"torch_version_import"
,
ver_file
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
module
)
version
=
module
.
__version__
if
int
(
version
[
0
])
>=
2
:
# enable by default for torch version 2.0 and up
if
"+cu"
in
version
:
# only on cuda torch
malloc_type
=
get_pytorch_cuda_alloc_conf
()
else
:
malloc_type
=
get_pytorch_cuda_alloc_conf
(
False
)
else
:
malloc_type
=
None
except
Exception
as
_
:
malloc_type
=
None
print
(
malloc_type
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL