【个人开发】deepspeed+Llama-factory 本地数据多卡Lora微调

文章目录

  • 1.背景
  • 2.微调方式
    • 2.1 关键环境版本信息
    • 2.2 步骤
    • 2.2.1 下载llama-factory
      • 2.2.2 准备数据集
      • 2.2.3 微调模式
      • 2.2.3.1 zero-3微调
      • 2.2.3.2 zero-2微调
      • 2.2.3.3 单卡Lora微调
    • 2.3 踩坑经验
      • 2.3.1 问题一:ValueError: Undefined dataset xxxx in dataset_info.json.
      • 2.3.2 问题二: ValueError: Target modules {'c_attn'} not found in the base model. Please check the target modules and try again.
      • 2.3.3 问题三: RuntimeError: The size of tensor a (1060864) must match the size of tensor b (315392) at non-singleton dimension 0。
      • 2.3.4 问题四: 训练效率问题
    • 2.4 实验
      • 2.4.1 实验1:多GPU微调-zero2
      • 2.4.2 实验2:多GPU微调-zero3
      • 2.4.3 实验3:Lora单卡微调
  • 3 合并大模型并启动
    • 3.1 方法一:Llama-factory合并,并使用ollama调用大模型
    • 3.2 方法二:Llama-factory合并,并使用vllm启动模型服务

1.背景

上一篇文件写到,macbook微调Lora,该微调方式,同样适用于GPU,只不过在train.py脚本中,针对device,调整为cuda即可。

但如果数据量过大的话,单卡微调会存在瓶颈,因此考虑多GPU进行微调。网上找了一圈,多卡微调的常用方式采用deepspeed+Llama-factory。

本文主要记录该方式的微调情况,仅为个人学习记录

2.微调方式

2.1 关键环境版本信息

模块版本
python3.10
CUDA12.6
torch2.5.1
peft0.12.0
transformers4.46.2
accelerate1.1.1
trl0.9.6
deepspeed0.15.4

2.2 步骤

2.2.1 下载llama-factory

git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
pip install -e ".[torch,metrics]"

2.2.2 准备数据集

数据集采用网上流传的《甄嬛传》,数据集结构如下,数据集命名【huanhuan.json】

[
    {
        "instruction": "小姐,别的秀女都在求中选,唯有咱们小姐想被撂牌子,菩萨一定记得真真儿的——",
        "input": "",
        "output": "嘘——都说许愿说破是不灵的。"
    },
    ...
]

其次,还得准备数据集信息【dataset_info.json】,因为是本地微调,所以微调时现访问dataset_info,再指定到具体的数据集中。

{
  "identity": {
    "file_name": "test_data.json"
  }
}

注意文本的数据集的格式必须为,json,不然会报错。

2.2.3 微调模式

2.2.3.1 zero-3微调

本次微调采用zero-3的方式,因此在LLaMa-Factory目录下,新增配置文件【ds_config_zero3.json】。

相关配置可参考【./LLaMA-Factory/examples/deepspeed/文件夹下的样例】

在这里插入图片描述

配置如下【ds_config_zero3.json】

{
    "fp16": {
        "enabled": "auto",
        "loss_scale": 0,
        "loss_scale_window": 1000,
        "initial_scale_power": 16,
        "hysteresis": 2,
        "min_loss_scale": 1
    },
    "bf16": {
        "enabled": "auto"
    },
    "optimizer": {
        "type": "AdamW",
        "params": {
            "lr": "auto",
            "betas": "auto",
            "eps": "auto",
            "weight_decay": "auto"
        }
    },

    "scheduler": {
        "type": "WarmupLR",
        "params": {
            "warmup_min_lr": "auto",
            "warmup_max_lr": "auto",
            "warmup_num_steps": "auto"
        }
    },

    "zero_optimization": {
        "stage": 3,
        "offload_optimizer": {
            "device": "none",
            "pin_memory": true
        },
        "offload_param": {
            "device": "none",
            "pin_memory": true
        },
        "overlap_comm": true,
        "contiguous_gradients": true,
        "sub_group_size": 1e9,
        "reduce_bucket_size": "auto",
        "stage3_prefetch_bucket_size": "auto",
        "stage3_param_persistence_threshold": "auto",
        "stage3_max_live_parameters": 1e9,
        "stage3_max_reuse_distance": 1e9,
        "stage3_gather_16bit_weights_on_model_save": true
    },

    "gradient_accumulation_steps": "auto",
    "gradient_clipping": "auto",
    "steps_per_print": 100,
    "train_batch_size": "auto",
    "train_micro_batch_size_per_gpu": "auto",
    "wall_clock_breakdown": false
}

