通过制作llama_cpp的docker镜像在内网离线部署运行大模型

通过制作llama_cpp的docker镜像在内网离线部署运行大模型

    正在检查是否收录...

对于机器在内网,无法连接互联网的服务器来说,想要部署体验开源的大模型,需要拷贝各种依赖文件进行环境搭建难度较大,本文介绍如何通过制作docker镜像的方式,通过llama.cpp实现量化大模型的快速内网部署体验。

一、llama_cpp介绍

LLaMA 全称是Large Language Model Meta AI,是由Meta AI(原FacebookAI研究实验室)研究人员发布的一个预训练语言模型。该模型最大的特点就是基于以较小的参数规模取得了优秀的性能,模型参数量从7B到65B, 与其他大型语言模型一样,LLaMA的工作原理是将一连串的单词作为输入,并预测下一个单词,以递归地生成文本。

LLaMA.cpp 项目是开发者 Georgi Gerganov 基于 Meta 的 LLaMA 模型实现的纯 C/C++ 版本,用于模型推理。 无需任何额外依赖,相比 Python 代码对 PyTorch 等库的要求,C/C++ 直接编译出可执行文件,跳过不同硬件的繁杂准备,可以在笔记本上运行,大大降低了门槛。

项目开源地址:GitHub - ggerganov/llama.cpp: Port of Facebook's LLaMA model in C/C++

二、镜像制作过程

1、下载基础镜像

在dockerhub上下载对应的镜像版本,关注需要的cuda版本和操作系统版本。

docker pull nvidia/cuda:11.2.2-devel-ubuntu20.04

运行镜像

docker run -id --gpus all -v D:\download:/app/model -p 8080:8080 nvidia/cuda:11.2.2-devel-ubuntu20.04

进入容器:

docker exec -it xxxx /bin/bash

2、配置yum

apt-get -y install git wget

修改国内源

gedit /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

apt-get update

3、安装python3.10

下载依赖

apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

下载python源码

wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz

tar -zvxf Python-3.10.0.tgz

cd Python-3.10.0/

配置

./configure --enable-optimizations

编译

make

安装

make install

更新python默认指向,删除旧的链接

remove /usr/bin/python

ln -s /usr/local/bin/python3.10 /usr/bin/python

ln -s /usr/local/bin/pip3 /usr/bin/pip

4、安装make等其他库

apt-get -y install build-essential libgl-dev libglib2.0-0 gcc g++ make cmake unzip curl

5、安装llama.app

mkdir /app

cd /app

git clone GitHub - ggerganov/llama.cpp: Port of Facebook's LLaMA model in C/C++

cd llama.cpp && mkdir build && cd build && cmake .. -DLLAMA_CUBLAS=ON && cmake --build . --config Release

报错如下:

报错

CMake Error at CMakeLists.txt:252 (cmake_minimum_required):

  CMake 3.17 or higher is required.  You are running version 3.16.3

-- Configuring incomplete, errors occurred!

6.更新cmake版本(如果上一步没有报错,则跳过该步骤):

wget https://cmake.org/files/v3.23/cmake-3.23.0.tar.gz

tar -zxvf cmake-3.23.0.tar.gz

cd cmake-3.23.0

./configure

make -j8

make install

ln -s /usr/local/bin/cmake /usr/bin/cmake

重新编译安装

cmake .. -DLLAMA_CUBLAS=ON && cmake --build . --config Release

成功!

7.运行

./server --host 0.0.0.0 -m /app/model/xxxx.gguf -c 128 -ngl 10

llamapythonappdocdockergitfacebookganurlcode语言模型大模型github笔记本可执行文件大型语言模型clone开发者模型推理sqlai研究imu预训练gpu操作系统研究人员互联网预训练语言模型pytorch服务器bash
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-3531.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

AIGC提示词(Prompt)网站

上一篇

Amazon CodeWhisperer 正式发布可免费供个人使用

下一篇
  • 复制图片
按住ctrl可打开默认菜单