paulwong

#

量化大模型工具

VLLM量化推理
https://llmc-zhcn.readthedocs.io/en/latest/backend/vllm.html#id1

安装此工具前需安装两个包:
sudo apt-get install cmake
sudo apt-get install pkgconfig

配置huggingface镜像地址:
export HF_ENDPOINT=https://hf-mirror.com

下载代码库, 并安装python依赖
git clone https://github.com/ModelTC/llmc.git
cd llmc/
pip install -r requirements.txt

找到量化方法的配置文件, 并作修改
base:
    seed: &seed 42
model:
    type: Llama
    path: /home/paul/.cache/huggingface/models/models--unsloth--llama-3-8b-Instruct-lawdata
    torch_dtype: auto
quant:
    method: RTN
    weight:
        bit: 8
        symmetric: True
        granularity: per_group
        group_size: 128
        need_pack: True
eval:
    eval_pos: [fake_quant]
    name: wikitext2
    download: True
    path: /home/paul/paulwong/work/workspaces/llmc/dataset
    bs: 1
    seq_len: 2048
    inference_per_block: False
save:
    save_vllm: True
    save_path: /home/paul/.cache/huggingface/models/models--unsloth--llama-3-8b-Instruct-lawdata-quantization

找到run_llmc.sh, 并作修改
#!/bin/bash

# export CUDA_VISIBLE_DEVICES=0,1

llmc=/home/paul/paulwong/work/workspaces/llmc
export PYTHONPATH=$llmc:$PYTHONPATH

# task_name=awq_w_only
# config=${llmc}/configs/quantization/methods/Awq/awq_w_only.yml
task_name=rtn_for_vllm
config=${llmc}/configs/quantization/backend/vllm/rtn_w8a16.yml

nnodes=1
nproc_per_node=1


find_unused_port() {
    while true; do
        port=$(shuf -i 10000-60000 -n 1)
        if ! ss -tuln | grep -q ":$port "; then
            echo "$port"
            return 0
        fi
    done
}
UNUSED_PORT=$(find_unused_port)


MASTER_ADDR=127.0.0.1
MASTER_PORT=$UNUSED_PORT
task_id=$UNUSED_PORT

nohup \
torchrun \
--nnodes $nnodes \
--nproc_per_node $nproc_per_node \
--rdzv_id $task_id \
--rdzv_backend c10d \
--rdzv_endpoint $MASTER_ADDR:$MASTER_PORT \
${llmc}/llmc/__main__.py --config $config --task_id $task_id \
> ${task_name}.log 2>&1 &

sleep 2
ps aux | grep '__main__.py' | grep $task_id | awk '{print $2}' > ${task_name}.pid

# You can kill this program by 
# xargs kill -9 < xxx.pid
# xxx.pid is ${task_name}.pid file

执行量化操作
bash scripts/run_llmc.sh




posted @ 2025-01-15 18:00 paulwong 阅读(89) | 评论 (0)编辑 收藏

微调资源

Fine-tune Llama 3.1 Ultra-Efficiently with Unsloth
https://huggingface.co/blog/mlabonne/sft-llama3

A beginners guide to fine tuning LLM using LoRA
https://zohaib.me/a-beginners-guide-to-fine-tuning-llm-using-lora/

【Day 23】調教你的 AI 寵物:用微調讓 LLM 乖乖聽話
https://ithelp.ithome.com.tw/articles/10346441


posted @ 2025-01-15 17:56 paulwong 阅读(67) | 评论 (0)编辑 收藏

安装docker版的Nvidia container toolkit

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation

posted @ 2025-01-13 14:20 paulwong 阅读(44) | 评论 (0)编辑 收藏

开源镜像库

华为:
https://mirrors.huaweicloud.com/home
https://mirrors.huaweicloud.com/artifactory/pypi-public/simple/torch/

清华:
https://mirrors.tuna.tsinghua.edu.cn
点击问号进详情

docker:
https://mirrors.huaweicloud.com/mirrorDetail/5ea14d84b58d16ef329c5c13?mirrorName=docker-ce&catalog=docker

posted @ 2025-01-13 10:32 paulwong 阅读(87) | 评论 (0)编辑 收藏

windows中添加端口转发规则

设置端口转发

在 Windows 上,以管理员身份打开 PowerShell,
netsh interface portproxy add v4tov4 listenport=7860 listenaddress=0.0.0.0 connectport=7860 connectaddress=123.45.67.89

