建议微调初学者们不要用web-ui训练

血的教训家人们

折磨了3天终于把模型训练起来了

如果你遇到这些问题(对于未启用这些功能摸不着头脑的初学者来说):

  1. 1.CUDA启动失败,但GPU可用(CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs above to fix your environment!
  2. If you cannot find any issues and suspect a bug, please open an issue with detals about your environment:)
  3. .FileExistsError: [WinError 183] 当文件已存在时,无法创建该文件。
  4. torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 44.00 MiB. GPU 0 has a total capacity of 22.00 GiB of which 17.97 GiB is free. Of the allocated memory 2.78 GiB is allocated by PyTorch, and 61.81 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management ...
  5. module ‘torch.library‘ has no attribute ‘register_fake‘
  6. 报错numpy必须<2.0.0
  7. 未检测到deepseepd(针对于初学者未启用的情况)
  8. loss一直等于0
  9. 加载“\lib\site-packages\torch\lib\shm.dll”或其依赖项之一时出错
  10. deepspeed安装报错 No module named ‘dskernels
  11. 没有经过微调的模型胡乱回答,乱码

如果你是初学者,对这些东西完全摸不着头脑,建议使用ms-swift的python代码进行训练!不要使用wei-ui!

最简示例:

# Experimental environment: RTX 2080 Ti 22G
# 22GB GPU memory
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

import torch

from swift.llm import (
    DatasetName, InferArguments, ModelType, SftArguments,
    infer_main, sft_main, app_ui_main, merge_lora_main
)

model_type = ModelType.qwen2_5_coder_7b_instruct # 改成你的模型的类型
sft_args = SftArguments(
    model_type=model_type,
    model_id_or_path="D:/LLaMA_Factory/Qwen/Qwen25Coder7B", # 改成你的本地模型路径
    train_dataset_sample=2000,
    dataset="D:/LLaMA_Factory/data/zh_INFJ_self_awareness.json", # 改成你的数据集路径
    output_dir='output')
result = sft_main(sft_args)
best_model_checkpoint = result['best_model_checkpoint']
print(f'best_model_checkpoint: {best_model_checkpoint}')
torch.cuda.empty_cache()

infer_args = InferArguments(
    ckpt_dir=best_model_checkpoint,
    load_dataset_config=True,
    show_dataset_sample=10)
# merge_lora_main(infer_args)
result = infer_main(infer_args)
torch.cuda.empty_cache()

app_ui_main(infer_args)

其实并没有想象中那么难对吧!

只需要更改这3个参数,小白都能把模型跑起来!

运行效果: 

7666fcb512a14ddd87ef63d468dbb496.png

注意!千万不要在VS code等IDE中运行代码,必须通过命令行运行py文件!否则会卡死!

python xxx.py

附:ms-swift官方文档 、训练微调教程

以上就是本文的全部内容

(本文是作者花了3天在本地机和云服务器、分别在windows10、windows11、windowsServer2022尝试,翻阅了数千个网站得出的经验)

(由于作者也是初学者,本文可能存在不足之处,请多多指出!)

### 关于 sd-webui-aki 项目的探索 `sd-webui-aki` 是围绕 Stable Diffusion Web UI 开发的一个特定分支或扩展项目。该项目通常由社区开发者维护,旨在增强原版 Stable Diffusion Web UI 的功能或提供定制化的用户体验。以下是关于 `sd-webui-aki` 及其相关插件和教程的信息: #### 1. **sd-webui-aki 项目概述** `sd-webui-aki` 是一个基于 Stable Diffusion Web UI 的自定义版本,主要目标是优化性能并增加额外的功能模块。此版本可能专注于提升图像生成的质量、速度以及用户界面的友好度[^2]。 #### 2. **常见功能与特性** 该版本继承了 Stable Diffusion Web UI 的核心功能(如 txt2img 和 img2img),同时还引入了一些独特的改进: - 更高效的模型加载机制。 - 增强的批处理能力。 - 自动化参数调整工具。 - 支持更多第三方插件集成。 这些特性的实现依赖于对底层代码结构的理解和技术栈的应用,例如 Python 脚本编写及 Gradio 框架的灵活运用。 #### 3. **安装与配置指南** 要使用 `sd-webui-aki`,需按照以下流程操作: ```bash git clone https://github.com/your-repo/sd-webui-aki.git cd sd-webui-aki pip install -r requirements.txt ./webui.sh ``` 上述命令会克隆仓库至本地环境,并完成必要的依赖项安装。启动脚本 (`webui.sh`) 将初始化服务端口,默认可通过浏览器访问地址 `http://localhost:7860` 进入图形化界面[^1]。 #### 4. **推荐插件列表** 为了进一步拓展功能边界,可考虑接入以下流行插件: - **ControlNet**: 实现条件控制下的图像生成过程,支持草图转绘等多种模式转换。 - **Lora Models**: 局部权重微调技术,允许快速适配个性化风格需求。 - **Deforum Animation**: 添加动态效果到静态图片序列中,形成流畅动画片段。 每款插件均附带详尽说明文档,便于初学者上手实践。 #### 5. **学习资源链接** 对于希望深入研究的朋友来说,这里整理了几份高质量的学习资料: - 官方 GitHub Repository 地址:https://github.com/your-repo/sd-webui-aki - 社区论坛讨论帖:https://community.example.com/posts/sd-webui-aki-tips/ - YouTube 教程视频合集:https://www.youtube.com/@sd_webui_aki_tutorials 以上内容涵盖了从基础知识讲解到高级技巧演示等多个层面的知识点。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值