微调脚本

# run_train_bash.sh 
#!/bin/bash
# 记录开始时间
START=$(date +%s.%N)
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 accelerate launch  src/train.py \
    --deepspeed ds_config_zero3.json \
    --stage sft \
    --do_train True \
    --model_name_or_path /root/ai_project/fine-tuning-by-lora/models/model/qwen/Qwen2___5-7B-Instruct \
    --finetuning_type lora \
    --template qwen \
    --dataset_dir /root/ai_project/fine-tuning-by-lora/dataset/ \
    --dataset identity \
    --cutoff_len 1024 \
    --num_train_epochs 5 \
    --max_samples 100000 \
    --per_device_train_batch_size 4 \
    --gradient_accumulation_steps 4 \
    --lr_scheduler_type cosine \
    --learning_rate 5e-04 \
    --lr_scheduler_type cosine \
    --max_grad_norm 1.0 \
    --logging_steps 5 \
    --save_steps 100 \
    --neftune_noise_alpha 0 \
    --lora_rank 8 \
    --lora_dropout 0.1 \
    --lora_alpha 32 \
    --lora_target q_proj,v_proj,k_proj,gate_proj,up_proj,o_proj,down_proj \
    --output_dir ./output/qwen_7b_ds/train_2025_02_13 \
    --bf16 True \
    --plot_loss True
    
# 记录结束时间
END=$(date +%s.%N)
# 计算运行时间
DUR=$(echo "$END - $START" | bc)
# 输出运行时间
printf "Execution time: %.6f seconds\n" $DUR

说明一下上述一些关键参数:

参数版本
–deepspeed指定deepspeed加速微调方式
–model_name_or_path微调模型路径
–finetuning_type微调方式,这里用lora微调
–template训练和推理时构造 prompt 的模板,不同大语言模型的模板不一样,这里用的是qwen
–dataset_dir本地的数据集路径
–dataset指定dataset_info.json中哪个数据集
–lora_target应用 LoRA 方法的模块名称。
–output_dir模型输出路径。

模型微调参数可以参考:Llama-Factory参数介绍

其他参数,其实就是常规使用peft进行lora微调的常见参数,以及常见的微调参数,可以对照如下。

lora_config = LoraConfig(
    task_type=TaskType.CAUSAL_LM,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
    inference_mode=False,
    r=8,
    lora_alpha=32,
    lora_dropout=0.1
)

2.2.3.2 zero-2微调

zero-2下述的配置中,调度器使用了AdamW,学习率在训练时候可以逐步下降。

配置如下【ds_config_zero2.json】

{
    "fp16": {
        "enabled": "auto",
        "loss_scale": 0,
        "loss_scale_window": 1000,
        "initial_scale_power": 16,
        "hysteresis": 2,
        "min_loss_scale": 1
    },
    "bf16": {
        "enabled": "auto"
    },
    "optimizer": {
        "type": "AdamW",
        "params": {
            "lr": "auto",
            "betas": "auto",
            "eps": "auto",
            "weight_decay": "auto"
        }
    },

    "zero_optimization": {
        "stage": 2,
        "offload_optimizer": {
            "device": "cpu",
            "pin_memory": true
        }
    },

    "gradient_accumulation_steps": 4,
    "gradient_clipping": "auto",
    "steps_per_print": 100,
    "train_batch_size": "auto",
    "train_micro_batch_size_per_gpu": "auto",
    "wall_clock_breakdown": false
}

