Skip to content

Commit a5b1cd1

Browse files
support win32 (#268)
1 parent 8a27ae2 commit a5b1cd1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

swift/ui/llm_train/llm_train.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import time
34
from dataclasses import fields
45
from typing import Dict, Type
@@ -262,7 +263,14 @@ def train(cls, *args):
262263
cuda_param = f'CUDA_VISIBLE_DEVICES={gpus}'
263264

264265
log_file = os.path.join(sft_args.logging_dir, 'run.log')
265-
run_command = f'{cuda_param} {ddp_param} nohup swift sft {params} > {log_file} 2>&1 &'
266+
if sys.platform == 'win32':
267+
if cuda_param:
268+
cuda_param = f'set {cuda_param} && '
269+
if ddp_param:
270+
ddp_param = f'set {ddp_param} && '
271+
run_command = f'{cuda_param}{ddp_param}start /b swift sft {params} > {log_file} 2>&1'
272+
else:
273+
run_command = f'{cuda_param} {ddp_param} nohup swift sft {params} > {log_file} 2>&1 &'
266274
logger.info(f'Run training: {run_command}')
267275
if not other_kwargs['dry_run']:
268276
os.makedirs(sft_args.logging_dir, exist_ok=True)

0 commit comments

Comments
 (0)