清华GLM部署记录

环境部署

  1. 首先安装anaconda(建议包管理比较方便)windows用户需手动配置一下环境变量,下面默认是在ubuntu环境说明
  2. 创建python环境,conda create -n your_env_name python=3.10 (注:官方是提供是python3.8,但目前主流用python3.10 因此使用python3.10. your_env_name 是可以自己命名的环境名字 )
  3. 导入需要的包,这里包版本的参考,在附件中的requirements.txt, 可以使用pip install -r requirements.txt

拉取github项目

  1. git clone https://github.com/chatchat-space/langchain-ChatGLM.git

  2. cd langchain-ChatGLM

  3. 启动webui:如果是ubuntu 可以直接运行命令

    python webui.py 
    

    启动api接口:如果是ubuntu 可以直接运行命令

    python api.py
    

    多卡启动, 在命令前面指定CUDA_VISIBLE_DEVICES=0,1 类似这样 如:

    CUDA_VISIBLE_DEVICES=0,1,2,3 python api.py
    

可能遇到的问题

  • 默认直接运行命令时,第一次将会从huggingface上下载模型,可能遇到网络连接的问题,解决方案如下:

    • 重新运行,因为有断点重连,所以就不停的重新运行直到下完模型权重就行,默认地址为~/.cache/huggingface/hub/models–模型名称

    • 打开huggingface,搜索要下载的模型,在Files and versions中将模型都下载到本地,目录结构为

      .
      └── 模型文件夹
      ├── added_tokens.json
      ├── config.json
      ├── configuration_codet5p_embedding.py
      ├── merges.txt
      ├── modeling_codet5p_embedding.py
      ├── pytorch_model.bin
      ├── special_tokens_map.json
      ├── tokenizer.json
      ├── tokenizer_config.json
      └── vocab.json

      然后在langchain-ChatGLM/config/model_config.py 中配置local_model_path 字段为 模型文件夹所在的路径

更多说明

可以使用fastchat 部署做到 模型和api在不同的服务器(或相同服务器)

参考连接 https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md#restful-api-server

猜你喜欢

转载自blog.csdn.net/Climbman/article/details/133457936
GLM