chatGLM-6B的Github地址:https://github.com/THUDM/ChatGLM-6B
chatGLM-6B的模型地址:https://huggingface.co/THUDM/chatglm-6b
apt-get updata
apt-get install git-lfs
git init
git lfs install
git clone https://github.com/THUDM/ChatGLM-6B
#model文件最好像我这样放置
cd ChatGLM-6B
mkdir model
cd model
git clone https://huggingface.co/THUDM/chatglm2-6b
模型文件耐心等待!!
一定要新一点点python版本! 比如3.10 不如install依赖容易出问题卡
我们从giihub 下载时有一个ptuning文件夹,就是官方推荐的微调工具箱
加载大模型后会加载我们的小问题,我们的微调的模型路径如下 ,我用的是gihub提供的example数据,商品推荐的例子,把step改为了300 ,save per step也是100 (会每100个step保存我们的参数bin文件 )测试一下即可,大概30分钟跑完
修改我们的原先的chatglm2路径、和我们的checkpoint-300 路径
看github官方,需要构建好你的多轮对话训练数据,利用train_chat.sh来做
1.问题1
报错
ModuleNotFoundError: No module named ‘pandas._libs.interval’
解决方法:更新pandas
pip install -U pandas
2.问题2
报错
AssertionError: Torch not compiled with CUDA enabled
解决方法:重新安装torch2.0.1及cuda118
pip uninstall torch
pip cache purge
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
3.问题3
报错
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 108.00 MiB (GPU 0; 8.00 GiB total capacity; 7.25 GiB already allocated; 0 bytes free; 7.25 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
解决方法:同样需要使用模型量化
model = AutoModel.from_pretrained(“D:\ChatGLM2-6B”, trust_remote_code=True).quantize(
(base) root@autodl-container-9d3911a33c-68e4ad7e:~/autodl-tmp/ChatGLM2-6B-main/ptuning# bash train.sh
usage: torchrun [-h] [–nnodes NNODES] [–nproc_per_node NPROC_PER_NODE] [–rdzv_backend RDZV_BACKEND] [–rdzv_endpoint RDZV_ENDPOINT] [–rdzv_id RDZV_ID]
[–rdzv_conf RDZV_CONF] [–standalone] [–max_restarts MAX_RESTARTS] [–monitor_interval MONITOR_INTERVAL] [–start_method {spawn,fork,forkserver}]
[–role ROLE] [-m] [–no_python] [–run_path] [–log_dir LOG_DIR] [-r REDIRECTS] [-t TEE] [–node_rank NODE_RANK] [–master_addr MASTER_ADDR]
[–master_port MASTER_PORT]
training_script …
torchrun: error: unrecognized arguments: --nproc-per-node=1
参数名称错!应该是下划线–nproc_per_node 不知道被谁该了23333
在运行ptuning后的web_demo.sh报错:
(chatglm) root@autodl-container-9d3911a33c-68e4ad7e:~/autodl-tmp/ChatGLM2-6B-main/ptuning# bash web_demo.sh
/root/autodl-tmp/ChatGLM2-6B-main/ptuning/web_demo.py:101: GradioDeprecationWarning: Thestyle
method is deprecated. Please set these arguments in the constructor instead.
user_input = gr.Textbox(show_label=False, placeholder=“Input…”, lines=10).style(
Traceback (most recent call last):
File “/root/autodl-tmp/ChatGLM2-6B-main/ptuning/web_demo.py”, line 167, in
main()
File “/root/autodl-tmp/ChatGLM2-6B-main/ptuning/web_demo.py”, line 133, in main
tokenizer = AutoTokenizer.from_pretrained(
File “/root/miniconda3/envs/chatglm/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py”, line 643, in from_pretrained
tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
File “/root/miniconda3/envs/chatglm/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py”, line 487, in get_tokenizer_config
resolved_config_file = cached_file(
File “/root/miniconda3/envs/chatglm/lib/python3.10/site-packages/transformers/utils/hub.py”, line 417, in cached_file
resolved_file = hf_hub_download(
File “/root/miniconda3/envs/chatglm/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py”, line 110, in _inner_fn
validate_repo_id(arg_value)
File “/root/miniconda3/envs/chatglm/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py”, line 158, in validate_repo_id
raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form ‘repo_name’ or ‘namespace/repo_name’: ‘…/root/chatglm2-6b’. Userepo_type
argument if needed.
第一个是方法被弃用,没事,迭戈是路径问题,改为绝对你路径,而不是相对路径…/