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
相关推荐
天桥吴彦祖1 天前
判断iOS如何监听手机屏幕是否锁屏
ios
东坡肘子1 天前
SPI 加入 Apple,Swift 迈向自举 -- 肘子的 Swift 周报 #142
人工智能·swiftui·swift
敲代码的鱼2 天前
PDF 预览与签名批注写回 支持安卓 iOS 鸿蒙 UTS插件
android·前端·ios
时光足迹2 天前
uni-app 视频通话实战:康复师与患者视频问诊的 6 个致命 Bug 与解决方案
android·ios·uni-app
时光足迹2 天前
JPush UniApp UTS 插件完全参考手册:API、事件与厂商通道一网打尽
vue.js·ios·uni-app
时光足迹2 天前
极光推送全攻略(下):uni-app 代码实现与 iOS 排查实战
vue.js·ios·uni-app
时光足迹2 天前
极光推送全攻略(上):被iOS证书折磨了三天,我写了一份前端也能看懂的避坑指南
前端·ios·uni-app
编程范式3 天前
SwiftUI 中图片如何适配可用空间
ios
songgeb5 天前
启发式 UI 自动化:从线性剧本到每步读屏决策
ios·测试
东坡肘子8 天前
Swift 还让你 Excited 吗?-- 肘子的 Swift 周报 #141
人工智能·swiftui·swift