|
@@ -126,13 +126,13 @@ class ModelTrainer:
|
|
|
gpu_memory_utilization=0.6, # 0.6 # Reduce if out of memory
|
|
|
)
|
|
|
|
|
|
- # 将模型移动到设备上
|
|
|
- model = model.to_empty(device='cuda') # 使用 to_empty 而不是 to
|
|
|
+ # # 将模型移动到设备上
|
|
|
+ # model = model.to_empty(device='cuda') # 使用 to_empty 而不是 to
|
|
|
|
|
|
- # 初始化模型的权重
|
|
|
- for param in model.parameters():
|
|
|
- if param.is_meta:
|
|
|
- param.data = torch.randn_like(param) # 随机初始化
|
|
|
+ # # 初始化模型的权重
|
|
|
+ # for param in model.parameters():
|
|
|
+ # if param.is_meta:
|
|
|
+ # param.data = torch.randn_like(param) # 随机初始化
|
|
|
|
|
|
# 添加 LoRA 适配器
|
|
|
model = FastLanguageModel.get_peft_model(
|