update
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
---
|
||||
title: chatglm3使用笔记
|
||||
tags:
|
||||
- AI
|
||||
- 学习笔记
|
||||
categories:
|
||||
- 学习笔记
|
||||
index_img: /img/2024/2/17/chatglm3.png
|
||||
banner_img: /img/2024/2/17/chatglm3.png
|
||||
permalink: /2024/02/16/chatglm3/index.html
|
||||
date: 2024-02-16 20:34:02
|
||||
---
|
||||
ChatGLM3是智谱AI和清华大学 KEG 实验室联合发布的对话预训练模型。
|
||||
ChatGLM3共有三种模型,如何选择请看[这里](https://modelscope.cn/models/ZhipuAI/chatglm3-6b/summary)
|
||||
实测windows 2022数据中心版+CUDA12.2+全部环境+anaconda+ChatGLM3-6b模型大约需要85G空间
|
||||
如果你没有GPU,那么可以来[启智](https://openi.pcl.ac.cn/user/sign_up?sharedUser=mei232)白嫖(真的白嫖,想充钱都充不了的,从前面的链接注册可以获得100积分,100积分在启智可以用11个小时A100,不过启智把内网穿透禁掉了,所以使用webui的模型没法跑)(其实也不是不能跑,就是自己改代码有点太麻烦了)
|
||||
## 软件安装
|
||||
运行ChatGLM3需要anaconda和Git,如果你的电脑上有,可以跳过这一部分。
|
||||
### anaconda
|
||||
在[这里](https://docs.anaconda.com/free/anaconda/install/)选择合适的anaconda安装,安装时记得勾选添加环境变量
|
||||
#### Conda 换源
|
||||
如果你的机器不在大陆或连接默认源很快,可以跳过这一步
|
||||
```shell
|
||||
# 首先,看一下目前conda源都有哪些内容
|
||||
conda info
|
||||
# 然后,删除并恢复默认的conda源
|
||||
conda config --remove-key channels
|
||||
```
|
||||
换源
|
||||
```shell
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
|
||||
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
|
||||
conda config --set show_channel_urls yes
|
||||
```
|
||||
### Git
|
||||
参照[这里](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)选择合适的Git安装(安装时直接一路点next就行)
|
||||
|
||||
## 下载模型
|
||||
具体如何让部署请参考模型官方仓库,这里只是一个示例(以从modelspace上使用Git下载为例)
|
||||
**三个模型按需选一个就行,不要全部下载**
|
||||
```shell
|
||||
# 安装Git LFS
|
||||
git lfs install
|
||||
# ChatGLM3-6b
|
||||
git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.git
|
||||
# ChatGLM3-6b-Base
|
||||
git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b-base.git
|
||||
# ChatGLM3-6B-32K
|
||||
git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b-32k.git
|
||||
```
|
||||
模型很大,可能需要等待较长时间
|
||||
## 环境部署
|
||||
执行以下命令新建一个 conda 环境并安装所需依赖:
|
||||
```shell
|
||||
conda create -n chatglm3-demo python=3.10
|
||||
# 如果这一步报错,试试 activate chatglm3-demo
|
||||
conda activate chatglm3-demo
|
||||
# 如果下载过慢请使用 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 更换pip源
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
### pytorch & CUDA
|
||||
默认安装的pytorch可能不带有CUDA支持,请参照一下步骤重装/安装带有CUDA支持的pytorch
|
||||
#### 安装带有CUDA支持的PyTorch
|
||||
```shell
|
||||
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu111/torch_stable.html
|
||||
```
|
||||
其中的cu111表示支持CUDA 11.1,自行替换为你的CUDA版本,在安装前记得先访问一下这个URL,看看你的CUDA版本是否受到支持
|
||||
**如果你的CUDA版本为12.2,可以安装支持CUDA12.1的pytorch**
|
||||
#### 验证安装
|
||||
安装完成后,可以在Python环境中检查PyTorch是否正确识别到了CUDA:
|
||||
```python
|
||||
import torch
|
||||
print(torch.cuda.is_available())
|
||||
```
|
||||
如果返回True,则说明PyTorch已成功启用CUDA支持
|
||||
|
||||
## 代码修改
|
||||
请先看完下面这部分内容,如果符合你的情况,你可以选择直接克隆我已经修改好仓库
|
||||
```shell
|
||||
# Github
|
||||
git clone https://github.com/ssdomei232/ChatGLM3-easydemo.git
|
||||
# 如果你访问GitHub比较困难,可以用下面这个
|
||||
git clone https://openi.pcl.ac.cn/mei232/ChatGLM3.git
|
||||
```
|
||||
ps:如果你觉得我弄的配色很丑,可以在右上角改掉
|
||||
如果你使用windows或带有桌面的linux,更推荐你使用`composite_demo`,如果你使用命令行的linux,请使用`basic_demo`体验
|
||||
### 模型量化
|
||||
默认情况下,模型以 FP16 精度加载,运行ChatGLM3-6b模型需要大概13GB显存。如果你的 GPU 显存有限,可以尝试以量化方式加载模型,使用方法如下:
|
||||
运行4-bit量化的ChatGLM3-6b模型大约需要8G显存.
|
||||
#### 综合demo
|
||||
如果你使用windows或带有桌面的linux,请看这部分内容
|
||||
找到`client.py` 130行左右
|
||||
```python
|
||||
self.model = AutoModel.from_pretrained(
|
||||
model_path,
|
||||
trust_remote_code=True,
|
||||
config=config,
|
||||
device_map="auto").eval()
|
||||
# add .quantize(4).cuda() before .eval() and remove device_map="auto" to use int4 model
|
||||
```
|
||||
改为
|
||||
```python
|
||||
self.model = AutoModel.from_pretrained(
|
||||
model_path,
|
||||
trust_remote_code=True,
|
||||
config=config,
|
||||
).quantize(4).cuda().eval()
|
||||
# add .quantize(4).cuda() before .eval() and remove device_map="auto" to use int4 model
|
||||
```
|
||||
`client.py `150行左右,
|
||||
```python
|
||||
self.model = AutoModel.from_pretrained(MODEL_PATH, trust_remote_code=True, device_map="auto").eval()
|
||||
```
|
||||
改为
|
||||
```python
|
||||
self.model = AutoModel.from_pretrained(MODEL_PATH, trust_remote_code=True).quantize(4).cuda().eval()
|
||||
```
|
||||
#### 命令行对话 Demo
|
||||
如果你使用命令行的linux,请看这部分内容
|
||||
找到cli_demo.py第八行左右
|
||||
```python
|
||||
model = AutoModel.from_pretrained(MODEL_PATH, trust_remote_code=True, device_map="auto").eval()
|
||||
```
|
||||
改为
|
||||
```python
|
||||
model = AutoModel.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True).quantize(4).cuda().eval()
|
||||
```
|
||||
|
||||
### 从本地加载模型
|
||||
如果你的机器位于某堵墙内或无法访问huggingface,有或者你已经提前下载好了模型,请看这部分内容
|
||||
#### 综合demo
|
||||
如果你使用windows或带有桌面的linux,请看这部分内容
|
||||
找到client.py第十八行左右
|
||||
```python
|
||||
MODEL_PATH = os.environ.get('MODEL_PATH', 'THUDM/chatglm3-6b')
|
||||
```
|
||||
改为
|
||||
```python
|
||||
# 模型文件放在同目录chatglm3-6b目录下,如果你想放在别处,请自行修改
|
||||
MODEL_PATH = 'chatglm3-6b'
|
||||
```
|
||||
#### 命令行对话 Demo
|
||||
如果你使用命令行的linux,请看这部分内容
|
||||
找到cli_demo.py第四行左右
|
||||
```python
|
||||
MODEL_PATH = os.environ.get('MODEL_PATH', 'THUDM/chatglm3-6b')
|
||||
```
|
||||
改为
|
||||
```python
|
||||
# 模型文件放在同目录chatglm3-6b目录下,如果你想放在别处,请自行修改
|
||||
MODEL_PATH = 'chatglm3-6b'
|
||||
```
|
||||
|
||||
## 运行
|
||||
### 综合demo
|
||||
```shell
|
||||
conda activate chatglm3-demo
|
||||
cd composite_demo
|
||||
streamlit run main.py
|
||||
```
|
||||
稍等一会加载模型,加载完浏览器会自动弹出到webui,若没有自动弹出,请查看命令行输出手动开启
|
||||
### 命令行对话 Demo
|
||||
```shell
|
||||
conda activate chatglm3-demo
|
||||
cd basic_demo
|
||||
python cli_demo.py
|
||||
```
|
||||
稍等一会加载模型,加载完就可以开始对话
|
||||
|
||||
### 温馨提示
|
||||
相当不建议你使用CPU来运行,除非你使用AMD的线程撕裂者之类的CPU,否则就不要难为电脑了.
|
||||
|
||||
## 参考资料
|
||||
[Conda 替换镜像源方法尽头,再也不用到处搜镜像源地址](https://blog.csdn.net/adreammaker/article/details/123396951)
|
||||
[THUDM/ChatGLM3: ChatGLM3 series: Open Bilingual Chat LLMs | 开源双语对话语言模型](https://github.com/THUDM/ChatGLM3)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: CUDA12.2使用支持CUDA的pytorch
|
||||
tags:
|
||||
- AI
|
||||
- python
|
||||
- 学习笔记
|
||||
categories:
|
||||
- 学习笔记
|
||||
index_img: /img/2024/2/17/torch.png
|
||||
banner_img: /img/2024/2/17/torch.png
|
||||
permalink: /2024/02/17/cuda122usepytorch/index.html
|
||||
date: 2024-02-17 11:36:55
|
||||
---
|
||||
如果你在nvidia官网安装了最新版的CUDA(CUDA12.2/12.3),但访问 [https://download.pytorch.org/whl/cu122/torch_stable.html](https://download.pytorch.org/whl/cu122/torch_stable.html) 就会发现pytorch并没有支持此版本的CUDA
|
||||
但是支持CUDA12.1的pytorch也可以支持CUDA12.2(看网上说CUDA12.3也可以支持,但没有试过)
|
||||
执行
|
||||
```shell
|
||||
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu121/torch_stable.html
|
||||
```
|
||||
来安装支持CUDA12.1的torch
|
||||
### 检查
|
||||
创建一个.py文件,内容为:
|
||||
```python
|
||||
import torch
|
||||
print(torch.cuda.is_available())
|
||||
```
|
||||
运行它,如果返回True,则说明PyTorch已成功启用CUDA支持
|
||||
如果返回False,那么重装一下torch或重启一下服务器应该就好了
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
title: GPT-sovits模型合集
|
||||
tags:
|
||||
- AI
|
||||
- TTS
|
||||
categories:
|
||||
- AI
|
||||
index_img: /img/2024/2/2/index.png
|
||||
banner_img: /img/2024/2/2/index.png
|
||||
permalink: /2024/02/02/202402021629/index.html
|
||||
date: 2024-02-02 16:30:00
|
||||
---
|
||||
GPT-sovits是一个简单好用的TTS模型,开源地址:
|
||||
[RVC-Boss/GPT-SoVITS: 1 min voice data can also be used to train a good TTS model! (few shot voice cloning)](https://github.com/RVC-Boss/GPT-SoVITS)
|
||||
运行这些模型不需要太大的显存,我测试时只需要2G甚至更少,但是训练最好使用更大的显存。
|
||||
**目前有的模型(以下载页实际为准,这里不长更新)**:
|
||||
* 神里凌华(v1)
|
||||
* 胡桃(v1)
|
||||
* 银狼(v1)
|
||||
* 三月七(v1)
|
||||
* 三月七低配版(v1)
|
||||
* 瓦尔特(v1)
|
||||
* 符玄(v1)
|
||||
* 温迪(v1)
|
||||
|
||||
**压缩包内的内容**:
|
||||
* 训练音频
|
||||
* 识别好的.list文件
|
||||
* GPT和Sovits微调模型
|
||||
|
||||
**注意事项**:
|
||||
* 本模型所用头像,形象,语音等等的所有权均归米哈游所有。只可用于二次创作。不得创作任何违反法律法规的内容,不得用于任何商业用途,不得二次配布。如有滥用行为,该模型将停止公开!
|
||||
* 发视频请注明模型训练者、整合包作者和数据集整理者。
|
||||
* V1的模型能用在V2上面,但是V2的模型不能用在V1上,并且V1模型在V2上效果不佳
|
||||
|
||||
数据集来源:https://www.bilibili.com/read/cv23965717/
|
||||
|
||||
### 下载:
|
||||
Newb(无需登录/注册): [https://newb.mei.lv/share/files/GPT-Sovits-models](https://c.mmeiblog.cn/share/share/files/GPT-Sovits-models)
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
title: linux中国归档站-Linuxcat
|
||||
tags:
|
||||
- linux
|
||||
categories:
|
||||
- 技术
|
||||
index_img: /img/2024/linuxcn-archive/finally.jpg
|
||||
banner_img: /img/2024/linuxcn-archive/finally.jpg
|
||||
permalink: /linuxcn.html
|
||||
date: 2024-02-25 11:29:54
|
||||
---
|
||||
在我看到[这篇文章](https://linux.cn/article-16603-1.html)后,我便想要将Linux中国的文章保留下来并渲染成我喜欢的主题,于是就有了[linuxcat.top](https://linuxcat.top/)
|
||||
|
||||
## 过程
|
||||
渲染 Linuxcat 的过程极其烦人, windows 的最大打开文件数使我无法再 windows 上进行渲染
|
||||
> User interface objects support only one handle per object. Processes cannot inherit or duplicate handles to user objects. Processes in one session cannot reference a user handle in another session.
|
||||
There is a theoretical limit of 65,536 user handles per session. However, the maximum number of user handles that can be opened per session is usually lower, since it is affected by available memory. There is also a default per-process limit of user handles. To change this limit, set the following registry value:
|
||||
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERProcessHandleQuota
|
||||
This value can be set to a number between 200 and 18,000.
|
||||
|
||||
Linuxcat 使用 149kf 渲染大约用了 15 分钟,加上传文件和删删改改耗费了近一天的时间。(Linuxcat 完整的索引文件高达200M)
|
||||
|
||||
### 修改数据
|
||||
头图和大图
|
||||
```shell
|
||||
shopt -s globstar
|
||||
sed 's|largepic|banner_img|g' -i **/*.md
|
||||
sed 's|pic|index_img|g' -i **/*.md
|
||||
```
|
||||
如果没有头图:
|
||||
```python
|
||||
import os
|
||||
import re
|
||||
|
||||
def replace_content(dir_path):
|
||||
for root, dirs, files in os.walk(dir_path):
|
||||
for file in files:
|
||||
if file.endswith('.md'):
|
||||
file_path = os.path.join(root, file)
|
||||
|
||||
with open(file_path, 'r+', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 查找并提取 banner_img 后面的内容
|
||||
match_banner = re.search(r'banner_img:\s*(.*)', content, re.IGNORECASE | re.MULTILINE)
|
||||
if match_banner:
|
||||
banner_img = match_banner.group(1).strip() # 去除两边空白字符
|
||||
|
||||
# 查找并替换 index_img 后面的内容
|
||||
match_index = re.search(r'index_img:\s*(.*)', content, re.IGNORECASE | re.MULTILINE)
|
||||
if match_index and 'islctt: false' in content:
|
||||
new_content = re.sub(r'index_img:\s*.*?\n', f'index_img: {banner_img}\n', content, flags=re.IGNORECASE | re.MULTILINE)
|
||||
|
||||
# 替换文件内容
|
||||
f.seek(0)
|
||||
f.truncate()
|
||||
f.write(new_content)
|
||||
|
||||
# 调用函数,指定要遍历的目录
|
||||
replace_content('_posts')
|
||||
```
|
||||
如果渲染是出现`Error: EMFILE, too many open files`报错,执行
|
||||
```shell
|
||||
ulimit -n 10000
|
||||
```
|
||||
如果还报错就把这个数改大点
|
||||
|
||||
## 有趣的发现
|
||||
在渲染Linux中国数据集的过程中,由于Linux中国文章时间跨度极大,不难发现一些有趣的东西
|
||||
### 人工智能
|
||||
打开[标签 - AI - Linuxcat](https://linuxcat.top/tags/AI/),Linux中国共编写了347篇与AI相关的文章,最早的一篇在2016年
|
||||
2017年共3篇,2018年5篇,2019年共4篇,2020年共10篇,2021年共34篇,2022年共81篇,2023年共187篇
|
||||
2024年1月共22篇(约为2023年平均篇数的141.2%)
|
||||
由此可以看出,人工智能的发展并不是突然暴起的,而是循序渐进的,若按照2023年的增速,2024年Linux中国可能会有超过300篇有关AI的文章
|
||||
|
||||
|
||||
## 参考资料
|
||||
[User Objects - Win32 apps | Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/sysinfo/user-objects)
|
||||
[Home · Linux-CN/archive Wiki (github.com)](https://github.com/Linux-CN/archive/wiki)
|
||||
|
||||
在此感谢Linux中国的全体贡献者,感谢他们创作/翻译了这么多优质的内容,感谢他们为中文开源社区做出的贡献
|
||||
@@ -0,0 +1,47 @@
|
||||
---
|
||||
title: VIVE XR 试玩体验
|
||||
tags:
|
||||
- MR
|
||||
- 试玩体验
|
||||
categories:
|
||||
- 试玩体验
|
||||
index_img: /img/2024/2/10/xr.jpg
|
||||
banner_img: /img/2024/2/10/xr.jpg
|
||||
permalink: /2024/02/10/202402102033/index.html
|
||||
date: 2024-02-10 20:33:57
|
||||
---
|
||||
最近寒假由于apple vision pro的火爆,所以对MR很感兴趣,所以找人借来了一台VIVE XR,不过写这篇文章的时候机器已经还回去了(因为不好玩)
|
||||
## 到手感觉
|
||||
到手时还是把原装盒子一块借给我了,装的也很整齐(看得出来这玩意不好玩),包装盒里有两个手柄,一坨电池,一个主体,几根线以及废纸若干。
|
||||
本体还是挺重的,虽然可以把电池部分拆掉,将前半部分当眼睛戴,但这样中心靠前,感觉好像马上就要掉下来一样。
|
||||
## 使用体验
|
||||
### 佩戴
|
||||
先把电池冲一下电,然后按照说明书操作一下,也可以直接拿充电宝/电脑插到眼睛上,会轻便一些,但会感觉很不稳,如果把后面一坨电池加上,会稳不少。
|
||||
### 启动
|
||||
打开就会先让你设定安全区域,不过如果选择圈定区域,会有十分烦人的bug,例如应用飞到远处拿不回来之类的,所以我用的原地模式,进入可以选择进入大厅或MR,大厅的观赏体验还是不错的,还有鲸鱼在大厅外面飞。MR如果在晚上开着灯效果很烂,显示不清晰,看电脑屏幕也看不清,白天也差不多,不过不太会出现频闪,但如果你所处的室内较暗,那么看向窗外会被闪瞎眼睛(雾)。
|
||||
### 显示
|
||||
单眼1080p的分辨率,能够明显看到像素点,目测使用这个看视频投到眼前的屏幕大约为40-50寸左右,像素密度和四五年前的电视差不多
|
||||
### 交互
|
||||
有两种交互方式,一种是拿手去捏,一种是使用手柄 </br>
|
||||
直接用手捏体验十分不好,有时候捏好几次都按不了 </br>
|
||||
用手柄操作就会舒服很多,但部分情况下对手抖人士很不友好,按键太小,需要两手稳定才能精准按下
|
||||
### 生态
|
||||
能用steamVR串流,自带的应用商店看起来很丰富,不过需要登录才能安装,就没有体验
|
||||
### 串流
|
||||
使用steamVR串流,支持局域网和有线,我只试了局域网串流,游戏为我的世界,VR版我的世界占用的资源很多,而且使用的Optifine为魔改版,很多光影都会崩溃。 </br>
|
||||
局域网串流体验没什么卡顿,但VR版我的世界并没有网上播的那么有趣,视角转动很僵硬,特殊的移动方式我主观体验也不是那么流畅 </br>
|
||||
当然你也可以把电脑屏幕串流过来,不过虽然大,但是像素密度大概率比你的显示器低,很不推荐你这样做
|
||||
### MR
|
||||
MR是VIVE XR的宣传重点之一,作为一台2023年初的机器,它的效果在当时应该算很好的,但比不上HTC目前在售的产品与火爆的apple vision pro </br>
|
||||
在使用是几乎感觉不到操作有延迟(我完全感觉不到),不细看的话确实跟没戴差不多,但仅限光照适宜的环境下,VIVE XR的曝光控制很烂,极其容易过曝 </br>
|
||||
空间定位还是很准确的,把视角转开再走几步应用还是飘在原地
|
||||
## 总结
|
||||
个人感觉VIVE XR像是一台半成品,很多功能并不完善,也有不少操作逻辑上的问题(VIVE XR中的应用不能拖来拖去),但是基础功能已经比较完善了,不过现在VIVE XR已经不在销售了,即使是二手,我认为也不是一个体验VR的好设备
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
免责声明:本文内容仅代表作者个人观点,不构成任何购买建议。作者不对因读者参考本文内容而做出的购买决策所产生的任何直接或间接后果承担责任。
|
||||
Reference in New Issue
Block a user