VisualGLM部署&微调&docker环境

一开始直接在本地环境部署,发现cuda版本冲突,所以改用docker,docke部署既不影响显卡性能,又可以避免环境冲突

1.创建docker容器

1.1. 拉取带有cuda11.7+cudnn8的镜像

docker pull andersen9419/cuda11.7.1_cudnn8_ubu22_torch2.0

1.2.运行容器

docker run --gpus all --net=host -d  -it --name VisualGLMsat andersen9419/cuda11.7.1_cudnn8_ubu22_torch2.0:latest

参数解释:
–gpus all 使得docker容器可以使用宿主机的所有gpu
–net=host配置docker容器使用宿主机的网络,这样宿主机如果开启了代理,docker容器也可以走代理

2.容器中的操作

2.1. 终端激活代理

export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"

2.2. 下载/复制VisualGLM文件夹到容器中

两种方式

1)直接在容器中使用git

apt update
apt install git
git clone https://github.com/THUDM/VisualGLM-6B.git

2)从宿主机复制

docker cp 宿主机文件路径 容器ID:容器路径

2.3. 安装依赖

pip install -r requirements.txt

2.4. 执行cli_demo.py

想要微调的也一定要先执行这个脚本,他会从sat下载模型相关文件,我一开始没执行这个就直接执行微调命令,结果老是报错,具体原因还是不太清楚,不知道是不是执行微调指令之后会从hf下载模而不是sat导致无法微调

python cli_demo.py

2.5. 报错处理

执行以上脚本的过程中可能会遇到以下报错
错误1 :
TypeError: init() got an unexpected keyword argument ‘mode‘
解决方法:

apt updata
apt intsall vim
vim /usr/local/lib/python3.10/dist-packages/sat/resources/download.py

删除download.py文件的50行的mode = 0o777
修改之前:lock = FileLock(model_path + ‘.lock’, mode=0o777)
修改之后:lock = FileLock(model_path + ‘.lock’)

错误2
AttributeError: ‘ChatGLMTokenizer’ object has no attribute ‘sp_tokenizer’. Did you mean: ‘_tokenize’?
解决方法
降低transformers版本

pip uninstall transformers
pip install transformers==4.33.0

2.6. 微调

cli_demo.py成功运行之后就可以开始微调了

2.6.1.解压数据

apt update
apt install zip
unzip fewshot-data.zip

2.6.2. 执行微调命令

bash finetune/finetune_visualglm_qlora.sh

2.6.3. 报错处理

错误1:
NameError: name ‘HackLinearNF4’ is not defined. Did you mean: ‘HackLinear’?

解决方法

 pip install bitsandbytes

总结

按以上步骤进行应该都可以成功运行,配环境真的好折磨哦!
希望对大家有帮助吧~

相关推荐

  1. VisualGLM部署&微调&docker环境

    2024-04-25 19:46:02       33 阅读
  2. docker 部署 LaTeX 环境

    2024-04-25 19:46:02       23 阅读
  3. 生产环境部署微调的10条戒律

    2024-04-25 19:46:02       33 阅读
  4. centos7部署docker环境

    2024-04-25 19:46:02       56 阅读
  5. centos7部署docker环境

    2024-04-25 19:46:02       51 阅读
  6. 快速部署docker-compose环境

    2024-04-25 19:46:02       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-25 19:46:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-25 19:46:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-25 19:46:02       82 阅读
  4. Python语言-面向对象

    2024-04-25 19:46:02       91 阅读

热门阅读

  1. python绘制平行四边形

    2024-04-25 19:46:02       33 阅读
  2. 在vue项目中使用TS

    2024-04-25 19:46:02       31 阅读
  3. el-table 表格自带全选按钮隐藏

    2024-04-25 19:46:02       25 阅读
  4. flask + celery + redis + flower

    2024-04-25 19:46:02       33 阅读
  5. C 语言实例 - 字符转 ASCII 码

    2024-04-25 19:46:02       32 阅读
  6. HashMap 和 HashTable的异同

    2024-04-25 19:46:02       32 阅读
  7. Linux c++ 中文字符转十六进制 UTF-8 编码

    2024-04-25 19:46:02       23 阅读
  8. 【React】生命周期

    2024-04-25 19:46:02       31 阅读
  9. 【vue】axios封装拦截

    2024-04-25 19:46:02       27 阅读