2.2.3.3 单卡Lora微调

具体使用可以参考上一篇文章:【个人开发】macbook m1 Lora微调qwen大模型
也可以参考github项目:fine-tuning-by-Lora

微调代码如下。


torch_dtype = torch.half

lora_config = LoraConfig(
    task_type=TaskType.CAUSAL_LM,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
    inference_mode=False,
    r=8,
    lora_alpha=32,
    lora_dropout=0.1
)

def train():
    # 加载模型
    model_dir = snapshot_download(model_id=model_id, cache_dir=f"{models_dir}/model", revision='master')
    if model_path != model_dir:
        raise Exception(f"model_path:{model_path} != model_dir:{model_dir}")
    model = AutoModelForCausalLM.from_pretrained(model_path,device_map=device, torch_dtype=torch_dtype)
    model.enable_input_require_grads()  # 开启梯度检查点时,要执行该方法

    # 加载数据
    df = pd.read_json(dataset_file)
    ds = Dataset.from_pandas(df)
    print(ds[:3])

    # 处理数据
    tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False, trust_remote_code=True)
    tokenizer.pad_token = tokenizer.eos_token
    def process_func(item):
        MAX_LENGTH = 384  # Llama分词器会将一个中文字切分为多个token,因此需要放开一些最大长度,保证数据的完整性
        input_ids, attention_mask, labels = [], [], []
        instruction = tokenizer(
            f"<|start_header_id|>user<|end_header_id|>\n\n{item['instruction'] + item['input']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n",
            add_special_tokens=False)  # add_special_tokens 不在开头加 special_tokens
        response = tokenizer(f"{item['output']}<|eot_id|>", add_special_tokens=False)
        input_ids = instruction["input_ids"] + response["input_ids"] + [tokenizer.pad_token_id]
        attention_mask = instruction["attention_mask"] + response["attention_mask"] + [1]  # 因为eos token咱们也是要关注的所以 补充为1
        labels = [-100] * len(instruction["input_ids"]) + response["input_ids"] + [tokenizer.pad_token_id]
        if len(input_ids) > MAX_LENGTH:  # 做一个截断
            input_ids = input_ids[:MAX_LENGTH]
            attention_mask = attention_mask[:MAX_LENGTH]
            labels = labels[:MAX_LENGTH]
        return {
            "input_ids": input_ids,
            "attention_mask": attention_mask,
            "labels": labels
        }

    tokenized_id = ds.map(process_func, remove_columns=ds.column_names)
    tokenizer.decode(list(filter(lambda x: x != -100, tokenized_id[1]["labels"])))
    # 加载lora权重
    model = get_peft_model(model, lora_config)
    # 训练模型
    training_args = TrainingArguments(
        output_dir=checkpoint_dir,
        per_device_train_batch_size=4,
        gradient_accumulation_steps=4,
        logging_steps=5,
        num_train_epochs=30,
        save_steps=100,
        learning_rate=5e-04,
        save_on_each_node=True,
        gradient_checkpointing=True,
    )

    trainer = Trainer(
        model=model,
        args=training_args,
        train_dataset=tokenized_id,
        data_collator=DataCollatorForSeq2Seq(tokenizer=tokenizer, padding=True),
    )
    trainer.train()

    # 保存模型
    trainer.model.save_pretrained(lora_dir)
    tokenizer.save_pretrained(lora_dir)

2.3 踩坑经验

2.3.1 问题一:ValueError: Undefined dataset xxxx in dataset_info.json.

如果你脚本的启动参数,–dataset identity。而dataset_info.json中的数据信息,没有“identity”这个key,则会出现这个报错,只要确保你dataset_info.json中存在该key即可。

2.3.2 问题二: ValueError: Target modules {‘c_attn’} not found in the base model. Please check the target modules and try again.

