创建环境

  1. 使用python版本3.10 (可以自己选择)
    conda create -n qwen2.5vl python=3.10
    
  2. 查看自己的cuda版本
    nvcc -V 
    # 我的版本是12.1 所以下面都是用cu121
    
  3. 下载对应版本的torch及其相关
    pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
    
  4. 下载huggingface的transfomrer accelerate相关
    pip install git+https://github.com/huggingface/transformers accelerate
    
  5. 下载qwen vl utils
    pip install qwen-vl-utils[decord]==0.0.8
    

下载qwen vl模型

  1. 安装hfd.sh(HF-Mirror 官方推荐下载工具)
    wget https://hf-mirror.com/hfd/hfd.sh
    chmod +x hfd.sh
    export HF_ENDPOINT=https://hf-mirror.com
    
  2. 安装依赖aria2
    apt-get update && apt-get install -y aria2 git
    
  3. 使用hfd下载
    ./hfd.sh Qwen/Qwen2.5-VL-3B-Instruct \
    	--local-dir /your/path/to/models--Qwen--Qwen2.5-VL-3B-Instruct
    

验证下载

from transformers import AutoModelForVision2Seq, AutoProcessor

model_path = "/path/to/your/models--Qwen--Qwen2.5-VL-3B-Instruct"

model = AutoModelForVision2Seq.from_pretrained(
    model_path,
    trust_remote_code=True,  # Qwen 系列通常需要
    device_map="auto"
)

processor = AutoProcessor.from_pretrained(
    model_path,
    trust_remote_code=True
)
Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