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
50b55044
Commit
50b55044
authored
Oct 22, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove parsing command line from devices.py
parent
e80bdcab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
14 deletions
+9
-14
modules/devices.py
modules/devices.py
+5
-9
modules/lowvram.py
modules/lowvram.py
+4
-5
No files found.
modules/devices.py
View file @
50b55044
...
@@ -15,12 +15,8 @@ def extract_device_id(args, name):
...
@@ -15,12 +15,8 @@ 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.
sys
.
argv
+=
shlex
.
split
(
commandline_args
)
device_id
=
extract_device_id
(
sys
.
argv
,
'--device-id'
)
else
:
device_id
=
shared
.
cmd_opts
.
device_id
device_id
=
shared
.
cmd_opts
.
device_id
if
device_id
is
not
None
:
if
device_id
is
not
None
:
...
@@ -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
View file @
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
...
...
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