• minigpt-4 本地部署


    minigpt-4 git主页
    笔者参考了深度学习笔记–本地部署Mini-GPT4,使用了http链接,

    huggingface下载llama和vicuna权重的download.txt分别如下:

    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/.gitattributes
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/LICENSE
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/README.md
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/config.json
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/generation_config.json
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00001-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00002-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00003-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00004-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00005-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00006-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00007-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00008-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00009-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00010-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00011-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00012-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00013-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00014-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00015-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00016-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00017-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00018-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00019-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00020-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00021-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00022-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00023-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00024-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00025-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00026-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00027-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00028-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00029-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00030-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00031-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00032-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00033-of-00033.bin
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model.bin.index.json
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/special_tokens_map.json
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer.model
    http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer_config.json
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/.gitattributes
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/README.md
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/config.json
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/generation_config.json
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model-00001-of-00002.bin
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model-00002-of-00002.bin
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model.bin.index.json
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/special_tokens_map.json
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/tokenizer.model
    http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/tokenizer_config.json
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    下载权重的脚本如下,使用了wget ${file} --no-check-certificate 绕开https检查:

    #! /bin/bash
    while read file; do
    	wget ${file} --no-check-certificate 
    done < download.txt
    
    • 1
    • 2
    • 3
    • 4

    笔者的环境下,安装FastChat 0.1.10会导致依赖冲突:

    The conflict is caused by:
        fschat 0.1.10 depends on tokenizers>=0.12.1
        transformers 4.35.0.dev0 depends on tokenizers<0.15 and >=0.14
    
    To fix this you could try to:
    1. loosen the range of package versions you've specified
    2. remove package versions to allow pip attempt to solve the dependency conflict
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    因此改为安装别的版本fastchat

    pip install fschat
    
    • 1

    再补充安装accelerate

    pip install accelerate
    
    • 1

    之后执行python demo时,缺什么依赖就直接pip install安装即可。作者没有列出requirements.txt

    python demo.py --cfg-path eval_configs/minigpt4_eval.yaml  --gpu-id 0
    
    • 1

    其它修改

    执行python demo.py仍然会遇到其它错误:

    如果在下载bert tokenizer和bert config时报HTTPS错误,可以到huggingface把文件下载下来,再修改Minigpt-4项目的源码models/blip2.py

    tokenizer = BertTokenizer.from_pretrained("/root/minigpt4/bert-base-uncased", local_files_only=True)
    ...
    encoder_config = BertConfig.from_pretrained("/root/minigpt4/bert-base-uncased", local_files_only=True)       
    
    • 1
    • 2
    • 3

    让代码监听网络,而不只是127.0.0.1

    demo.launch(share=True, enable_queue=True, server_name='0.0.0.0')
    
    • 1
  • 相关阅读:
    以太坊合并对NFT意味着什么?
    【C语言】指针详细解读2
    十种排序方法
    在springboot中使用JWT自定义生成Token信息,接口请求时校验Token(在Shiro基础上)
    力扣450 补9.15
    【LLM】Windows10环境部署阿里通义千问大模型(Qwen-14B-Chat-Int4)
    ESP32基础应用之LVGL基础
    SQL存储过程和函数
    如何裁剪视频画面?快来看看这个详细教程
    网络编程、OSI七层协议
  • 原文地址:https://blog.csdn.net/duoyasong5907/article/details/133783109