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
相关推荐
傅里叶4 小时前
iOS相机权限获取
flutter·ios
郑州光合科技余经理20 小时前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo12321 小时前
matlab画图工具
开发语言·matlab
dustcell.21 小时前
haproxy七层代理
java·开发语言·前端
norlan_jame21 小时前
C-PHY与D-PHY差异
c语言·开发语言
多恩Stone21 小时前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
QQ4022054961 天前
Python+django+vue3预制菜半成品配菜平台
开发语言·python·django
遥遥江上月1 天前
Node.js + Stagehand + Python 部署
开发语言·python·node.js
zhangkai1 天前
flutter存储知识点总结
flutter·ios
m0_531237171 天前
C语言-数组练习进阶
c语言·开发语言·算法