在 PowerShell 中使用 netsh interface portproxy 命令设置的端口转发规则是持久性的。这些规则会在系统重启后继续生效,因为它们被存储在 Windows 的注册表中。

删除端口转发规则

如果想删除之前设置的端口转发规则,可以使用以下命令:
netsh interface portproxy delete v4tov4 listenport=7860 listenaddress=0.0.0.0

这里的 listenport 和 listenaddress 应与之前设置时的值一致。

查看当前的端口转发规则

要查看当前系统中所有的端口转发规则,可以运行:
netsh interface portproxy show all


posted @ 2025-01-13 09:34 paulwong 阅读(133) | 评论 (0)编辑 收藏

AI微调框架axolotl安装

1. N卡驱动和toolkit安装
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=runfile_local
 
2. python和mini-conda安装
基本是要下载安装包安装,
python下载地址:https://repo.huaweicloud.com/python/3.12.8/
m
ini-conda下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/
co
nda清华资源:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/


3. 新建一个conda环境
conda create -n axolotl python=3.12

4. cuda版本的pytorch安装
https://download.pytorch.org/whl/cu124/torch-2.5.0%2Bcu124-cp311-cp311-linux_x86_64.whl#sha256=5e3f4a7ba812517c2c1659857b5195f287a288fbd050a5abf9311e03dbe1a28b
如想安装其他版本, 可从以下网址查找:
https://download.pytorch.org/whl/torch

5. git clone https://github.com/axolotl-ai-cloud/axolotl, cd到根目录, 运行
pip3 install --no-build-isolation axolotl[flash-attn,deepspeed]





posted @ 2025-01-12 16:37 paulwong 阅读(58) | 评论 (0)编辑 收藏

内网穿透工具

将内网, 如家庭中的使用wifi建立的网站, 发布到外网, 而无需使用服务器.

https://i.cpolar.com/m/5jN0

reference:
https://www.cpolar.com/blog/cpolar-quick-start-tutorial-ubuntu-series

posted @ 2025-01-12 11:54 paulwong 阅读(158) | 评论 (0)编辑 收藏

安装cuda版本的pytorch

先下载cuda版本的pytorch的整个打包文件:
https://download.pytorch.org/whl/cu124/torch-2.5.1%2Bcu124-cp312-cp312-linux_x86_64.whl#sha256=bf6484bfe5bc4f92a4a1a1bf553041505e19a911f717065330eb061afe0e14d7
https://mirrors.huaweicloud.com/artifactory/pypi-public/simple/torch/


pip install torch-2.5.1+cu124-cp312-cp312-linux_x86_64.whl

验证:
#python
import torch
torch.__version__

posted @ 2025-01-12 11:05 paulwong 阅读(68) | 评论 (0)编辑 收藏

mac使用vscode远程连接win11下的wsl2的方法

1.首先给win11的ssh开一个新端口.(修改C:\ProgramData\ssh\sshd_config即可)

2.win11设置防火墙,开放1中添加的端口.

3.win11进入wsl2,输入ifconfig,查看ip地址(输出信息第二行 inet后面那一串数字).

4.在win11的cmd中输入以下命令:
netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=<步骤1中开放的端口> connectaddress=<步骤3中得到的ip地址> connectport=22


5. ssh连接步骤1中开放的端口就可以连接上wsl2(注意事项:(1)连接时,win11上需要有一个wsl窗口,不然连不上,(2)ssh连接时的用户名写wsl2中的用户名,密码写wsl2中的密码,ip地址写win11的ip地址)

https://www.zhihu.com/question/618935377

posted @ 2025-01-11 09:59 paulwong 阅读(45) | 评论 (0)编辑 收藏

WSL资源

谁来救救被WSL占用的磁盘空间
https://zhuanlan.zhihu.com/p/641436638

利用 VsCode Tunnel 在 Mac 上远程开发
https://juejin.cn/post/7334167506319327283

用 WSL2 搭建 Windows 上更爽的前端开发环境
https://www.bilibili.com/video/BV1BV4y1Z7v4/?vd_source=35b81999db00535703a287d5c98652b1

posted @ 2025-01-11 09:57 paulwong 阅读(29) | 评论 (0)编辑 收藏

仅列出标题
共115页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last