如果你脚本的启动参数,–lora_target参数设为常见的c_attn参数,则会报此错。处理方式还是调整参数,使用Lora微调时的常见参数,q_proj,v_proj,k_proj,gate_proj,up_proj,o_proj,down_proj。注意格式,如果格式不对,还是会报错。

2.3.3 问题三: RuntimeError: The size of tensor a (1060864) must match the size of tensor b (315392) at non-singleton dimension 0。

这种tensor的问题,很可能是模型冲突的问题,比如调到一半,然后重新提调,指到相同的路径。重新指定output路径即可。

2.3.4 问题四: 训练效率问题

在GPU充分的情况下,使用zero_2的训练效率,很明显比zero_3的训练效率更快!

2.4 实验

本次测试使用多GPU微调,测试多GPU微调跟单GPU微调的性能对比。

使用2,030条数据,epoch = 30 ,batch size = 4,Gradient Accumulation steps = 4

实验组实验类别耗时最终loss
实验1zero2微调09:590.4757
实验2zero3微调1:49:110.0746
实验3单卡lora微调【待补充】【待补充】

2.4.1 实验1:多GPU微调-zero2

使用2,030条数据,8卡微调,微调参数如下,总共480步,耗时09:59。

[INFO|trainer.py:2369] 2025-02-17 12:53:54,461 >> ***** Running training *****
[INFO|trainer.py:2370] 2025-02-17 12:53:54,461 >>   Num examples = 2,030
[INFO|trainer.py:2371] 2025-02-17 12:53:54,461 >>   Num Epochs = 30
[INFO|trainer.py:2372] 2025-02-17 12:53:54,461 >>   Instantaneous batch size per device = 4
[INFO|trainer.py:2375] 2025-02-17 12:53:54,461 >>   Total train batch size (w. parallel, distributed & accumulation) = 128
[INFO|trainer.py:2376] 2025-02-17 12:53:54,461 >>   Gradient Accumulation steps = 4
[INFO|trainer.py:2377] 2025-02-17 12:53:54,461 >>   Total optimization steps = 480
[INFO|trainer.py:2378] 2025-02-17 12:53:54,465 >>   Number of trainable parameters = 20,185,088


***** train metrics *****
  epoch                    =        30.0
  total_flos               = 234733999GF
  train_loss               =      1.6736
  train_runtime            =  0:09:59.38
  train_samples_per_second =     101.605
  train_steps_per_second   =       0.801
Figure saved at: ./output/qwen_7b_ft/zero2/training_loss.png

GPU使用情况如下:
在这里插入图片描述
损失下降情况:
在这里插入图片描述

2.4.2 实验2:多GPU微调-zero3

使用2,030条数据,8卡微调,微调参数如下,总共480步,耗时1:49:11。

[INFO|trainer.py:2369] 2025-02-17 13:07:48,438 >> ***** Running training *****
[INFO|trainer.py:2370] 2025-02-17 13:07:48,438 >>   Num examples = 2,030
[INFO|trainer.py:2371] 2025-02-17 13:07:48,438 >>   Num Epochs = 30
[INFO|trainer.py:2372] 2025-02-17 13:07:48,438 >>   Instantaneous batch size per device = 4
[INFO|trainer.py:2375] 2025-02-17 13:07:48,438 >>   Total train batch size (w. parallel, distributed & accumulation) = 128
[INFO|trainer.py:2376] 2025-02-17 13:07:48,438 >>   Gradient Accumulation steps = 4
[INFO|trainer.py:2377] 2025-02-17 13:07:48,438 >>   Total optimization steps = 480
[INFO|trainer.py:2378] 2025-02-17 13:07:48,442 >>   Number of trainable parameters = 20,185,088

...

***** train metrics *****
  epoch                    =       30.0
  total_flos               =   257671GF
  train_loss               =     0.3719
  train_runtime            = 1:49:11.88
  train_samples_per_second =      9.295
  train_steps_per_second   =      0.073
