? ? ? 最近很多人都嘗試在M1/M2芯片下跑chatglm/chatglm2,結(jié)果都不太理想,或者是說(shuō)要32G內(nèi)存才可以運(yùn)行。本文使用cpu基于chatglm-cpp運(yùn)行chatglm2的int4版本。開(kāi)了多個(gè)網(wǎng)頁(yè)及應(yīng)用的情況下(包括chatglm2),總體內(nèi)存占用9G左右。chatglm2可以流暢的運(yùn)行了。虛擬環(huán)境為python 3.10,使用conda 創(chuàng)建。
?
?具體部署過(guò)程如下:
1.安裝brew,主要需要安裝core及cask
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
2.添加git配置
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
3. 安裝cmake
brew install cmake
4. 下載chatglm-cpp
git clone --recursive https://github.com/li-plus/chatglm.cpp.git && cd chatglm.cpp
5. 轉(zhuǎn)換chatglm2模型(模型下載THUDM/chatglm2-6b at main,依賴(lài)安裝)????????????????
python3 convert.py -i THUDM/chatglm2-6b -t q4_0 -o chatglm2-ggml.bin
6. build main
cmake -B build
cmake --build build -j
7. 命令行調(diào)用
./build/bin/main -m chatglm2-ggml.bin -p 你好 --top_p 0.8 --temp 0.8 # ChatGLM2-6B
# 你好??!我是人工智能助手 ChatGLM2-6B,很高興見(jiàn)到你,歡迎問(wèn)我任何問(wèn)題。
8. 安裝chatglm-cpp文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-636395.html
pip install -U chatglm-cpp
9. 運(yùn)行web_demo.py文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-636395.html
cd examples && python web_demo.py -m ../chatglm-ggml.bin
到了這里,關(guān)于Mac(M1Pro)下運(yùn)行ChatGLM2的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!