SWIFT环境配置及大模型微调实践

SWIFT环境配置及大模型微调实践

SWIFT介绍参考: 这里

SWIFT环境配置

基础配置

bash 复制代码
conda create -n swift python=3.8

pip install ms-swift[all] -U

# 下载项目
git clone https://github.com/modelscope/swift

增量配置

如果是运行qwen-audio,需要安装ffmpeg

bash 复制代码
apt-get update
apt-get install ffmpeg

SWIFT Qwen_audio_chat大模型微调实践

也可以参考https://zhuanlan.zhihu.com/p/665300386

微调代码

bash 复制代码
cd swift/examples/pytorch/llm
nohup bash scripts/qwen_audio_chat/lora/sft.sh > qwen_audio_chat_sft_20240320.log &

问题1:

复制代码
   第一次跑,发现使用的是cpu,经过检查,发现pytorch版本对应的cuda版本较高,于是重新安装pytorch。
bash 复制代码
conda install --use-local pytorch-1.13.0-py3.8_cuda11.6_cudnn8.3.2_0.tar.bz2.tar.bz2
复制代码
    但是,在训练的时候会出现问题,如下。

问题2:

cannot import name 'LRScheduler' from 'torch.optim.lr_scheduler

问题定位

这个问题定位了很久,最后确定了是版本兼容问题。

具体的:pytorch 2.0.0以上的版本是LRScheduler,以下的版本是_LRScheduler。

解决方法

卸载掉之前安装的版本,重新手动安装pytorch 2.0.0以上版本。

手动安装pytorch

  1. 从该网址下载对应包:https://download.pytorch.org/whl/torch_stable.html
    (pytorch的版本号,cuda版本号,python版本号都对应好。)
  2. 使用pip手动安装
    pip install some_package.whl
相关推荐
HarderCoder11 小时前
iOS 知识积累第一弹:从 struct 到 APP 生命周期的全景复盘
ios
叽哥21 小时前
Flutter Riverpod上手指南
android·flutter·ios
HarderCoder2 天前
Swift 6 并发时代,如何优雅地“抢救”你的单例?
swift
zhangmeng2 天前
FlutterBoost在iOS26真机运行崩溃问题
flutter·app·swift
HarderCoder2 天前
SwiftUI 踩坑记:onAppear / task 不回调?90% 撞上了“空壳视图”!
swift
HarderCoder2 天前
@isolated(any) 深度解析:Swift 并发中的“隔离追踪器”
swift
大熊猫侯佩2 天前
桃花岛 Xcode 构建秘籍:Swift 中的 “Feature Flags” 心法
app·xcode·swift
用户092 天前
SwiftUI Charts 函数绘图完全指南
ios·swiftui·swift
YungFan2 天前
iOS26适配指南之UIColor
ios·swift
HarderCoder2 天前
Swift 6.2 新特性 `@concurrent` 完全导读
swift