目录
一、LLama-Factory安装
参考官网介绍:https://github.com/hiyouga/LLaMA-Factory
二、LLama-Factory 遇到的问题
(一)包不兼容问题
按照提示安装对应的版本,只要不相互冲突即可
(二)使用文件路径,加载模型
1.提示:NameError: name 'AsyncLLMEngine' is not defined
解决方案:在文件:src/llamafactory/chat/base_engine.py
将from vllm import AsyncLLMEngine 改为 from vllm_engine import AsyncLLMEngine
2.使用chat的时候修改gpu的使用个数和号
在运行训练程序前,在用户根目录下配置环境(~/.bashrc):
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '0,1'
或:
export CUDA_VISIBLE_DEVICES = NUM
NUM是用户指定显卡的序号(0,1,2…),可以先用 nvidia-smi 查看当前哪块显卡可用。但这种方法限制了用户可见的GPU数量,比如你的其他程序在你的目录里无法选择别的GPU; 你的程序也没法使用multiple GPUs。
注意!!!!!!
ValueError: Total number of attention heads (28) must be divisible by tensor parallel size (6).
如果改后报这个错误,一定注意注意力头数要能被gpu卡数除尽!
并在src/llamafactory/chat/vllm_engine.py将下面get_device_count() 改为自己设置的gpu并行个数,如果是占用机器上的全部gpu数量则不需要改,如果少于机器上gpu数量一定要修改为自己设定的数。
"tensor_parallel_size": get_device_count() or 1
src/llamafactory/extras/misc.py
def get_device_count() -> int:
r"""
Gets the number of available GPU or NPU devices.
"""
if is_torch_xpu_available():
return torch.xpu.device_count()
elif is_torch_npu_available():
return torch.npu.device_count()
elif is_torch_cuda_available():
return 4 # 将cuda加载的设备数修改,得保证能够被注意头除尽
#return torch.cuda.device_count()
else:
return 0
但是查看gpu使用情况,仍然是占用了所有的gpu 啊!!
3.使用train的时候修改gpu--没找到
设置环境变量CUDA_VISIBLE_DEVICES声明训练过程中允许使用4张显卡,显卡编号分别为1、2、3、4。使用 llamafactory-cli
命令启动训练
export CUDA_VISIBLE_DEVICES=1,2,3,4
llamafactory-cli train /data2/downloads/LLaMA-Factory/qwen2_lora_sft.yaml
4.Cannot use FlashAttention-2 backend because the flash_attn package is not found
pip install -U flash-attn==2.5.8
5.WARNING worker.py:1481 -- SIGTERM handler is not set because current thread is not the main thread.
gcs_rpc_client.h:179: Failed to connect to GCS at address 172.16.11.103:48924 within 5 seconds
Failed to get cluster ID from GCS server: TimedOut: Timed out while waiting for GCS to become available
6.RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
7.使用huggingface推理的Baichuan2-13B-Chat的时候,
提示:RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
8.用vllm加载模型的时候提示:Started a local Ray instance.
一个低级问题导致vLLM加载大模型时ray卡死 - badwood - 博客园
这两天一直被一个问题困扰,用vLLM加载千问时不能开并行(tensor_parallel_size>1),一开就会卡在ray阶段,最初是提示Started a local Ray instance,后来手工启动ray集群,就提示connected to Ray cluster。无论怎样调都无法跑下去,根本不会加载模型,换了各种版本的vllm、transformer、ray、显卡、甚至是用本来可以跑的docker,都不行,直到发现一个偶尔爆出的错误:ray pthread_create failed: Resource temporarily unavailable。一搜,第一条建议就是检查系统线程数设置。最终定位是系统设置的用户最大线程数太小(ulimit -u),设定为4096,修改到unlimited(/etc/security/limits.conf中增加app用户的nofile、nproc设置),顺利解决问题。
9.加载/home/sxw/3-model/1-patentWritten/10-glm-4-9b-chat模型的时候,huggingface推理,进行对话提示:KeyError: '<reserved_102>'
10.llama-factory加载chatglm3-6b-32k模型huggingface推理,对话提示:ValueError: too many values to unpack (expected 2)
解决方法:原因是transformers版本过高,修改为transformers==4.41.2【bug解决】chatglm3推理 ValueError: too many values to unpack (expected 2)_chatglm3 valueerror: too many values to unpack (ex-优快云博客
11.llama-factory加载qwen2.5-14B模型huggingface推理,对话提示:RuntimeError: Could not infer dtype of NoneType
12.llama-factory加载glm-4-9b-chat-1m模型huggingface推理,对话提示:KeyError: 'sop'。
14.vllm 推理报错,无法导入本地大模型路径_vllm加载本地模型-优快云博客
15.RuntimeError: Could not infer dtype of NoneType-优快云博客
16.解决vscode远程连接Linux无权限保存的问题,解决vscode远程连接Linux无权限保存的问题_vscode无法保存linux主机上的网络共享恩家-优快云博客
17. 为什么安装了autoawq后运行python文件的时候还是提示安装autoawq?
解决方法:直接git clone awq的源码,新建conda环境并安装awq依赖,在这个环境下运行,可以避免提示一直要安装autoawq问题,安装的autoawq版本是:0.2.6+cu121
18.vs code 提示:无法监视文件更改,请按照链接说明
【问题解决】VSCode报警:无法在这个大型工作区中监视文件更改。请按照说明链接来解决此问题。_无法在这个大型工作区文件夹中监视文件更改。请按照说明链接来解决此问题。-优快云博客
19. ollama的open webui 在执行open-webui serve的时候提示:undefined symbol: __nvJitLinkAddData_12_1, version libnvJitLink.so.x报错缺失