"没有GPU的服务器,训练本地的模型,代码如下:import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
from swift.llm import DatasetName, ModelType, SftArguments, sft_main
sft_args = SftArguments(
model_id_or_path='/models/Qwen-7B-Chat',
model_type=ModelType.qwen_7b_chat,
dataset=[DatasetName.ms_bench_mini],
train_dataset_sample=1000,
logging_steps=5,
max_length=2048,
learning_rate=5e-5,
warmup_ratio=0.4,
output_dir='output',
lora_target_modules=['ALL'],
self_cognition_sample=500,
model_name=['小黄', 'Xiao Huang'],
model_author=['魔搭', 'ModelScope'])
output = sft_main(sft_args)
best_model_checkpoint = output['best_model_checkpoint']
print(f'best_model_checkpoint: {best_model_checkpoint}'),是从https://github.com/modelscope/swift/blob/main/docs/source/LLM/Qwen1.5%E5%85%A8%E6%B5%81%E7%A8%8B%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md复制下来的,却报错了:Traceback (most recent call last):
File ""train.py"", line 22, in
output = sft_main(sft_args)
File ""/models/swift/swift/utils/run_utils.py"", line 31, in x_main
result = llm_x(args, kwargs)
File ""/models/swift/swift/llm/sft.py"", line 76, in llm_sft
model, tokenizer = get_model_tokenizer(
File ""/models/swift/swift/llm/utils/model.py"", line 3200, in get_model_tokenizer
model, tokenizer = get_function(model_dir, torch_dtype, model_kwargs,
File ""/models/swift/swift/llm/utils/model.py"", line 2222, in get_model_tokenizer_qwen_chat
model, tokenizer = get_model_tokenizer_qwen(*args, kwargs)
File ""/models/swift/swift/llm/utils/model.py"", line 2118, in get_model_tokenizer_qwen
model, tokenizer = get_model_tokenizer_from_repo(
File ""/models/swift/swift/llm/utils/model.py"", line 519, in get_model_tokenizer_from_repo
model = automodel_class.from_pretrained(
File ""/opt/conda/lib/python3.8/site-packages/modelscope/utils/hf_util.py"", line 113, in from_pretrained
module_obj = module_class.from_pretrained(model_dir, model_args,
File ""/opt/conda/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py"", line 558, in from_pretrained
return model_class.from_pretrained(
File ""/opt/conda/lib/python3.8/site-packages/modelscope/utils/hf_util.py"", line 76, in from_pretrained
return ori_from_pretrained(cls, model_dir, model_args, kwargs)
File ""/opt/conda/lib/python3.8/site-packages/transformers/modeling_utils.py"", line 3589, in from_pretrained
dispatch_model(model, device_map_kwargs)
File ""/opt/conda/lib/python3.8/site-packages/accelerate/big_modeling.py"", line 428, in dispatch_model
raise ValueError(
ValueError: You are trying to offload the whole model to the disk. Please use the disk_offload
function instead. ModelScope中,以上代码有什么错误吗?"
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352