专业的郑州网站推广,平泉市住房和城乡建设局网站,网站备案注销申请书,郑州网站模板大模型这里更新是挺快的#xff0c;我参考的视频教程就和我这个稍微有些不一样#xff0c;这距离教程发布只过去4天而已… 不过基本操作也差不多 AutoDL算力云#xff1a;https://www.autodl.com/home ChatGLM3#xff1a;https://github.com/THUDM/ChatGLM3/tree/main Hug… 大模型这里更新是挺快的我参考的视频教程就和我这个稍微有些不一样这距离教程发布只过去4天而已… 不过基本操作也差不多 AutoDL算力云https://www.autodl.com/home ChatGLM3https://github.com/THUDM/ChatGLM3/tree/main Hugging Facehttps://huggingface.co/THUDM/chatglm3-6b/tree/main 视频教程https://www.bilibili.com/video/BV1E94y1V7Lz 租用 按量计费 注册账号。新用户有免费一个月的会员学生的话认证后每次认证有一年的会员会员95折能便宜一点是一点 租用一个3090的GPU有很多地区选多点点找个便宜的就行 基础镜像里面的pytorch选最新的就行 需要注意cuda版本不能超过当前主机最高支持的版本 租用完成后在控制台页面先关机然后选择以无卡方式启动这个省钱毕竟部署的时候还不需要GPU 使用jupyterLab打开 点击进入数据盘【autodl-tmp】在数据盘打开终端 在终端中执行后续操作 部署
开启学术加速
source /etc/network_turbo初始化git lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bashsudo apt-get install git-lfs克隆github仓库
git clone https://github.com/THUDM/ChatGLM3到ChatGLM3目录下
cd ChatGLM3clear升级pip
python -m pip install --upgrade pip安装依赖【看见successfully就表示安装成功】
pip install -r requirements.txt拉取 Hugging Face下的模型 根据官方的如果从 HuggingFace 下载比较慢也可以从 ModelScope 中下载。 使用这个我也试了确实是快一些可以直接跳到第十步后面几步都不需要执行了 git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.gitgit clone https://huggingface.co/THUDM/chatglm3-6b拉取的时候大的模型文件可能拉不下来需要手动下载。如果【chatglm3-6b】文件夹下有以下10个文件可以按【CtrlC】终止git克隆手动安装模型权重文件 依次执行以下代码下载模型权重文件 一定要在chatglm3-6b文件夹下执行 cd chatglm3-6bwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00001-of-00007.binwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00002-of-00007.binwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00003-of-00007.binwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00004-of-00007.binwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00005-of-00007.binwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00006-of-00007.binwget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model-00007-of-00007.bin关机重启因为刚才是以无卡模式启动的现在需要跑模型了需要使用GPU。
测试
修改模型路径。打开【basic_demo】文件夹下的cli_demo.py文件将里面的model_path改为你刚才下载Hugging Face里面的模型的路径【“…/chatglm3-6b/”】 关于这个路径的问题大家一定要看好你执行的这个文件相对于模型文件夹的位置关系ChatGLM另一个git仓库有的python文件没有放到文件夹中直接就在根目录里面了 如果路径不对他就会报错说你的格式不对***之类的这时候不要怀疑你之前没有作对仅仅只是路径没写对 # 一些报错huggingface_hub.utils._validators.HFValidationError: Repo id must use alphanumeric chars or -, _, ., -- and .. are forbidden, - and . cannot start or end the name, max length is 96: chatglm3-6b/.OSError: ChatGLM3/chatglm3-6b is not a local folder and is not a valid model identifier listed on https://huggingface.co/models
If this is a private repository, make sure to pass a token having permission to this repo with use_auth_token or log in with huggingface-cli login and pass use_auth_tokenTrue.运行cli_demo.py在终端窗口内进行对话
cd basic_demo
python cli_demo.py运行基于gradio的网页端的模型web_demo.py 运行生成的网址是不能直接访问的根据官方的教程安装Windows桌面工具下载 然后就可以在本地访问gradio生成的网页 下面streamlit 生成的网页也是这样但是streamlit生成的网址我们只需要访问这个端口号就行直接点击那个生成的网址即使挂代理了也打不开 python web_demo.py运行基于streamlit 的网页端的模型web_demo2.py 直接访问端口号不用访问他生成的 streamlit run web_demo2.py综合 Demo 集成了以下功能 Chat: 对话模式在此模式下可以与模型进行对话。Tool: 工具模式模型除了对话外还可以通过工具进行其他操作。Code Interpreter: 代码解释器模式模型可以在一个 Jupyter 环境中执行代码并获取结果以完成复杂任务。 新建一个 conda 环境并安装所需依赖
conda create -n chatglm3-demo python3.10source activatesource deactivateconda activate chatglm3-demopip install -r requirements.txt使用 Code Interpreter 还需要安装 Jupyter 内核
ipython kernel install --name chatglm3-demo --user运行
streamlit run main.py