diff --git a/mindformers/trainer/base_trainer.py b/mindformers/trainer/base_trainer.py index 2bba7ab52508750b97eb7b089be0519c410b2c54..25f896756e54a096a91c8d388cbe588e5049b6c1 100644 --- a/mindformers/trainer/base_trainer.py +++ b/mindformers/trainer/base_trainer.py @@ -15,7 +15,7 @@ """Base Trainer.""" import os import re -import subprocess +import socket from pprint import pprint from functools import partial from typing import Optional, Union, List @@ -108,12 +108,8 @@ class BaseTrainer: def __init__(self, task: str = None, model_name: str = None): - host_name_output = subprocess.run(['hostname'], shell=False, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, encoding='utf-8', check=True) - host_ip_output = subprocess.run(['hostname', '-I'], shell=False, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, encoding='utf-8', check=True) - host_name = host_name_output.stdout.strip() - host_ip = host_ip_output.stdout.strip().split(' ')[0] + host_name = socket.gethostname() + host_ip = socket.gethostbyname(host_name) logger.info(f"host_name: {host_name}, host_ip: {host_ip}") if model_name is None: