From f13ccdb980ed613e3c0b51c0a4a1d5e51daf6c74 Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Sat, 19 Oct 2024 20:39:21 +0800
Subject: [PATCH 01/29] [doc] Camp4-InternVL
---
docs/L2/InternVL/README.md | 322 ++++++++++++++++++++++++++++++++
docs/L2/InternVL/easy_README.md | 162 ++++++++++++++++
docs/L2/InternVL/task.md | 14 ++
3 files changed, 498 insertions(+)
create mode 100644 docs/L2/InternVL/README.md
create mode 100644 docs/L2/InternVL/easy_README.md
create mode 100644 docs/L2/InternVL/task.md
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
new file mode 100644
index 000000000..a0347dc65
--- /dev/null
+++ b/docs/L2/InternVL/README.md
@@ -0,0 +1,322 @@
+# InternVL 部署微调实践
+
+
+
+# 0.开发机创建与使用
+
+登录浦语开发平台`studio.intern-ai.org.cn`,登录账号后,点击“创建开发机”。(也可以使用自己的机器实践)
+选择以下设置:
+
+- 开发机名称:你自己喜欢的名字
+- 镜像:Cuda12.2-conda
+- 资源配置:50% A100 * 1
+- 其余默认
+
+点击“立即创建”,成功后,可在“开发机”选栏中看到刚刚创建的开发机,可以点击“进入开发机”,利用terminal、code server进行开发。也可以使用本地的vscode通过“SSH链接”中的信息通过SSH链接进行开发。(强烈建议使用本地的vscode进行连接,前者可能有显示bug)
+
+
+
+后续在命令行中的操作可在进入开发机的terminal或者vscode的terminal界面中进行。代码的修改在vscode中进行。
+
+本地vscode连接服务器需要下载扩展:
+
+
+
+然后根据SSH连接的信息,填写ssh连接配置文件。
+
+
+
+上方马赛克处的数字,即为下面port处要填写的端口号。
+
+
+
+连接后,操作系统选择"linux",密码输入SSH连接界面给的密码即可。
+
+# 1.环境配置
+
+## 1.1.训练环境配置
+
+### 1.1.a.使用浦语开发机InternStudio
+
+进入预设的虚拟环境:
+
+```Bash
+conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
+```
+
+这个环境中预设了pytorch,因此安装会快一些。
+
+安装xtuner和timm,用-t的目的是为了把包下载在指定路径下,这样可以防止污染这个环境:
+
+```Bash
+pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
+```
+
+在本教程中后续提到训练环境均指"/root/share/pre_envs/pytorch2.3.1cu12.1"环境。
+
+### 1.1.b.使用自己的机器
+
+新建虚拟环境并进入:
+
+```Bash
+conda create --name xtuner-env python=3.10 -y
+conda activate xtuner-env
+```
+
+"xtuner-env"为训练环境名,可以根据个人喜好设置,在本教程中后续提到训练环境均指"xtuner-env"环境。
+
+安装与deepspeed集成的xtuner和相关包:
+
+```Bash
+pip install -U 'xtuner[deepspeed]' timm==1.0.9
+```
+
+训练环境既为安装成功。
+
+## 1.2.推理环境配置
+
+配置推理所需环境:
+
+```Bash
+conda create -n lmdeploy python=3.8 -y
+conda activate lmdeploy
+pip install lmdeploy gradio
+```
+
+"lmdeploy"为推理使用环境名。
+
+# 2.LMDeploy部署
+
+## 2.1.LMDeploy基本用法介绍
+
+我们主要通过`pipeline.chat` 接口来构造多轮对话管线,核心代码为:
+
+```Python
+## 1.导入相关依赖包
+from lmdeploy import pipeline, TurbomindEngineConfig, GenerationConfig
+from lmdeploy.vl import load_image
+
+## 2.使用你的模型初始化推理管线
+model_path = "your_model_path"
+pipe = pipeline(model_path,
+ backend_config=TurbomindEngineConfig(session_len=8192))
+
+## 3.读取图片(此处使用PIL读取也行)
+image = load_image('your_image_path')
+
+## 4.配置推理参数
+gen_config = GenerationConfig(top_p=0.8, temperature=0.8)
+## 5.利用 pipeline.chat 接口 进行对话,需传入生成参数
+sess = pipe.chat(('describe this image', image), gen_config=gen_config)
+print(sess.response.text)
+## 6.之后的对话轮次需要传入之前的session,以告知模型历史上下文
+sess = pipe.chat('What is the woman doing?', session=sess, gen_config=gen_config)
+print(sess.response.text)
+```
+
+lmdeploy推理的核心代码如上注释所述。
+
+## 2.2.网页应用部署体验
+
+我们可以使用UI界面先体验与InternVL对话:
+
+拉取本教程的github仓库(https://github.com/Control-derek/InternVL2-Tutorial.git):
+
+```Bash
+git clone https://github.com/Control-derek/InternVL2-Tutorial.git
+cd InternVL2-Tutorial
+```
+
+demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
+
+
+
+启动demo:
+
+```Bash
+conda activate lmdeploy
+python demo.py
+```
+
+上述命令请在vscode下运行,因为vscode自带端口转发,可以把部署在服务器上的网页服务转发到本地。
+
+启动后,CTRL+鼠标左键点进这个链接或者复制链接到浏览器
+
+
+
+会看到如下界面:
+
+点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
+
+
+
+## 2.3.可能遇到棘手bug的解决
+
+如果输入多张图,或者开多轮对话时报错:
+
+
+
+可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
+
+
+
+屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
+
+
+
+# 3.Xtuner微调实践
+
+## 3.1.准备基本配置文件
+
+在InternStudio开发机的`/root/xtuner`路径下,即为开机自带的xtuner,先进入工作目录并激活训练环境:
+
+```Bash
+cd root/xtuner
+conda activate xtuner-env # 或者是你自命名的训练环境
+```
+
+原始internvl的微调配置文件在路径`./xtuner/configs/internvl/v2`下,假设上面克隆的仓库在/`root/InternVL2-Tutorial`,复制配置文件到目标目录下:
+
+```Bash
+cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune_food.py /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py
+```
+
+## 3.2.配置文件参数解读
+
+在第一部分的设置中,有如下参数:
+
+- `path`: 需要微调的模型路径,在InternStudio环境下,无需修改。
+- `data_root`: 数据集所在路径。
+- `data_path`: 训练数据文件路径。
+- `image_folder`: 训练图像根路径。
+- `prompt_temple`: 配置模型训练时使用的聊天模板、系统提示等。使用与模型对应的即可,此处无需修改。
+- `max_length`: 训练数据每一条最大token数。
+- `batch_size`: 训练批次大小,可以根据显存大小调整。
+- `accumulative_counts`: 梯度累积的步数,用于模拟较大的batch_size,在显存有限的情况下,提高训练稳定性。
+- `dataloader_num_workers`: 指定数据集加载时子进程的个数。
+- `max_epochs`:训练轮次。
+- `optim_type`:优化器类型。
+- `lr`: 学习率
+- `betas`: Adam优化器的beta1, beta2
+- `weight_decay`: 权重衰减,防止训练过拟合用
+- `max_norm`: 梯度裁剪时的梯度最大值
+- `warmup_ratio`: 预热比例,前多少的数据训练时,学习率将会逐步增加。
+- `save_steps`: 多少步存一次checkpoint
+- `save_total_limit`: 最多保存几个checkpoint,设为-1即无限制
+
+
+
+LoRA相关参数:
+
+
+
+- `r`: 低秩矩阵的秩,决定了低秩矩阵的维度。
+- `lora_alpha` 缩放因子,用于调整低秩矩阵的权重。
+- `lora_dropout` dropout 概率,以防止过拟合。
+
+如果想断点重训,可以在最下面传入参数:
+
+
+
+把这里的`load_from`传入你想要载入的checkpoint,并设置`resume=True`即可断点重续。
+
+## 3.3.数据集下载
+
+### 3.3.a.通过huggingface下载
+
+有能力的同学,建议去huggingface下载此数据集:https://huggingface.co/datasets/lyan62/FoodieQA。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
+
+由于申请的与huggingface账号绑定,需要在命令行登录huggingface后直接在服务器上下载:
+
+```Bash
+huggingface-cli login
+```
+
+然后在这里输入huggingface的具有`read`权限的token即可成功登录。
+
+
+
+再使用命令行下载数据集:
+
+```Bash
+huggingface-cli download --repo-type dataset --resume-download lyan62/FoodieQA --local-dir /root/huggingface/FoodieQA --local-dir-use-symlinks False
+```
+
+如果觉得上述过程麻烦,可以用浏览器下载后,再上传服务器即可😊
+
+由于原始数据集格式不符合微调需要格式,需要处理方可使用,在`InternVL2-Tutorial`下,运行:
+
+```Bash
+python process_food.py
+```
+
+即可把数据处理为xtuner所需格式。注意查看`input_path`和`output_path`变量与自己下载路径的区别。
+
+### 3.3.b.通过网盘下载
+
+由于该数据集即需要登录huggingface的方法,又需要申请,下完还需要自己处理,因此我把处理后的文件放在网盘里了🤗。网盘不提供原始数据文件,仅提供完成本课程后续内容所需文件:
+
+> 链接:https://pan.quark.cn/s/ccd8e23bdeca
+>
+> 提取码:VF45
+
+## 3.4.开始微调🐱🏍
+
+运行命令,开始微调(如果是利用浦语开发机配置的环境,需要先运行第一行,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包,在自己机器用非pip install -t安装的可以忽视第一行):
+
+```Bash
+export PYTHONPATH=/root/internvl_course:$PYTHONPATH # 让python能找到第一步安装在其他路径下的包
+xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_zero2
+```
+
+看到有日志输出,即为启动成功:
+
+
+
+如果报错如:keyerror或者Filenotfound之类的,可能是xtuner没识别到新写的配置文件,需要指定配置文件的完整路径:
+
+```Bash
+xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py --deepspeed deepspeed_zero2
+```
+
+把`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`换成自己配置文件的路径即可。
+
+微调后,把模型checkpoint的格式转化为便于测试的格式:
+
+```Bash
+python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py ./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/iter_640.pth ./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/lr35_ep10/
+```
+
+如果修改了超参数,`iter_xxx.pth`需要修改为对应的想要转的checkpoint。 `./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/lr35_ep10/`为转换后的模型checkpoint保存的路径。
+
+# 4.与AI美食家玩耍🎉
+
+修改MODEL_PATH为刚刚转换后保存的模型路径:
+
+
+
+就像在第2节中做的那样,启动网页应用:
+
+```Bash
+cd /root/InternVL2-Tutorial
+conda activate lmdeploy
+python demo.py
+```
+
+部分case展示:
+
+微调前,把肠粉错认成饺子,微调后,正确识别:
+
+
+
+
+
+微调前,不认识“锅包又”,微调后,可以正确识别:
+
+
+
+
+
+
恭喜你完成了本课程🎉🎊
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index a455eb661..1c8145a6b 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -50,7 +50,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-
+
启动demo:
@@ -63,23 +63,23 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-
+
## 2.2.多图/轮对话可能会报错
如果输入多张图,或者开多轮对话时报错:
-
+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-
+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-
+
-# 3.Xtuner微调实践
+# 3.XTuner微调实践
## 3.1.准备配置文件
@@ -103,7 +103,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-
+
再使用命令行下载数据集:
@@ -117,7 +117,7 @@ huggingface-cli download --repo-type dataset --resume-download lyan62/FoodieQA -
python process_food.py
```
-即可把数据处理为xtuner所需格式。注意查看`input_path`和`output_path`变量与自己下载路径的区别。
+即可把数据处理为XTuner所需格式。注意查看`input_path`和`output_path`变量与自己下载路径的区别。
### 3.3.b.通过网盘下载
@@ -136,7 +136,7 @@ xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lo
`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`为自己配置文件的路径。看到有日志输出,即为启动成功:
-
+
微调后,把模型checkpoint的格式转化为便于测试的格式:
@@ -150,7 +150,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-
+
就像在第2节中做的那样,启动网页应用:
diff --git a/docs/L2/InternVL/task.md b/docs/L2/InternVL/task.md
index 1f2a8e473..042fea663 100644
--- a/docs/L2/InternVL/task.md
+++ b/docs/L2/InternVL/task.md
@@ -11,4 +11,4 @@
- 闯关作业总共分为一个任务,一个任务完成视作闯关成功。
- 请将作业发布到知乎、CSDN等任一社交媒体,将作业链接提交到以下问卷,助教老师批改后将获得 100 算力点奖励!!!
-- 提交地址:
\ No newline at end of file
+- 提交地址:https://aicarrier.feishu.cn/share/base/form/shrcnUqshYPt7MdtYRTRpkiOFJd
\ No newline at end of file
From 624933c70890ef54565572a9090ed45d5545de6a Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Sun, 20 Oct 2024 22:34:12 +0800
Subject: [PATCH 03/29] [doc] Camp4-InternVL_1020
---
docs/L2/InternVL/README.md | 25 ++++++++++++++++++------
docs/L2/InternVL/easy_README.md | 34 ++++++++++++++++++++++++---------
2 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 7ec5edc81..236db1de0 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -221,6 +221,23 @@ LoRA相关参数:
## 3.3.数据集下载
+我们采用的是FoodieQA数据集,这篇文章中了2024EMNLP的主会,其引用信息如下:
+
+```
+@article{li2024foodieqa,
+ title={FoodieQA: A Multimodal Dataset for Fine-Grained Understanding of Chinese Food Culture},
+ author={Li, Wenyan and Zhang, Xinyu and Li, Jiaang and Peng, Qiwei and Tang, Raphael and Zhou, Li and Zhang, Weijia and Hu, Guimin and Yuan, Yifei and S{\o}gaard, Anders and others},
+ journal={arXiv preprint arXiv:2406.11030},
+ year={2024}
+}
+```
+
+FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集。它包含了大量关于食物的图片和问题,帮助多模态大模型更好地理解不同地区的饮食习惯和文化特色。这个数据集的推出,让我们能够更深入地探索和理解食物背后的文化意义。
+
+根据下载方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
+
+
+
### 3.3.a.通过huggingface下载
有能力的同学,建议去huggingface下载此数据集:https://huggingface.co/datasets/lyan62/FoodieQA。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
@@ -251,13 +268,9 @@ python process_food.py
即可把数据处理为XTuner所需格式。注意查看`input_path`和`output_path`变量与自己下载路径的区别。
-### 3.3.b.通过网盘下载
-
-由于该数据集即需要登录huggingface的方法,又需要申请,下完还需要自己处理,因此我把处理后的文件放在网盘里了🤗。网盘不提供原始数据文件,仅提供完成本课程后续内容所需文件:
+### 3.3.b.利用share目录下处理好的数据集
-> 链接:https://pan.quark.cn/s/ccd8e23bdeca
->
-> 提取码:VF45
+由于该数据集即需要登录huggingface的方法,又需要申请,下完还需要自己处理,因此我把处理后的文件放在开发机的`/root/share/datasets/FoodieQA`路径下了。
## 3.4.开始微调🐱🏍
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 1c8145a6b..c19fb1b82 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -92,10 +92,28 @@ cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune
```
## 3.2.数据集下载
+我们采用的是FoodieQA数据集,这篇文章中了2024EMNLP的主会,其引用信息如下:
-### 3.3.a.通过huggingface下载
+```
+@article{li2024foodieqa,
+ title={FoodieQA: A Multimodal Dataset for Fine-Grained Understanding of Chinese Food Culture},
+ author={Li, Wenyan and Zhang, Xinyu and Li, Jiaang and Peng, Qiwei and Tang, Raphael and Zhou, Li and Zhang, Weijia and Hu, Guimin and Yuan, Yifei and S{\o}gaard, Anders and others},
+ journal={arXiv preprint arXiv:2406.11030},
+ year={2024}
+}
+```
+
+FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集。它包含了大量关于食物的图片和问题,帮助多模态大模型更好地理解不同地区的饮食习惯和文化特色。这个数据集的推出,让我们能够更深入地探索和理解食物背后的文化意义。
+
+根据下载方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
+
+
-进入该页面https://huggingface.co/datasets/lyan62/FoodieQA申请通过后,在命令行登录huggingface后直接在服务器上下载:
+### 3.2.a.通过huggingface下载
+
+有能力的同学,建议去huggingface下载此数据集:https://huggingface.co/datasets/lyan62/FoodieQA。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
+
+由于申请的与huggingface账号绑定,需要在命令行登录huggingface后直接在服务器上下载:
```Bash
huggingface-cli login
@@ -111,6 +129,8 @@ huggingface-cli login
huggingface-cli download --repo-type dataset --resume-download lyan62/FoodieQA --local-dir /root/huggingface/FoodieQA --local-dir-use-symlinks False
```
+如果觉得上述过程麻烦,可以用浏览器下载后,再上传服务器即可😊
+
由于原始数据集格式不符合微调需要格式,需要处理方可使用,在`InternVL2-Tutorial`下,运行:
```Bash
@@ -119,15 +139,11 @@ python process_food.py
即可把数据处理为XTuner所需格式。注意查看`input_path`和`output_path`变量与自己下载路径的区别。
-### 3.3.b.通过网盘下载
-
-由于该数据集即需要登录huggingface的方法,又需要申请,下完还需要自己处理,因此我把处理后的文件放在网盘里了🤗。网盘不提供原始数据文件,仅提供完成本课程后续内容所需文件:
+### 3.2.b.利用share目录下处理好的数据集
-> 链接:https://pan.quark.cn/s/ccd8e23bdeca
->
-> 提取码:VF45
+由于该数据集即需要登录huggingface的方法,又需要申请,下完还需要自己处理,因此我把处理后的文件放在开发机的`/root/share/datasets/FoodieQA`路径下了。
-## 3.4.开始微调🐱🏍
+## 3.3.开始微调🐱🏍
```Bash
export PYTHONPATH=/root/internvl_course:$PYTHONPATH # 让python能找到第一步安装在其他路径下的包
From 2c6d732f0eb4777638a7595bcbaaefc67661aed0 Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Sun, 20 Oct 2024 22:45:30 +0800
Subject: [PATCH 04/29] [doc] Camp4-InternVL_1020
---
docs/L2/InternVL/README.md | 2 +-
docs/L2/InternVL/easy_README.md | 14 +-------------
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 236db1de0..a5a3cb9ba 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -234,7 +234,7 @@ LoRA相关参数:
FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集。它包含了大量关于食物的图片和问题,帮助多模态大模型更好地理解不同地区的饮食习惯和文化特色。这个数据集的推出,让我们能够更深入地探索和理解食物背后的文化意义。
-根据下载方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
+**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:

diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index c19fb1b82..0d7efe21b 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -8,8 +8,6 @@
## 1.1.训练环境配置
-### 1.1.a.使用浦语开发机InternStudio
-
进入预设的虚拟环境,安装相关包:
```Bash
@@ -17,16 +15,6 @@ conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
```
-### 1.1.b.使用自己的机器
-
-新建虚拟环境并进入:
-
-```Bash
-conda create --name xtuner-env python=3.10 -y
-conda activate xtuner-env
-pip install -U 'xtuner[deepspeed]' timm==1.0.9
-```
-
## 1.2.推理环境配置
配置推理所需环境:
@@ -105,7 +93,7 @@ cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune
FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集。它包含了大量关于食物的图片和问题,帮助多模态大模型更好地理解不同地区的饮食习惯和文化特色。这个数据集的推出,让我们能够更深入地探索和理解食物背后的文化意义。
-根据下载方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
+**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:

From 6e2010c266fa9bc08b62681850b8add625b2a22f Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Sun, 20 Oct 2024 22:48:55 +0800
Subject: [PATCH 05/29] [doc] Camp4-InternVL_1020
---
docs/L2/InternVL/README.md | 6 ++++++
docs/L2/InternVL/easy_README.md | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index a5a3cb9ba..3e5c448e0 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -52,6 +52,12 @@ conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
```
+每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包(同一个终端下只需运行一次):
+```Bash
+export PYTHONPATH=/root/internvl_course:$PYTHONPATH
+```
+
+
在本教程中后续提到训练环境均指"/root/share/pre_envs/pytorch2.3.1cu12.1"环境。
### 1.1.b.使用自己的机器
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 0d7efe21b..57bfeca27 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -14,6 +14,10 @@
conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
```
+每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包(同一个终端下只需运行一次):
+```Bash
+export PYTHONPATH=/root/internvl_course:$PYTHONPATH
+```
## 1.2.推理环境配置
From d8cd2924a39756ec2ef0314a771b20e75db3a6b7 Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Mon, 21 Oct 2024 15:05:23 +0800
Subject: [PATCH 06/29] [doc] Camp4-InternVL_1021
---
docs/L2/InternVL/README.md | 78 ++++++++++++++++++++++++++-------
docs/L2/InternVL/easy_README.md | 38 ++++++++++++----
2 files changed, 90 insertions(+), 26 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 3e5c448e0..9438936f2 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -1,6 +1,8 @@
# InternVL 部署微调实践
+

+
# 0.开发机创建与使用
@@ -14,21 +16,29 @@
点击“立即创建”,成功后,可在“开发机”选栏中看到刚刚创建的开发机,可以点击“进入开发机”,利用terminal、code server进行开发。也可以使用本地的vscode通过“SSH链接”中的信息通过SSH链接进行开发。(强烈建议使用本地的vscode进行连接,前者可能有显示bug)
+

+
后续在命令行中的操作可在进入开发机的terminal或者vscode的terminal界面中进行。代码的修改在vscode中进行。
本地vscode连接服务器需要下载扩展:
+

+
然后根据SSH连接的信息,填写ssh连接配置文件。
+

+
上方马赛克处的数字,即为下面port处要填写的端口号。
+

+
连接后,操作系统选择"linux",密码输入SSH连接界面给的密码即可。
@@ -135,7 +145,9 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-
+
+

+
启动demo:
@@ -148,27 +160,37 @@ python demo.py
启动后,CTRL+鼠标左键点进这个链接或者复制链接到浏览器
-
+
+

+
会看到如下界面:
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-
+
+

+
## 2.3.可能遇到棘手bug的解决
如果输入多张图,或者开多轮对话时报错:
-
+
+

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-
+
+

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-
+
+

+
# 3.XTuner微调实践
## 3.1.准备基本配置文件
@@ -209,11 +231,15 @@ cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune
- `save_steps`: 多少步存一次checkpoint
- `save_total_limit`: 最多保存几个checkpoint,设为-1即无限制
-
+
+

+
LoRA相关参数:
-
+
+

+
- `r`: 低秩矩阵的秩,决定了低秩矩阵的维度。
- `lora_alpha` 缩放因子,用于调整低秩矩阵的权重。
@@ -221,7 +247,9 @@ LoRA相关参数:
如果想断点重训,可以在最下面传入参数:
-
+
+

+
把这里的`load_from`传入你想要载入的checkpoint,并设置`resume=True`即可断点重续。
@@ -242,7 +270,9 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-
+
+

+
### 3.3.a.通过huggingface下载
@@ -256,7 +286,9 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-
+
+

+
再使用命令行下载数据集:
@@ -289,7 +321,9 @@ xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_z
看到有日志输出,即为启动成功:
-
+
+

+
如果报错如:keyerror或者Filenotfound之类的,可能是XTuner没识别到新写的配置文件,需要指定配置文件的完整路径:
@@ -311,7 +345,9 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-
+
+

+
就像在第2节中做的那样,启动网页应用:
@@ -325,16 +361,24 @@ python demo.py
微调前,把肠粉错认成饺子,微调后,正确识别:
-
+
+

+
-
+
+

+
微调前,不认识“锅包又”,微调后,可以正确识别:
-
+
+

+
-
+
+

+
恭喜你完成了本课程🎉🎊
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 57bfeca27..c772fbb08 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -1,6 +1,8 @@
# InternVL 部署微调实践
+

+
**本文档为有一定基础可以快速上手的同学准备,比`README.md`的说明更加简洁。**
@@ -42,7 +44,9 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-
+
+

+
启动demo:
@@ -55,21 +59,29 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-
+
+

+
## 2.2.多图/轮对话可能会报错
如果输入多张图,或者开多轮对话时报错:
-
+
+

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-
+
+

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-
+
+

+
# 3.XTuner微调实践
@@ -99,7 +111,9 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-
+
+

+
### 3.2.a.通过huggingface下载
@@ -113,7 +127,9 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-
+
+

+
再使用命令行下载数据集:
@@ -144,7 +160,9 @@ xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lo
`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`为自己配置文件的路径。看到有日志输出,即为启动成功:
-
+
+

+
微调后,把模型checkpoint的格式转化为便于测试的格式:
@@ -158,7 +176,9 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-
+
+

+
就像在第2节中做的那样,启动网页应用:
From baadd9978d90434ce9934c4582d884f109635ba0 Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Mon, 21 Oct 2024 15:21:46 +0800
Subject: [PATCH 07/29] [doc] Camp4-InternVL_1021
---
docs/L2/InternVL/README.md | 42 ++++++++++++++++-----------------
docs/L2/InternVL/easy_README.md | 18 +++++++-------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 9438936f2..581b0979d 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -17,7 +17,7 @@
点击“立即创建”,成功后,可在“开发机”选栏中看到刚刚创建的开发机,可以点击“进入开发机”,利用terminal、code server进行开发。也可以使用本地的vscode通过“SSH链接”中的信息通过SSH链接进行开发。(强烈建议使用本地的vscode进行连接,前者可能有显示bug)
-

+
后续在命令行中的操作可在进入开发机的terminal或者vscode的terminal界面中进行。代码的修改在vscode中进行。
@@ -25,19 +25,19 @@
本地vscode连接服务器需要下载扩展:
-

+
然后根据SSH连接的信息,填写ssh连接配置文件。
-

+
上方马赛克处的数字,即为下面port处要填写的端口号。
-

+
连接后,操作系统选择"linux",密码输入SSH连接界面给的密码即可。
@@ -146,7 +146,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-

+
启动demo:
@@ -161,7 +161,7 @@ python demo.py
启动后,CTRL+鼠标左键点进这个链接或者复制链接到浏览器
-

+
会看到如下界面:
@@ -169,7 +169,7 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-

+
## 2.3.可能遇到棘手bug的解决
@@ -177,19 +177,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-

+
# 3.XTuner微调实践
@@ -232,13 +232,13 @@ cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune
- `save_total_limit`: 最多保存几个checkpoint,设为-1即无限制
-

+
LoRA相关参数:
-

+
- `r`: 低秩矩阵的秩,决定了低秩矩阵的维度。
@@ -248,7 +248,7 @@ LoRA相关参数:
如果想断点重训,可以在最下面传入参数:
-

+
把这里的`load_from`传入你想要载入的checkpoint,并设置`resume=True`即可断点重续。
@@ -271,7 +271,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-

+
### 3.3.a.通过huggingface下载
@@ -287,7 +287,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-

+
再使用命令行下载数据集:
@@ -322,7 +322,7 @@ xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_z
看到有日志输出,即为启动成功:
-

+
如果报错如:keyerror或者Filenotfound之类的,可能是XTuner没识别到新写的配置文件,需要指定配置文件的完整路径:
@@ -346,7 +346,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-

+
就像在第2节中做的那样,启动网页应用:
@@ -362,22 +362,22 @@ python demo.py
微调前,把肠粉错认成饺子,微调后,正确识别:
-

+
-

+
微调前,不认识“锅包又”,微调后,可以正确识别:
-

+
-

+
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index c772fbb08..79efec80c 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -45,7 +45,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-

+
启动demo:
@@ -60,7 +60,7 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-

+
## 2.2.多图/轮对话可能会报错
@@ -68,19 +68,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-

+
# 3.XTuner微调实践
@@ -112,7 +112,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-

+
### 3.2.a.通过huggingface下载
@@ -128,7 +128,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-

+
再使用命令行下载数据集:
@@ -161,7 +161,7 @@ xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lo
`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`为自己配置文件的路径。看到有日志输出,即为启动成功:
-

+
微调后,把模型checkpoint的格式转化为便于测试的格式:
@@ -177,7 +177,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-

+
就像在第2节中做的那样,启动网页应用:
From 7eccd12cdda5dde98b1984c3f2e3108024baaa92 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:23:22 +0800
Subject: [PATCH 08/29] Update README.md
---
docs/L2/InternVL/README.md | 46 +++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 581b0979d..7d0127673 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -1,7 +1,7 @@
# InternVL 部署微调实践
-

+
# 0.开发机创建与使用
@@ -17,7 +17,7 @@
点击“立即创建”,成功后,可在“开发机”选栏中看到刚刚创建的开发机,可以点击“进入开发机”,利用terminal、code server进行开发。也可以使用本地的vscode通过“SSH链接”中的信息通过SSH链接进行开发。(强烈建议使用本地的vscode进行连接,前者可能有显示bug)
-

+
后续在命令行中的操作可在进入开发机的terminal或者vscode的terminal界面中进行。代码的修改在vscode中进行。
@@ -25,19 +25,19 @@
本地vscode连接服务器需要下载扩展:
-

+
然后根据SSH连接的信息,填写ssh连接配置文件。
-

+
上方马赛克处的数字,即为下面port处要填写的端口号。
-

+
连接后,操作系统选择"linux",密码输入SSH连接界面给的密码即可。
@@ -146,7 +146,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-

+
启动demo:
@@ -161,7 +161,7 @@ python demo.py
启动后,CTRL+鼠标左键点进这个链接或者复制链接到浏览器
-

+
会看到如下界面:
@@ -169,7 +169,7 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-

+
## 2.3.可能遇到棘手bug的解决
@@ -177,19 +177,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-

+
# 3.XTuner微调实践
@@ -232,13 +232,13 @@ cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune
- `save_total_limit`: 最多保存几个checkpoint,设为-1即无限制
-

+
LoRA相关参数:
-

+
- `r`: 低秩矩阵的秩,决定了低秩矩阵的维度。
@@ -248,7 +248,7 @@ LoRA相关参数:
如果想断点重训,可以在最下面传入参数:
-

+
把这里的`load_from`传入你想要载入的checkpoint,并设置`resume=True`即可断点重续。
@@ -271,7 +271,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-

+
### 3.3.a.通过huggingface下载
@@ -287,7 +287,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-

+
再使用命令行下载数据集:
@@ -322,7 +322,7 @@ xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_z
看到有日志输出,即为启动成功:
-

+
如果报错如:keyerror或者Filenotfound之类的,可能是XTuner没识别到新写的配置文件,需要指定配置文件的完整路径:
@@ -346,7 +346,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-

+
就像在第2节中做的那样,启动网页应用:
@@ -362,24 +362,24 @@ python demo.py
微调前,把肠粉错认成饺子,微调后,正确识别:
-

+
-

+
微调前,不认识“锅包又”,微调后,可以正确识别:
-

+
-

+
恭喜你完成了本课程🎉🎊
-
\ No newline at end of file
+
From c9ca5ca5f688cb45a654e2e41ff942170c380fc6 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:25:07 +0800
Subject: [PATCH 09/29] Update README.md
---
docs/L2/InternVL/README.md | 44 +++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 7d0127673..48fa4d769 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -1,6 +1,6 @@
# InternVL 部署微调实践
-
+
@@ -16,7 +16,7 @@
点击“立即创建”,成功后,可在“开发机”选栏中看到刚刚创建的开发机,可以点击“进入开发机”,利用terminal、code server进行开发。也可以使用本地的vscode通过“SSH链接”中的信息通过SSH链接进行开发。(强烈建议使用本地的vscode进行连接,前者可能有显示bug)
-
+
@@ -24,19 +24,19 @@
本地vscode连接服务器需要下载扩展:
-
+
然后根据SSH连接的信息,填写ssh连接配置文件。
-
+
上方马赛克处的数字,即为下面port处要填写的端口号。
-
+
@@ -145,7 +145,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-
+
@@ -160,7 +160,7 @@ python demo.py
启动后,CTRL+鼠标左键点进这个链接或者复制链接到浏览器
-
+
@@ -168,7 +168,7 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-
+
@@ -176,19 +176,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-
+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-
+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-
+
# 3.XTuner微调实践
@@ -231,13 +231,13 @@ cp /root/InternVL2-Tutorial/xtuner_config/internvl_v2_internlm2_2b_lora_finetune
- `save_steps`: 多少步存一次checkpoint
- `save_total_limit`: 最多保存几个checkpoint,设为-1即无限制
-
+
LoRA相关参数:
-
+
@@ -247,7 +247,7 @@ LoRA相关参数:
如果想断点重训,可以在最下面传入参数:
-
+
@@ -270,7 +270,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-
+
@@ -286,7 +286,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-
+
@@ -321,7 +321,7 @@ xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_z
看到有日志输出,即为启动成功:
-
+
@@ -345,7 +345,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-
+
@@ -361,22 +361,22 @@ python demo.py
微调前,把肠粉错认成饺子,微调后,正确识别:
-
+
-
+
微调前,不认识“锅包又”,微调后,可以正确识别:
-
+
-
+
From a4958a8480519a594b2a0dd4739d8c787a4ee71a Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:25:50 +0800
Subject: [PATCH 10/29] Update README.md
---
docs/L2/InternVL/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 48fa4d769..41a69f96a 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -169,7 +169,7 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-

+
## 2.3.可能遇到棘手bug的解决
From 42e0b7ee27eb409252a8e3538f78e025f38ecd83 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:26:39 +0800
Subject: [PATCH 11/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 79efec80c..6aa0aea2d 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -1,6 +1,6 @@
# InternVL 部署微调实践
-
+
@@ -44,7 +44,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-
+
@@ -59,27 +59,27 @@ python demo.py
点击**Start Chat**即可开始聊天,下方**食物快捷栏**可以快速输入图片,**输入示例**可以快速输入文字。输入完毕后,按enter键即可发送。
-
-

+
+
## 2.2.多图/轮对话可能会报错
如果输入多张图,或者开多轮对话时报错:
-
+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-
+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-
+
@@ -111,7 +111,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-
+
@@ -127,7 +127,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-
+
@@ -160,7 +160,7 @@ xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lo
`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`为自己配置文件的路径。看到有日志输出,即为启动成功:
-
+
@@ -176,7 +176,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-
+
From a622a26b2b850b8f329392ac5af25e72a07b53fd Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:27:37 +0800
Subject: [PATCH 12/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 6aa0aea2d..9bfe98610 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -45,7 +45,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-

+
启动demo:
@@ -68,19 +68,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-

+
# 3.XTuner微调实践
@@ -112,7 +112,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-

+
### 3.2.a.通过huggingface下载
@@ -128,7 +128,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-

+
再使用命令行下载数据集:
@@ -161,7 +161,7 @@ xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lo
`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`为自己配置文件的路径。看到有日志输出,即为启动成功:
-

+
微调后,把模型checkpoint的格式转化为便于测试的格式:
@@ -177,7 +177,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-

+
就像在第2节中做的那样,启动网页应用:
From ebd8eb0066050eeaa719631b0f18feb07501963c Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:28:12 +0800
Subject: [PATCH 13/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 9bfe98610..e0a5ab0c5 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -45,7 +45,7 @@ cd InternVL2-Tutorial
demo.py文件中,MODEL_PATH处传入InternVL2-2B的路径,如果使用的是InternStudio的开发机则无需修改,否则改为模型路径。
-

+
启动demo:
@@ -68,19 +68,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-

+
# 3.XTuner微调实践
@@ -112,7 +112,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
**可以通过`3.2.a.`和`3.2.b.`两种方式获取数据集**,根据获取方式的不同,可能需要修改配置文件中的`data_root`变量为你数据集的路径:
-

+
### 3.2.a.通过huggingface下载
@@ -128,7 +128,7 @@ huggingface-cli login
然后在这里输入huggingface的具有`read`权限的token即可成功登录。
-

+
再使用命令行下载数据集:
@@ -161,7 +161,7 @@ xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lo
`/root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py`为自己配置文件的路径。看到有日志输出,即为启动成功:
-

+
微调后,把模型checkpoint的格式转化为便于测试的格式:
@@ -177,7 +177,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-

+
就像在第2节中做的那样,启动网页应用:
From 4d4978717780f31448827040a05fd0fb9f92a212 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:31:20 +0800
Subject: [PATCH 14/29] Update README.md
---
docs/L2/InternVL/README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 41a69f96a..2660ad980 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -17,7 +17,7 @@
点击“立即创建”,成功后,可在“开发机”选栏中看到刚刚创建的开发机,可以点击“进入开发机”,利用terminal、code server进行开发。也可以使用本地的vscode通过“SSH链接”中的信息通过SSH链接进行开发。(强烈建议使用本地的vscode进行连接,前者可能有显示bug)
-

+
后续在命令行中的操作可在进入开发机的terminal或者vscode的terminal界面中进行。代码的修改在vscode中进行。
@@ -161,7 +161,7 @@ python demo.py
启动后,CTRL+鼠标左键点进这个链接或者复制链接到浏览器
-

+
会看到如下界面:
@@ -177,19 +177,19 @@ python demo.py
如果输入多张图,或者开多轮对话时报错:
-

+
可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
-

+
屏蔽报错的engine.py的126,127行,添加`self._create_event_loop_task()`后,即可解决上面报错。
-

+
# 3.XTuner微调实践
@@ -322,7 +322,7 @@ xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_z
看到有日志输出,即为启动成功:
-

+
如果报错如:keyerror或者Filenotfound之类的,可能是XTuner没识别到新写的配置文件,需要指定配置文件的完整路径:
@@ -346,7 +346,7 @@ python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/intern
修改MODEL_PATH为刚刚转换后保存的模型路径:
-

+
就像在第2节中做的那样,启动网页应用:
From 0ec62a0f5efb244e93e3e1439cc5c6fe232df8c3 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:17:51 +0800
Subject: [PATCH 15/29] Update README.md
---
docs/L2/InternVL/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 2660ad980..562784d37 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -94,7 +94,7 @@ pip install -U 'xtuner[deepspeed]' timm==1.0.9
配置推理所需环境:
```Bash
-conda create -n lmdeploy python=3.8 -y
+conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
pip install lmdeploy gradio
```
From 9627439d7f0019b54b1b89e45211400493e155d7 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:18:02 +0800
Subject: [PATCH 16/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index e0a5ab0c5..67a6feb7d 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -26,7 +26,7 @@ export PYTHONPATH=/root/internvl_course:$PYTHONPATH
配置推理所需环境:
```Bash
-conda create -n lmdeploy python=3.8 -y
+conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
pip install lmdeploy gradio
```
From 5b8f90629b69157c121e13e167b9b8dbec53ba77 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:18:38 +0800
Subject: [PATCH 17/29] Update README.md
---
docs/L2/InternVL/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 562784d37..b97c00998 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -191,6 +191,7 @@ python demo.py
+
# 3.XTuner微调实践
## 3.1.准备基本配置文件
From 81f3973ffdf877361450ef7386666cf1862324cd Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:40:35 +0800
Subject: [PATCH 18/29] Update README.md
---
docs/L2/InternVL/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index b97c00998..262339036 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -136,7 +136,7 @@ lmdeploy推理的核心代码如上注释所述。
我们可以使用UI界面先体验与InternVL对话:
-拉取本教程的github仓库(https://github.com/Control-derek/InternVL2-Tutorial.git):
+拉取本教程的github仓库[https://github.com/Control-derek/InternVL2-Tutorial.git](https://github.com/Control-derek/InternVL2-Tutorial.git):
```Bash
git clone https://github.com/Control-derek/InternVL2-Tutorial.git
From aa8d036bee80b3e116850a283f0198d7899e65fa Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:43:16 +0800
Subject: [PATCH 19/29] Update README.md
---
docs/L2/InternVL/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 262339036..03ccf2f83 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -277,7 +277,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
### 3.3.a.通过huggingface下载
-有能力的同学,建议去huggingface下载此数据集:https://huggingface.co/datasets/lyan62/FoodieQA。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
+有能力的同学,建议去huggingface下载此数据集:[https://huggingface.co/datasets/lyan62/FoodieQA](https://huggingface.co/datasets/lyan62/FoodieQA)。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
由于申请的与huggingface账号绑定,需要在命令行登录huggingface后直接在服务器上下载:
From a4d243791d39a39a6b17a4e65fb4a59625615642 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:43:59 +0800
Subject: [PATCH 20/29] Update README.md
---
docs/L2/InternVL/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 03ccf2f83..8e910e160 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -180,7 +180,7 @@ python demo.py
-可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
+可以参考github的issue[https://github.com/InternLM/lmdeploy/issues/2101](https://github.com/InternLM/lmdeploy/issues/2101):

From 47c3a082617fc2409141ab5c78e6ca380be6bc03 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 21 Oct 2024 16:44:54 +0800
Subject: [PATCH 21/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 67a6feb7d..dad3c430a 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -35,7 +35,7 @@ pip install lmdeploy gradio
## 2.1.网页应用部署体验
-拉取本教程的github仓库(https://github.com/Control-derek/InternVL2-Tutorial.git):
+拉取本教程的github仓库[https://github.com/Control-derek/InternVL2-Tutorial.git](https://github.com/Control-derek/InternVL2-Tutorial.git):
```Bash
git clone https://github.com/Control-derek/InternVL2-Tutorial.git
@@ -71,7 +71,7 @@ python demo.py
-可以参考github的issue(https://github.com/InternLM/lmdeploy/issues/2101):
+可以参考github的issue[https://github.com/InternLM/lmdeploy/issues/2101](https://github.com/InternLM/lmdeploy/issues/2101):

@@ -117,7 +117,7 @@ FoodieQA 是一个专门为研究中国各地美食文化而设计的数据集
### 3.2.a.通过huggingface下载
-有能力的同学,建议去huggingface下载此数据集:https://huggingface.co/datasets/lyan62/FoodieQA。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
+有能力的同学,建议去huggingface下载此数据集:[https://huggingface.co/datasets/lyan62/FoodieQA](https://huggingface.co/datasets/lyan62/FoodieQA)。该数据集为了防止网络爬虫污染测评效果,需要向提交申请后下载使用。
由于申请的与huggingface账号绑定,需要在命令行登录huggingface后直接在服务器上下载:
From 0d5850aa77061fe5bfc9506d3dcf7a64e7752a95 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Tue, 22 Oct 2024 01:00:30 +0800
Subject: [PATCH 22/29] Update README.md
---
docs/L2/InternVL/README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 8e910e160..8682e4536 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -62,9 +62,10 @@ conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
```
-每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包(同一个终端下只需运行一次):
+每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包;还要把`bin`文件夹添加到PATH环境变量中,这样才能找到你用pip安装的命令行工具(同一个终端下只需运行一次):
```Bash
export PYTHONPATH=/root/internvl_course:$PYTHONPATH
+export PATH=/root/internvl_course/bin:$PATH
```
@@ -317,6 +318,7 @@ python process_food.py
```Bash
export PYTHONPATH=/root/internvl_course:$PYTHONPATH # 让python能找到第一步安装在其他路径下的包
+export PATH=/root/internvl_course/bin:$PATH # 让系统可以找到你安装的命令行工具
xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_zero2
```
From 3451f92df3166fd2ecb97d656e3b993426daca17 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Tue, 22 Oct 2024 01:02:35 +0800
Subject: [PATCH 23/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index dad3c430a..d75569d59 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -16,9 +16,10 @@
conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
```
-每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包(同一个终端下只需运行一次):
+每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包;还要把`bin`文件夹添加到PATH环境变量中,这样才能找到你用pip安装的命令行工具(同一个终端下只需运行一次):
```Bash
export PYTHONPATH=/root/internvl_course:$PYTHONPATH
+export PATH=/root/internvl_course/bin:$PATH
```
## 1.2.推理环境配置
@@ -155,6 +156,7 @@ python process_food.py
```Bash
export PYTHONPATH=/root/internvl_course:$PYTHONPATH # 让python能找到第一步安装在其他路径下的包
+export PATH=/root/internvl_course/bin:$PATH # 让系统可以找到你安装的命令行工具
xtuner train /root/xtuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py --deepspeed deepspeed_zero2
```
From 1f5d4422ec6a5e540afce2b9f630af454efce91b Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Tue, 22 Oct 2024 16:23:46 +0800
Subject: [PATCH 24/29] Update README.md
---
docs/L2/InternVL/README.md | 31 +------------------------------
1 file changed, 1 insertion(+), 30 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 8682e4536..85b8966e4 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -46,33 +46,6 @@
## 1.1.训练环境配置
-### 1.1.a.使用浦语开发机InternStudio
-
-进入预设的虚拟环境:
-
-```Bash
-conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
-```
-
-这个环境中预设了pytorch,因此安装会快一些。
-
-安装XTuner和timm,用-t的目的是为了把包下载在指定路径下,这样可以防止污染这个环境:
-
-```Bash
-pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
-```
-
-每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包;还要把`bin`文件夹添加到PATH环境变量中,这样才能找到你用pip安装的命令行工具(同一个终端下只需运行一次):
-```Bash
-export PYTHONPATH=/root/internvl_course:$PYTHONPATH
-export PATH=/root/internvl_course/bin:$PATH
-```
-
-
-在本教程中后续提到训练环境均指"/root/share/pre_envs/pytorch2.3.1cu12.1"环境。
-
-### 1.1.b.使用自己的机器
-
新建虚拟环境并进入:
```Bash
@@ -314,11 +287,9 @@ python process_food.py
## 3.4.开始微调🐱🏍
-运行命令,开始微调(如果是利用浦语开发机配置的环境,需要先运行第一行,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包,在自己机器用非pip install -t安装的可以忽视第一行):
+运行命令,开始微调:
```Bash
-export PYTHONPATH=/root/internvl_course:$PYTHONPATH # 让python能找到第一步安装在其他路径下的包
-export PATH=/root/internvl_course/bin:$PATH # 让系统可以找到你安装的命令行工具
xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_zero2
```
From 584a9536eb0b87fe4f40dc12f7b45cab5b6a621f Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 28 Oct 2024 04:17:11 +0800
Subject: [PATCH 25/29] Update README.md
---
docs/L2/InternVL/README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 85b8966e4..37d6687c7 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -59,6 +59,8 @@ conda activate xtuner-env
```Bash
pip install -U 'xtuner[deepspeed]' timm==1.0.9
+pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu121
+pip install transformers==4.39.0
```
训练环境既为安装成功。
@@ -70,7 +72,7 @@ pip install -U 'xtuner[deepspeed]' timm==1.0.9
```Bash
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
-pip install lmdeploy gradio
+pip install lmdeploy gradio timm==1.0.9
```
"lmdeploy"为推理使用环境名。
From 377b395d487d5b141af60561b722f570c3349a5c Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 28 Oct 2024 04:18:11 +0800
Subject: [PATCH 26/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index d75569d59..fbaed0a53 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -29,7 +29,7 @@ export PATH=/root/internvl_course/bin:$PATH
```Bash
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
-pip install lmdeploy gradio
+pip install lmdeploy gradio timm==1.0.9
```
# 2.LMDeploy部署
From 82b58b867a2e23217391a0d2cca9efcd92bba802 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 28 Oct 2024 04:29:34 +0800
Subject: [PATCH 27/29] Update easy_README.md
---
docs/L2/InternVL/easy_README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index fbaed0a53..306e41554 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -29,7 +29,7 @@ export PATH=/root/internvl_course/bin:$PATH
```Bash
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
-pip install lmdeploy gradio timm==1.0.9
+pip install lmdeploy gradio==4.44.1 timm==1.0.9
```
# 2.LMDeploy部署
From bbb94b3459b528cdd732e36e91513c01cf3d9047 Mon Sep 17 00:00:00 2001
From: Control-derek <96937251+Control-derek@users.noreply.github.com>
Date: Mon, 28 Oct 2024 04:32:05 +0800
Subject: [PATCH 28/29] Update README.md
---
docs/L2/InternVL/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 37d6687c7..6a8862691 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -72,7 +72,7 @@ pip install transformers==4.39.0
```Bash
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
-pip install lmdeploy gradio timm==1.0.9
+pip install lmdeploy gradio==4.44.1 timm==1.0.9
```
"lmdeploy"为推理使用环境名。
From 89f715b0bd34db35145efb1e1ade2db5a304bac9 Mon Sep 17 00:00:00 2001
From: Control-derek <1067245742@qq.com>
Date: Sun, 8 Dec 2024 17:59:11 +0800
Subject: [PATCH 29/29] Fixed a bug caused by peft
---
docs/L2/InternVL/README.md | 9 +++++----
docs/L2/InternVL/easy_README.md | 5 +++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/docs/L2/InternVL/README.md b/docs/L2/InternVL/README.md
index 6a8862691..d21c5c2b6 100644
--- a/docs/L2/InternVL/README.md
+++ b/docs/L2/InternVL/README.md
@@ -58,9 +58,10 @@ conda activate xtuner-env
安装与deepspeed集成的xtuner和相关包:
```Bash
-pip install -U 'xtuner[deepspeed]' timm==1.0.9
+pip install xtuner==0.1.23 timm==1.0.9
+pip install 'xtuner[deepspeed]'
pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu121
-pip install transformers==4.39.0
+pip install transformers==4.39.0 peft==0.13.2
```
训练环境既为安装成功。
@@ -72,7 +73,7 @@ pip install transformers==4.39.0
```Bash
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
-pip install lmdeploy gradio==4.44.1 timm==1.0.9
+pip install lmdeploy==0.6.1 gradio==4.44.1 timm==1.0.9
```
"lmdeploy"为推理使用环境名。
@@ -175,7 +176,7 @@ python demo.py
在InternStudio开发机的`/root/xtuner`路径下,即为开机自带的xtuner,先进入工作目录并激活训练环境:
```Bash
-cd root/xtuner
+cd /root/xtuner
conda activate xtuner-env # 或者是你自命名的训练环境
```
diff --git a/docs/L2/InternVL/easy_README.md b/docs/L2/InternVL/easy_README.md
index 306e41554..72b7d3abf 100644
--- a/docs/L2/InternVL/easy_README.md
+++ b/docs/L2/InternVL/easy_README.md
@@ -14,7 +14,8 @@
```Bash
conda activate /root/share/pre_envs/pytorch2.3.1cu12.1
-pip install -t /root/internvl_course 'xtuner[deepspeed]' timm==1.0.9 # 防止污染环境
+pip install -t /root/internvl_course xtuner==0.1.23 timm==1.0.9 # 防止污染环境
+pip install -t /root/internvl_course 'xtuner[deepspeed]' # 防止污染环境
```
每次使用前,需要运行一下命令,把自定义的安装包的路径添加到PYTHONPATH环境变量中,这样python才能找到你安装的包;还要把`bin`文件夹添加到PATH环境变量中,这样才能找到你用pip安装的命令行工具(同一个终端下只需运行一次):
```Bash
@@ -29,7 +30,7 @@ export PATH=/root/internvl_course/bin:$PATH
```Bash
conda create -n lmdeploy python=3.10 -y
conda activate lmdeploy
-pip install lmdeploy gradio==4.44.1 timm==1.0.9
+pip install lmdeploy==0.6.1 gradio==4.44.1 timm==1.0.9
```
# 2.LMDeploy部署