Fix: disable multiprocessing for bert_gen due to pyopenjtalk_worker
This commit is contained in:
16
bert_gen.py
16
bert_gen.py
@@ -6,15 +6,19 @@ import torch.multiprocessing as mp
|
|||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
|
from style_bert_vits2.constants import Languages
|
||||||
from style_bert_vits2.logging import logger
|
from style_bert_vits2.logging import logger
|
||||||
from style_bert_vits2.models import commons
|
from style_bert_vits2.models import commons
|
||||||
from style_bert_vits2.models.hyper_parameters import HyperParameters
|
from style_bert_vits2.models.hyper_parameters import HyperParameters
|
||||||
from style_bert_vits2.nlp import cleaned_text_to_sequence, extract_bert_feature
|
from style_bert_vits2.nlp import (
|
||||||
|
bert_models,
|
||||||
|
cleaned_text_to_sequence,
|
||||||
|
extract_bert_feature,
|
||||||
|
)
|
||||||
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker
|
from style_bert_vits2.nlp.japanese import pyopenjtalk_worker
|
||||||
from style_bert_vits2.nlp.japanese.user_dict import update_dict
|
from style_bert_vits2.nlp.japanese.user_dict import update_dict
|
||||||
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT
|
from style_bert_vits2.utils.stdout_wrapper import SAFE_STDOUT
|
||||||
from style_bert_vits2.nlp import bert_models
|
|
||||||
from style_bert_vits2.constants import Languages
|
|
||||||
|
|
||||||
bert_models.load_model(Languages.JP)
|
bert_models.load_model(Languages.JP)
|
||||||
bert_models.load_tokenizer(Languages.JP)
|
bert_models.load_tokenizer(Languages.JP)
|
||||||
@@ -74,9 +78,6 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", "--config", type=str, default=config.bert_gen_config.config_path
|
"-c", "--config", type=str, default=config.bert_gen_config.config_path
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--num_processes", type=int, default=config.bert_gen_config.num_processes
|
|
||||||
)
|
|
||||||
args, _ = parser.parse_known_args()
|
args, _ = parser.parse_known_args()
|
||||||
config_path = args.config
|
config_path = args.config
|
||||||
hps = HyperParameters.load_from_json(config_path)
|
hps = HyperParameters.load_from_json(config_path)
|
||||||
@@ -89,7 +90,8 @@ if __name__ == "__main__":
|
|||||||
add_blank = [hps.data.add_blank] * len(lines)
|
add_blank = [hps.data.add_blank] * len(lines)
|
||||||
|
|
||||||
if len(lines) != 0:
|
if len(lines) != 0:
|
||||||
num_processes = args.num_processes
|
# pyopenjtalkの別ワーカー化により、並列処理でエラーがでる模様なので、一旦シングルスレッド強制にする
|
||||||
|
num_processes = 1
|
||||||
with ThreadPoolExecutor(max_workers=num_processes) as executor:
|
with ThreadPoolExecutor(max_workers=num_processes) as executor:
|
||||||
_ = list(
|
_ = list(
|
||||||
tqdm(
|
tqdm(
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class Bert_gen_config:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config_path: str,
|
config_path: str,
|
||||||
num_processes: int = 2,
|
num_processes: int = 1,
|
||||||
device: str = "cuda",
|
device: str = "cuda",
|
||||||
use_multi_device: bool = False,
|
use_multi_device: bool = False,
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ preprocess_text:
|
|||||||
|
|
||||||
bert_gen:
|
bert_gen:
|
||||||
config_path: "config.json"
|
config_path: "config.json"
|
||||||
num_processes: 2
|
num_processes: 1
|
||||||
device: "cuda"
|
device: "cuda"
|
||||||
use_multi_device: false
|
use_multi_device: false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user