Figure saved at: ./output/qwen_7b_ft/zero3/training_loss.png
[WARNING|2025-02-17 14:57:11] llamafactory.extras.ploting:162 >> No metric eval_loss to plot.
[WARNING|2025-02-17 14:57:11] llamafactory.extras.ploting:162 >> No metric eval_accuracy to plot.
[INFO|modelcard.py:449] 2025-02-17 14:57:11,629 >> Dropping the following result as it does not have all the necessary fields:

GPU使用情况如下:

在这里插入图片描述
损失下降情况:
在这里插入图片描述

2.4.3 实验3:Lora单卡微调

【待补充】

3 合并大模型并启动

3.1 方法一:Llama-factory合并,并使用ollama调用大模型

模型合并

利用Llama-factory的框架,配置llama3_lora_sft_qwen.yaml 文件,进行模型合并。

# llama3_lora_sft_qwen.yaml
### model
model_name_or_path: /root/ai_project/fine-tuning-by-lora/models/model/qwen/Qwen2___5-7B-Instruct
adapter_name_or_path: /root/ai_project/LLaMA-Factory/output/qwen_7b_ds/zero2/
template: qwen
trust_remote_code: true

### export
export_dir: output/llama3_lora_sft_qwen
export_size: 5
export_device: gpu
export_legacy_format: false
llamafactory-cli export llama3_lora_sft_qwen.yaml

模型打包

合并完成后,会有直接生成Modelfile文件,可以直接打包到ollama中。

在这里插入图片描述

# ollama modelfile auto-generated by llamafactory
FROM .

TEMPLATE """{{ if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ range .Messages }}{{ if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
<|im_start|>assistant
{{ else if eq .Role "assistant" }}{{ .Content }}<|im_end|>
{{ end }}{{ end }}"""

SYSTEM """You are a helpful assistant."""

PARAMETER stop "<|im_end|>"
PARAMETER num_ctx 4096

模型启动
ollama启动

ollama create llama3_lora_sft_qwen -f Modelfile

参考文章:大模型开发和微调工具Llama-Factory–>LoRA合并

3.2 方法二:Llama-factory合并,并使用vllm启动模型服务

模型的合并同方法一,之后使用vllm命令启动。

vllm命令启动模型服务

# 内置了vllm的qwen的template。
CUDA_VISIBLE_DEVICES=1,2,3,4 python3 -m vllm.entrypoints.openai.api_server \
    --model "/root/ai_project/LLaMA-Factory/output/merge/" \
    --port 6006 \
    --tensor-parallel-size 4 \
    --served-model-name Qwen2.5-7B-sft \
    --max-model-len 8192 \
    --dtype half \
    --host 0.0.0.0

模型服务接口调用

import requests

def chat_with_vllm(prompt, port=6006):

    url = f"http://localhost:{port}/v1/chat/completions"
    headers = {"Content-Type": "application/json"}
    data = {
        "model": "Qwen2.5-7B-sft",  # 模型名称或路径
        "messages": [{"role": "user", "content": prompt}],
        "max_tokens": 512,
        "temperature": 0.7
    }

    response = requests.post(url, headers=headers, json=data)

    if response.status_code == 200:
        result = response.json()
        generated_text = result["choices"][0]["message"]["content"]
        print(generated_text.strip())
    else:
        print("Error:", response.status_code, response.text)

# 示例调用
chat_with_vllm("你是谁?", port=6006)

服务日志:
在这里插入图片描述
说明:日志中可以看到template。

调用结果:
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/971256.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

微信小程序之mobx-miniprogram状态管理

目前已经学习了6种小程序页面、组件间的数据通信方案,分别是: 1. 数据绑定: properties 2.获取组件实例: this.selectComponent() 3.事件绑定: this.triggerEvent() 4. 获取应用实例&#xff1a;getApp() 5. 页面间通信: EventChannel 6.事件总线:pubsub-js 在中小型项目…

express + vue 部署宝塔

