在本地電腦系統部署開源大語言模型-Llama2教程

備注:本文在window10系統安裝部署。
1.安裝Anaconda
官網https://link.zhihu.com/?target=https%3A//www.anaconda.com/
安裝完之后:
創建環境敲入命令:conda create -n Llama python=3.10.9
出現提示輸入:y 回車
激活環境輸入命令:conda activate Llama
激活環境后輸入命令:pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
到這里環境配置完成。
2.安裝webUI這里我們用text-generation-web-UI(可視化大模型web界面)
這里我們使用git命令下載,請先安裝git,也可以從清華鏡像站下載git-windows 版本安裝。
輸入命令:git clone https://github.com/oobabooga/text-generation-webui
克隆完成后我們進入該目錄
輸入命令:cd text-generation-webui-main
執行命令:pip install -r requirements.txt
啟動命令:python server.py
運行成功到本地瀏覽器輸入http://127.0.0.1:7860
下載Llama2-7B文件:
鏈接地址:
https://link.zhihu.com/?target=https%3A//pan.baidu.com/s/1777txQrnBsT0SydCLWtRGg%3Fpwd%3D8794
提取碼:8794
點進Llama2文件夾下載chinese-alpaca-2-7b-hf 文件夾
下載完成后放入text-generation-webui-main\models\

放好模型文件夾后到瀏覽器中加載,點擊load按鈕


image.png

開始聊天:


image.png

錯誤:
RuntimeError: Failed to import transformers.models.llama.modeling_llama because of the following error (look up to see its traceback):
DLL load failed while importing flash_attn_2_cuda:

解決:
pip uninstall torch torchvision torchaudio
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu121/torch_stable.html

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容