Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
H
Hydra Node Http
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
Hydra Node Http
Commits
f30be23f
Commit
f30be23f
authored
Jul 30, 2022
by
novelailab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix no init
parent
02b5dfc0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
hydra_node/config.py
hydra_node/config.py
+18
-2
hydra_node/models.py
hydra_node/models.py
+1
-17
No files found.
hydra_node/config.py
View file @
f30be23f
...
@@ -12,6 +12,22 @@ from sentry_sdk import capture_exception
...
@@ -12,6 +12,22 @@ from sentry_sdk import capture_exception
from
sentry_sdk.integrations.threading
import
ThreadingIntegration
from
sentry_sdk.integrations.threading
import
ThreadingIntegration
from
hydra_node.models
import
StableDiffusionModel
from
hydra_node.models
import
StableDiffusionModel
def
no_init
(
loading_code
):
def
dummy
(
self
):
return
modules
=
[
torch
.
nn
.
Linear
,
torch
.
nn
.
Embedding
,
torch
.
nn
.
LayerNorm
]
original
=
{}
for
mod
in
modules
:
original
[
mod
]
=
mod
.
reset_parameters
mod
.
reset_parameters
=
dummy
result
=
loading_code
()
for
mod
in
modules
:
mod
.
reset_parameters
=
original
[
mod
]
return
result
def
init_config_model
():
def
init_config_model
():
config
=
DotMap
()
config
=
DotMap
()
config
.
dtype
=
os
.
getenv
(
"DTYPE"
,
"float16"
)
config
.
dtype
=
os
.
getenv
(
"DTYPE"
,
"float16"
)
...
@@ -81,7 +97,7 @@ def init_config_model():
...
@@ -81,7 +97,7 @@ def init_config_model():
load_time
=
time
.
time
()
load_time
=
time
.
time
()
try
:
try
:
model
=
StableDiffusionModel
(
config
)
model
=
no_init
(
lambda
:
StableDiffusionModel
(
config
)
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
f
"Failed to load model: {str(e)}"
)
logger
.
error
(
f
"Failed to load model: {str(e)}"
)
capture_exception
(
e
)
capture_exception
(
e
)
...
@@ -97,7 +113,7 @@ def init_config_model():
...
@@ -97,7 +113,7 @@ def init_config_model():
f
=
open
(
"/tmp/health_readiness"
,
"w"
)
f
=
open
(
"/tmp/health_readiness"
,
"w"
)
f
.
close
()
f
.
close
()
time_load
=
time
.
time
()
-
load_time
time_load
=
time
.
time
()
-
load_time
logger
.
info
(
f
"Models loaded in {time_load:.2f}s"
)
logger
.
info
(
f
"Models loaded in {time_load:.2f}s"
)
...
...
hydra_node/models.py
View file @
f30be23f
...
@@ -14,27 +14,11 @@ from ldm.models.diffusion.ddim import DDIMSampler
...
@@ -14,27 +14,11 @@ from ldm.models.diffusion.ddim import DDIMSampler
from
ldm.models.diffusion.plms
import
PLMSSampler
from
ldm.models.diffusion.plms
import
PLMSSampler
import
time
import
time
def
no_init
(
loading_code
):
def
dummy
(
self
):
return
modules
=
[
torch
.
nn
.
Linear
,
torch
.
nn
.
Embedding
,
torch
.
nn
.
LayerNorm
]
original
=
{}
for
mod
in
modules
:
original
[
mod
]
=
mod
.
reset_parameters
mod
.
reset_parameters
=
dummy
result
=
loading_code
()
for
mod
in
modules
:
mod
.
reset_parameters
=
original
[
mod
]
return
result
class
StableDiffusionModel
(
nn
.
Module
):
class
StableDiffusionModel
(
nn
.
Module
):
def
__init__
(
self
,
config
):
def
__init__
(
self
,
config
):
nn
.
Module
.
__init__
(
self
)
nn
.
Module
.
__init__
(
self
)
self
.
config
=
config
self
.
config
=
config
model
,
model_config
=
no_init
(
lambda
:
self
.
from_folder
(
config
.
model_path
)
)
model
,
model_config
=
self
.
from_folder
(
config
.
model_path
)
if
config
.
dtype
==
"float16"
:
if
config
.
dtype
==
"float16"
:
typex
=
torch
.
float16
typex
=
torch
.
float16
else
:
else
:
...
...
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