域名备案 我这里是不同的账号&#xff0c;需要先登录服务器的账号生成授权码给到对应域名的账号。目前域名审核中。 进入域名账号&#xff0c;进行备案即可。 登录阿里云密码设置 未设置登录远程服务的密码&#xff0c;要先设置密码。 登录服务 设置安全组 根据宝塔的需要端…

250214-java类集框架

引言 类集框架本质上相当于是容器&#xff0c;容器装什么东西由程序员指定 1.单列集合 单列集合是list和set&#xff0c;list的实现类有ArrayList和LinkedList&#xff0c;前者是数组实现&#xff0c;后者是链表实现。list和set&#xff0c;前者有序、可重复&#xff0c;后者…

【华为OD机考】2024E+D卷真题【完全原创题解 详细考点分类 不断更新题目 六种主流语言Py+Java+Cpp+C+Js+Go】

可上 欧弟OJ系统 练习华子OD、大厂真题 绿色聊天软件戳 oj1441了解算法冲刺训练&#xff08;备注【CSDN】否则不通过&#xff09; 文章目录 相关推荐阅读模拟 数学排序字符串基础数组基础系统设计蒙特卡洛模拟其他 栈 常规栈单调栈 队列&#xff08;题目极少&#xff0c;几乎不…

【论文投稿】Python 网络爬虫:探秘网页数据抓取的奇妙世界

目录 前言 一、Python—— 网络爬虫的绝佳拍档 二、网络爬虫基础&#xff1a;揭开神秘面纱 &#xff08;一&#xff09;工作原理&#xff1a;步步为营的数据狩猎 &#xff08;二&#xff09;分类&#xff1a;各显神通的爬虫家族 三、Python 网络爬虫核心库深度剖析 &…

借3D视觉定位东风,汽车零部件生产线实现无人化的精准飞跃

在新能源汽车市场的推动下&#xff0c;汽车零部件制造业正迎来前所未有的发展机遇。然而&#xff0c;传统的生产方式已经无法满足现代制造业对高效、精准的要求。为了应对这一挑战&#xff0c;越来越多的企业开始探索智能化生产的道路。 在这个过程中&#xff0c;3D视觉定位系…

Linux 服务器部署deepseek

把手教你在linux服务器部署deepseek&#xff0c;打造专属自己的数据库知识库 正文开始 第一步&#xff1a;安装Ollama 打开官方网址&#xff1a;https://ollama.com/download/linux 下载Ollama linux版本 复制命令到linux操作系统执行 [rootpostgresql ~]# curl -fsSL http…

20250213编译飞凌的OK3588-C_Linux5.10.209+Qt5.15.10_用户资料_R1

20250213编译飞凌的OK3588-C_Linux5.10.209Qt5.15.10_用户资料_R1 2025/2/13 11:43 缘起&#xff1a;飞凌发布了高版本内核的适配OK3588-C的Buildroot的SDK&#xff1a;OK3588-C_Linux5.10.209Qt5.15.10_用户资料_R1。 但是编译异常了。 于是按照百度升级libc6&#xff0c;可以…

img标签的title和alt

img标签的title和alt 显示上 title:鼠标移入到图片上时候显示的内容&#xff1b; alt:图片无法加载时候显示的内容; <div class"box"><div><!-- title --><h3>title</h3><img src"./image/poster.jpg" title"这是封…

案例-04.部门管理-删除

一.功能演示 二.需求说明 三.接口文档 四.思路 既然是通过id删除对应的部门&#xff0c;那么必然要获取到前端请求的要删除部门的id。id作为请求路径传递过来&#xff0c;那么要从请求路径中获取&#xff0c;id是一个路径参数。因此使用注解PathVariable获取路径参数。 请求方…

性格测评小程序07用户登录

目录 1 创建登录页2 在首页检查登录状态3 搭建登录功能最终效果总结 小程序注册功能开发好了之后&#xff0c;就需要考虑登录的问题。首先要考虑谁作为首页&#xff0c;如果把登录页作为首页&#xff0c;比较简单&#xff0c;每次访问的时候都需要登录。 如果把功能页作为首页&…

