fix abort in webui DDP mode

This commit is contained in:
hiyouga
2024-06-04 00:10:24 +08:00
parent ae18e1e251
commit 2187518762
3 changed files with 32 additions and 54 deletions

View File

@@ -1,8 +1,10 @@
import json
import os
import signal
from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple
import psutil
from transformers.trainer_utils import get_last_checkpoint
from yaml import safe_dump, safe_load
@@ -17,6 +19,18 @@ if is_gradio_available():
import gradio as gr
def abort_leaf_process(pid: int) -> None:
r"""
Aborts the leaf processes.
"""
children = psutil.Process(pid).children()
if children:
for child in children:
abort_leaf_process(child.pid)
else:
os.kill(pid, signal.SIGABRT)
def can_quantize(finetuning_type: str) -> "gr.Dropdown":
r"""
Judges if the quantization is available in this finetuning type.