文章目录
chatglm文本生成入门级教程,其中原理性不在赘述,实操如下:
一. 虚拟环境创建
- 建立虚拟环境
conda create -n xxx python==x.x
其中xxx为你要建立的虚拟环境的名字,自定义即可。pythonx.x为这个环境要使用的python版本。比如建立使用python3.8版本的名字为py38的虚拟环境:conda create -n py38 python3.8 - 激活环境
conda activate xxx
其中xxx为(1)中xxx,即虚拟环境名称。比如:conda activate py38
- 进入虚拟环境后,安装所需的包,如果网速慢,可以用阿里源或是豆瓣等
例如
pip install ultralytics -i https://pypi.tuna.tsinghua.edu.cn/simple
其他所需命令:
退出当前虚拟环境:conda deactivate
下述命令在退出当前虚拟环境才能用:
删除环境:conda remove -n xxx --all
查看现有虚拟环境:conda env list
查看环境中的包:conda list
建立虚拟环境conda create -n xxx python==x.x安装报错:
解决办法:
conda config --show-sources
修改文件为:
ssl_verify: True
channels:
4. http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
5. http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
6. default
7. conda-forge
show_channel_urls: True
原有
channels:
8. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
9. https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
10. defaults
show_channel_urls: true
查看gpu使用情况:nvidia-smi
二. chatglm-6b模型文件下载
一般是进入huggingface官网下载,但目前官网进不去
-
进入虚拟环境
-
安装依赖:pip install -U huggingface_hub
-
export HF_ENDPOINT=https://hf-mirror.com
-
huggingface-cli download --resume-download --local-dir-use-symlinks False bigscience/bloom-560m --local-dir bloom-560m
其中bigscience/bloom-560m是需要下载的模型,local-dir是要下载到的本地路径 -
或者使用modelscope下载
三. chatglm-6b源代码下载
一般要去github上下载,目前同样进不去
git clone https://gitcode.com/THUDM/ChatGLM2-6B.git
或者进入gitcode网站下载
四. 安装模型依赖
下载源代码后,会生成一个chatglm-6b的路径
cd chatglm-6b
pip install -r requirements.txt