服务器被暴力破解的一次小记录

1. 网络架构 家里三台主机&#xff0c;其他一台macmini 启用ollama运行大模型的服务&#xff0c;主机1用来部署一些常用的服务如&#xff1a;mysql, photoprism等&#xff0c;服务器作为网关部署docker, 并且和腾讯云做了内网穿透。服务器部署了1panel用来管理服务并且监控&…

长视频生成、尝试性检索、任务推理 | Big Model Weekly 第56期

点击蓝字 关注我们 AI TIME欢迎每一位AI爱好者的加入&#xff01; 01 COMAL:AConvergent Meta-Algorithm for Aligning LLMs with General Preferences 许多对齐方法&#xff0c;包括基于人类反馈的强化学习&#xff08;RLHF&#xff09;&#xff0c;依赖于布拉德利-特里&#…

STM32 串口转 虚拟串口---实现USB转串口功能

一&#xff0c;USART与UART 区别 USART&#xff08;Universal Synchronous/Asynchronous Receiver/Transmitter&#xff09;通用同步/异步串行接收/发送器 相较于UART&#xff1a;通用异步收发传输器&#xff08;Universal Asynchronous Receiver/Transmitter&#xff09;多了…

将OpenWrt部署在x86服务器上

正文共&#xff1a;1234 字 40 图&#xff0c;预估阅读时间&#xff1a;2 分钟 如果你问ChatGPT有哪些开源的SD-WAN方案&#xff0c;他会这样答复你&#xff1a; 我们看到&#xff0c;OpenWrt也属于比较知名的开源SD-WAN解决方案。当然&#xff0c;在很久之前&#xff0c;我就发…

EtherNetIP转ModbusTCP网关,给风电注入“超级赛亚人”能量

EtherNetIP转ModbusTCP网关&#xff0c;给风电注入“超级赛亚人”能量 在工业通信领域&#xff0c;常常需要将不同网络协议的设备和系统连接起来&#xff0c;以实现更高效的数据交互和系统集成。比如&#xff0c;把EtherNet/IP设备及其网络连接到ModbusTCP网络系统&#xff0c…

【LeetCode】438.找到字符串中所有的字母异位词

目录 题目题目要求什么是“异位词”&#xff1f;如何快速判断两个字符串是否是“异位词”&#xff1f; 解法 滑动窗口 哈希表 &#xff08;统计个数&#xff09;核心思路具体步骤 代码 题目 题目链接&#xff1a;LeetCode-438题 给定两个字符串 s 和 p&#xff0c;找到 s 中所…

【设计模式】【结构型模式】装饰者模式(Decorator)

&#x1f44b;hi&#xff0c;我不是一名外包公司的员工&#xff0c;也不会偷吃茶水间的零食&#xff0c;我的梦想是能写高端CRUD &#x1f525; 2025本人正在沉淀中… 博客更新速度 &#x1f44d; 欢迎点赞、收藏、关注&#xff0c;跟上我的更新节奏 &#x1f3b5; 当你的天空突…

基于Ubuntu+vLLM+NVIDIA T4高效部署DeepSeek大模型实战指南

一、 前言&#xff1a;拥抱vLLM与T4显卡的强强联合 在探索人工智能的道路上&#xff0c;如何高效地部署和运行大型语言模型&#xff08;LLMs&#xff09;一直是一个核心挑战。尤其是当我们面对资源有限的环境时&#xff0c;这个问题变得更加突出。原始的DeepSeek-R1-32B模型虽…

Windows环境搭建ES集群

搭建步骤 下载安装包 下载链接&#xff1a;https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.27-windows-x86_64.zip 解压 解压并复制出3份 es-node1配置 config/elasticsearch.yml cluster.name: xixi-es-win node.name: node-1 path.data: D:\\wor…