安装过程
安装依赖
按照GitHub上介绍的过程安装即可
GitHub - hiyouga/LLaMA-Factory: Unify Efficient Fine-Tuning of 100+ LLMshttps://github.com/hiyouga/LLaMA-Factory参考代码:
git clone https://github.com/hiyouga/LLaMA-Factory.git
conda create -n llama_factory python=3.10
conda activate llama_factory
cd LLaMA-Factory
pip install -r requirements.txt
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -e .[metrics]
选择PyTorch版本
查看pytorch版本
python
import torch
print(torch.__version__)
对比pytorch和CUDA的对应版本
Previous PyTorch Versions | PyTorchhttps://link.zhihu.com/?target=https%3A//pytorch.org/get-started/previous-versions/
安装pytorch
1. 卸载当前 PyTorch
pip uninstall torch torchvision torchaudio
2. 安装适用于 CUDA 11.8 的 PyTorch
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
3. 验证安装
python
import torch
print(torch.__version__)
print("CUDA available: ", torch.cuda.is_available())
print("Current CUDA device: ", torch.cuda.current_device())
print("Device name: ", torch.cuda.get_device_name(torch.cuda.current_device()))
通过上述两个方法之一,你可以解决 PyTorch 和 CUDA 版本不匹配的问题,从而确保 PyTorch 能够正确识别并利用 GPU 进行计算。
LLaMA Board 可视化界面
注意:LLaMA Board 可视化界面目前仅支持单 GPU 训练,请使用命令行接口来进行分布式训练。
使用本地环境:
export CUDA_VISIBLE_DEVICES=0 # Windows 使用 `set CUDA_VISIBLE_DEVICES=0`
python webui.py
执行后:
然后就可以访问web界面了。(这里还需要去服务器安全组设置安全端口)
补充本地模型地址和数据集地址