Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
50b55044
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1746
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
50b55044
编写于
10月 22, 2022
作者:
A
AUTOMATIC
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove parsing command line from devices.py
上级
e80bdcab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
14 deletion
+9
-14
modules/devices.py
modules/devices.py
+5
-9
modules/lowvram.py
modules/lowvram.py
+4
-5
未找到文件。
modules/devices.py
浏览文件 @
50b55044
...
@@ -15,14 +15,10 @@ def extract_device_id(args, name):
...
@@ -15,14 +15,10 @@ def extract_device_id(args, name):
def
get_optimal_device
():
def
get_optimal_device
():
if
torch
.
cuda
.
is_available
():
if
torch
.
cuda
.
is_available
():
# CUDA device selection support:
from
modules
import
shared
if
"shared"
not
in
sys
.
modules
:
commandline_args
=
os
.
environ
.
get
(
'COMMANDLINE_ARGS'
,
""
)
#re-parse the commandline arguments because using the shared.py module creates an import loop.
device_id
=
shared
.
cmd_opts
.
device_id
sys
.
argv
+=
shlex
.
split
(
commandline_args
)
device_id
=
extract_device_id
(
sys
.
argv
,
'--device-id'
)
else
:
device_id
=
shared
.
cmd_opts
.
device_id
if
device_id
is
not
None
:
if
device_id
is
not
None
:
cuda_device
=
f
"cuda:
{
device_id
}
"
cuda_device
=
f
"cuda:
{
device_id
}
"
return
torch
.
device
(
cuda_device
)
return
torch
.
device
(
cuda_device
)
...
@@ -49,7 +45,7 @@ def enable_tf32():
...
@@ -49,7 +45,7 @@ def enable_tf32():
errors
.
run
(
enable_tf32
,
"Enabling TF32"
)
errors
.
run
(
enable_tf32
,
"Enabling TF32"
)
device
=
device_interrogate
=
device_gfpgan
=
device_bsrgan
=
device_esrgan
=
device_scunet
=
device_codeformer
=
get_optimal_device
()
device
=
device_interrogate
=
device_gfpgan
=
device_bsrgan
=
device_esrgan
=
device_scunet
=
device_codeformer
=
None
dtype
=
torch
.
float16
dtype
=
torch
.
float16
dtype_vae
=
torch
.
float16
dtype_vae
=
torch
.
float16
...
...
modules/lowvram.py
浏览文件 @
50b55044
import
torch
import
torch
from
modules
.devices
import
get_optimal_device
from
modules
import
devices
module_in_gpu
=
None
module_in_gpu
=
None
cpu
=
torch
.
device
(
"cpu"
)
cpu
=
torch
.
device
(
"cpu"
)
device
=
gpu
=
get_optimal_device
()
def
send_everything_to_cpu
():
def
send_everything_to_cpu
():
...
@@ -33,7 +32,7 @@ def setup_for_low_vram(sd_model, use_medvram):
...
@@ -33,7 +32,7 @@ def setup_for_low_vram(sd_model, use_medvram):
if
module_in_gpu
is
not
None
:
if
module_in_gpu
is
not
None
:
module_in_gpu
.
to
(
cpu
)
module_in_gpu
.
to
(
cpu
)
module
.
to
(
gpu
)
module
.
to
(
devices
.
device
)
module_in_gpu
=
module
module_in_gpu
=
module
# see below for register_forward_pre_hook;
# see below for register_forward_pre_hook;
...
@@ -51,7 +50,7 @@ def setup_for_low_vram(sd_model, use_medvram):
...
@@ -51,7 +50,7 @@ def setup_for_low_vram(sd_model, use_medvram):
# send the model to GPU. Then put modules back. the modules will be in CPU.
# send the model to GPU. Then put modules back. the modules will be in CPU.
stored
=
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
stored
=
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
=
None
,
None
,
None
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
=
None
,
None
,
None
sd_model
.
to
(
device
)
sd_model
.
to
(
device
s
.
device
)
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
=
stored
sd_model
.
cond_stage_model
.
transformer
,
sd_model
.
first_stage_model
,
sd_model
.
model
=
stored
# register hooks for those the first two models
# register hooks for those the first two models
...
@@ -70,7 +69,7 @@ def setup_for_low_vram(sd_model, use_medvram):
...
@@ -70,7 +69,7 @@ def setup_for_low_vram(sd_model, use_medvram):
# so that only one of them is in GPU at a time
# so that only one of them is in GPU at a time
stored
=
diff_model
.
input_blocks
,
diff_model
.
middle_block
,
diff_model
.
output_blocks
,
diff_model
.
time_embed
stored
=
diff_model
.
input_blocks
,
diff_model
.
middle_block
,
diff_model
.
output_blocks
,
diff_model
.
time_embed
diff_model
.
input_blocks
,
diff_model
.
middle_block
,
diff_model
.
output_blocks
,
diff_model
.
time_embed
=
None
,
None
,
None
,
None
diff_model
.
input_blocks
,
diff_model
.
middle_block
,
diff_model
.
output_blocks
,
diff_model
.
time_embed
=
None
,
None
,
None
,
None
sd_model
.
model
.
to
(
device
)
sd_model
.
model
.
to
(
device
s
.
device
)
diff_model
.
input_blocks
,
diff_model
.
middle_block
,
diff_model
.
output_blocks
,
diff_model
.
time_embed
=
stored
diff_model
.
input_blocks
,
diff_model
.
middle_block
,
diff_model
.
output_blocks
,
diff_model
.
time_embed
=
stored
# install hooks for bits of third model
# install hooks for bits of third model
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录