mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-28 09:08:54 +00:00
Add logging, ripgrep, FIX DEVICE != cpu!
This commit is contained in:
@@ -3,7 +3,7 @@ FROM nvidia/cuda:12.0.1-runtime-ubuntu22.04
|
|||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# NB: ffmpeg for transcoding opus -> wav
|
# NB: ffmpeg for transcoding opus -> wav
|
||||||
# NB(bt,2023-05-04): Installing lsof, htop, and other debugging tools
|
# NB(bt,2023-05-04): Installing lsof, htop, ripgrep, and other debugging tools
|
||||||
# NB(bt,2023-05-04): Installing rsync to monitor time it takes for files to sync
|
# NB(bt,2023-05-04): Installing rsync to monitor time it takes for files to sync
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
build-essential \
|
build-essential \
|
||||||
@@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
python3.10 \
|
python3.10 \
|
||||||
python3.10-dev \
|
python3.10-dev \
|
||||||
python3.10-venv \
|
python3.10-venv \
|
||||||
|
ripgrep \
|
||||||
rsync \
|
rsync \
|
||||||
vim \
|
vim \
|
||||||
wget \
|
wget \
|
||||||
|
|||||||
@@ -129,12 +129,19 @@ class Svc:
|
|||||||
self.cluster_model = cluster.get_cluster_model(cluster_model_path)
|
self.cluster_model = cluster.get_cluster_model(cluster_model_path)
|
||||||
|
|
||||||
def load_model(self):
|
def load_model(self):
|
||||||
|
LOG.info(f"Svc.load_model() ... ")
|
||||||
self.net_g = SynthesizerTrn(
|
self.net_g = SynthesizerTrn(
|
||||||
self.hps.data.filter_length // 2 + 1,
|
self.hps.data.filter_length // 2 + 1,
|
||||||
self.hps.train.segment_size // self.hps.data.hop_length,
|
self.hps.train.segment_size // self.hps.data.hop_length,
|
||||||
**self.hps.model,
|
**self.hps.model,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
LOG.info(f"Svc.load_model() utils.load_checkpoit() BEGIN")
|
||||||
|
|
||||||
_ = utils.load_checkpoint(self.net_g_path, self.net_g, None)
|
_ = utils.load_checkpoint(self.net_g_path, self.net_g, None)
|
||||||
|
|
||||||
|
LOG.info(f"Svc.load_model() utils.load_checkpoit() END")
|
||||||
|
|
||||||
_ = self.net_g.eval().to(self.device, dtype=self.dtype)
|
_ = self.net_g.eval().to(self.device, dtype=self.dtype)
|
||||||
|
|
||||||
def get_unit_f0(
|
def get_unit_f0(
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ class HubertModelWithFinalProj(HubertModel):
|
|||||||
def get_hubert_model(
|
def get_hubert_model(
|
||||||
device: str | torch.device, final_proj: bool = True
|
device: str | torch.device, final_proj: bool = True
|
||||||
) -> HubertModel:
|
) -> HubertModel:
|
||||||
|
LOG.info("get_hubert_model()")
|
||||||
if final_proj:
|
if final_proj:
|
||||||
return HubertModelWithFinalProj.from_pretrained(
|
return HubertModelWithFinalProj.from_pretrained(
|
||||||
"lengyue233/content-vec-best"
|
"lengyue233/content-vec-best"
|
||||||
@@ -233,6 +234,9 @@ def load_checkpoint(
|
|||||||
optimizer: torch.optim.Optimizer | None = None,
|
optimizer: torch.optim.Optimizer | None = None,
|
||||||
skip_optimizer: bool = False,
|
skip_optimizer: bool = False,
|
||||||
) -> tuple[torch.nn.Module, torch.optim.Optimizer | None, float, int]:
|
) -> tuple[torch.nn.Module, torch.optim.Optimizer | None, float, int]:
|
||||||
|
|
||||||
|
LOG.info(f"utils.load_checkpoint(): path = {checkpoint_path}")
|
||||||
|
|
||||||
if not Path(checkpoint_path).is_file():
|
if not Path(checkpoint_path).is_file():
|
||||||
raise FileNotFoundError(f"File {checkpoint_path} not found")
|
raise FileNotFoundError(f"File {checkpoint_path} not found")
|
||||||
with Path(checkpoint_path).open("rb") as f:
|
with Path(checkpoint_path).open("rb") as f:
|
||||||
@@ -242,15 +246,28 @@ def load_checkpoint(
|
|||||||
)
|
)
|
||||||
# NB(paul): iirc changing this to false prevented an error at some point
|
# NB(paul): iirc changing this to false prevented an error at some point
|
||||||
# but it also worsens security
|
# but it also worsens security
|
||||||
checkpoint_dict = torch.load(f, map_location="cpu", weights_only=False)
|
|
||||||
|
LOG.info("utils.load_checkpoint(): torch.load() BEGIN")
|
||||||
|
|
||||||
|
# NB(bt, 2023-05-04): This was set to CPU! Maybe this is the fix
|
||||||
|
# checkpoint_dict = torch.load(f, map_location="cpu", weights_only=False)
|
||||||
|
checkpoint_dict = torch.load(f, weights_only=False)
|
||||||
|
|
||||||
|
LOG.info("utils.load_checkpoint(): torch.load() END")
|
||||||
|
|
||||||
iteration = checkpoint_dict["iteration"]
|
iteration = checkpoint_dict["iteration"]
|
||||||
learning_rate = checkpoint_dict["learning_rate"]
|
learning_rate = checkpoint_dict["learning_rate"]
|
||||||
|
|
||||||
# safe load module
|
# safe load module
|
||||||
|
LOG.info("utils.load_checkpoint(): safe_load() BEGIN")
|
||||||
|
|
||||||
if hasattr(model, "module"):
|
if hasattr(model, "module"):
|
||||||
safe_load(model.module, checkpoint_dict["model"])
|
safe_load(model.module, checkpoint_dict["model"])
|
||||||
else:
|
else:
|
||||||
safe_load(model, checkpoint_dict["model"])
|
safe_load(model, checkpoint_dict["model"])
|
||||||
|
|
||||||
|
LOG.info("utils.load_checkpoint(): safe_load() END")
|
||||||
|
|
||||||
# safe load optim
|
# safe load optim
|
||||||
if (
|
if (
|
||||||
optimizer is not None
|
optimizer is not None
|
||||||
@@ -259,8 +276,13 @@ def load_checkpoint(
|
|||||||
):
|
):
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("ignore")
|
warnings.simplefilter("ignore")
|
||||||
|
|
||||||
|
LOG.info("utils.load_checkpoint(): safe_load() optimizer BEGIN")
|
||||||
|
|
||||||
safe_load(optimizer, checkpoint_dict["optimizer"])
|
safe_load(optimizer, checkpoint_dict["optimizer"])
|
||||||
|
|
||||||
|
LOG.info("utils.load_checkpoint(): safe_load() optimizer END")
|
||||||
|
|
||||||
LOG.info(f"Loaded checkpoint '{checkpoint_path}' (epoch {iteration})")
|
LOG.info(f"Loaded checkpoint '{checkpoint_path}' (epoch {iteration})")
|
||||||
return model, optimizer, learning_rate, iteration
|
return model, optimizer, learning_rate, iteration
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user