通过Anaconda搭建运行环境
1.下载anaconda安装包
wget https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
2.安装anacconda
bash ./Anaconda3-2024.10-1-Linux-x86_64.sh
vim ~/.bashrc
# 添加如下内容
export PATH="$HOME/anaconda3/bin:$PATH"
export HF_ENDPOINT=https://hf-mirror.com
# 退出编辑后
source ~/.bashrc
3.新建运行环境
清华anaconda镜像配置:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
BitNet项目地址:https://github.com/microsoft/BitNet
# 拉项目
git clone --recursive https://github.com/microsoft/BitNet.git
cd BitNet
# 创建环境
conda create -n bitnet-cpp python=3.9
conda activate bitnet-cpp
# 配置镜像
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# conda 镜像
vim ${HOME}/.condarc
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda clean -i
conda config --set show_channel_urls yes
conda config --set custom_channels.pytorch https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
conda clean -i
# 拉取依赖
pip install -r requirements.txt
huggingface下载模型
huggingface官网:https://huggingface.co 国内无法直接访问
1.配置镜像,可以写入.bashrc持久化
export HF_ENDPOINT=https://hf-mirror.com
2.下载一个模型
huggingface-cli download 1bitLLM/bitnet_b1_58-xl --local-dir models/bitnet_b1_58-xl
3.运行模型:目前测试不行了,各个官方都喜欢乱搞,资料都不更新!!!现在的代码需要vllm来运行了
python setup_env.py -md models/bitnet_b1_58-xl -q i2_s
正式运行
该情况是运行的GPU版本,cpu需要自己编译
pip install vllm
vllm serve models/bitnet_b1_58-xl --trust-remote-code
评论区