Compare commits
12 Commits
0a79961014
...
5ea36e5f62
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea36e5f62 | |||
| ffff2aae4c | |||
| cd3db8547c | |||
| 9370b911ec | |||
| c9dbe02e20 | |||
| a72cc8fe83 | |||
| 915e4b8e69 | |||
| 854219f7a0 | |||
| fd6471e64e | |||
| b6ca38d72b | |||
| 11558c4481 | |||
| 06ac10c8fb |
@ -39,7 +39,6 @@ highlight_shrink: false #true代码框不展开,需点击 '>' 打开 false展
|
||||
code_word_wrap: true
|
||||
index_img: https://gcore.jsdelivr.net/gh/volantis-x/cdn-wallpaper/abstract/BBC19066-E176-47C2-9D22-48C81EE5DF6B.jpeg
|
||||
archive_img: https://gcore.jsdelivr.net/gh/volantis-x/cdn-wallpaper/abstract/67239FBB-E15D-4F4F-8EE8-0F1C9F3C4E7C.jpeg
|
||||
|
||||
# Footer设置
|
||||
since: 2022
|
||||
footer_custom_text: Hi, welcome to my Xiaowen blog!
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
"dependencies": {
|
||||
"cheerio": "^0.22.0",
|
||||
"hexo": "^6.3.0",
|
||||
"hexo-asset-image": "^1.0.0",
|
||||
"hexo-asset-img": "^1.2.0",
|
||||
"hexo-deployer-git": "^3.0.0",
|
||||
"hexo-generator-archive": "^2.0.0",
|
||||
"hexo-generator-category": "^2.0.0",
|
||||
@ -31,5 +31,6 @@
|
||||
"hexo-theme-volantis": "^5.7.6",
|
||||
"hexo-wordcount": "^6.0.1",
|
||||
"save": "^2.9.0"
|
||||
}
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ CentOS占CPU Docker CPU引擎占用低
|
||||
|
||||
```shell
|
||||
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
|
||||
# 另一种方式
|
||||
# 另一种方式
|
||||
curl -sSL https://get.daocloud.io/docker | sh
|
||||
# 如上述两种方式都不行
|
||||
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
|
||||
@ -49,7 +49,7 @@ dnf list docker-ce --showduplicates | sort -r
|
||||
# 安装Docker CE
|
||||
dnf install docker-ce-3:24.0.7-1.el9 -y
|
||||
# 镜像源配置
|
||||
vim /etc/docker/daemon.json
|
||||
vim /etc/docker/daemon.json
|
||||
```
|
||||
|
||||
## Ubuntu
|
||||
@ -99,7 +99,7 @@ permission denied while trying to connect to the Docker daemon socket at unix://
|
||||
|
||||
```bash
|
||||
cat /etc/group | grep docker
|
||||
|
||||
|
||||
docker:x:988:
|
||||
```
|
||||
|
||||
@ -180,7 +180,7 @@ sed -e 's/"//g' -e "s/name:/$1:/g" -e "s/{count:/$1总版本数-/"
|
||||
docker-tags脚本编辑好之后,需要通过chmod修改文件权限才可以执行。在权限修改完成之后,就可以使用docker-tags脚本来查询相关镜像的最近版本信息了。
|
||||
|
||||
```shell
|
||||
chmod 777 docker-tags
|
||||
chmod 777 docker-tags
|
||||
./docker-tags ubuntu
|
||||
```
|
||||
|
||||
@ -189,7 +189,7 @@ chmod 777 docker-tags
|
||||
```shell
|
||||
# 第一步:新建或编辑daemon.json
|
||||
vim /etc/docker/daemon.json
|
||||
|
||||
|
||||
# 第二步:daemon.json中编辑如下
|
||||
{
|
||||
"registry-mirrors": [
|
||||
@ -204,10 +204,10 @@ vim /etc/docker/daemon.json
|
||||
"https://docker.xiaogenban1993.com"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
# 第三步:重启docker
|
||||
systemctl restart docker.service
|
||||
|
||||
|
||||
# 第四步:执行docker info查看是否修改成功
|
||||
docker info
|
||||
|
||||
@ -259,7 +259,7 @@ docker inspect <IMAGE ID>
|
||||
### 运行容器
|
||||
|
||||
```shell
|
||||
# 第一个8080是外部海豚上的 第二个8080是内部集装箱上的
|
||||
# 第一个8080是外部海豚上的 第二个8080是内部集装箱上的
|
||||
docker run -p 8080:8080
|
||||
```
|
||||
|
||||
@ -331,7 +331,7 @@ docker inspect <container id>
|
||||
```shell
|
||||
docker pull hello-world
|
||||
docker pull nginx
|
||||
docker save -o images.tar nginx hello-world
|
||||
docker save -o images.tar nginx hello-world
|
||||
ll images.tar
|
||||
```
|
||||
|
||||
@ -343,14 +343,14 @@ ll images.tar
|
||||
|
||||
```shell
|
||||
docker load -i images.tar
|
||||
docker images
|
||||
docker images
|
||||
```
|
||||
|
||||
## Docker 容器快照的导出和导入
|
||||
|
||||
### 容器快照的导出
|
||||
|
||||
当容器文件修改之后,可以通过`docker export`命令将容器以快照的形式导出到文件。其命令的格式为`docker export 容器名 > 快照文件名`。和镜像导出不同,快照的导出,会将容器的镜像,和容器在镜像之上的修改部分同时导出
|
||||
当容器文件修改之后,可以通过`docker export`命令将容器以快照的形式导出到文件。其命令的格式为`docker export 容器名 > 快照文件名`。**导出容器会丢失历史记录和元数据,类似与快照。**
|
||||
|
||||
```shell
|
||||
docker export python-1 > python-snapshot.tar
|
||||
@ -359,7 +359,7 @@ ll python-snapshot.tar
|
||||
|
||||
### 容器快照的导入
|
||||
|
||||
对于通过`docker export`导出的容器快照文件。可以通过`docker import`命令将其导入到docker中,在这里需要特别注意的是:`docker import是以镜像而不是容器的形式导入快照`。也就是说导入的快照并不能直接运行,而是需要根据此快照镜像再次创建容器才可以使用。`docker import`命令的格式为`docker import 快照文件 导入镜像名称:版本号`
|
||||
对于通过`docker export`导出的容器快照文件。可以通过`docker import`命令将其导入到docker中,在这里需要特别注意的是:`docker import是以镜像而不是容器的形式导入快照`。也就是说导入的快照并不能直接运行,而是需要根据此快照镜像再次创建容器才可以使用。`docker import`命令的格式为`docker import 快照文件 导入镜像名称:版本号` **启动export与import命令导出导入的镜像必须加/bin/bash或者其他/bin/sh,否则会报错。**
|
||||
|
||||
```shell
|
||||
docker import python-snapshot.tar python-snapshot:latest
|
||||
@ -378,7 +378,7 @@ docker save new_image_name > image.tar
|
||||
|
||||
### 导入容器镜像
|
||||
|
||||
迁移到 B 服务器上
|
||||
迁移到 B 服务器上cd
|
||||
|
||||
```shell
|
||||
docker load < image.tar
|
||||
@ -403,6 +403,8 @@ docker load < image.tar
|
||||
|
||||
将A服务器宿主机的目录备份到B服务器上
|
||||
|
||||
## Docker 网络 network
|
||||
|
||||
|
||||
|
||||
## Docker 容器与宿主机时间不同步
|
||||
@ -458,7 +460,7 @@ docker start <container id>
|
||||
修改线上容器--restart参数值
|
||||
|
||||
```shell
|
||||
docker update --restart=no [容器名]
|
||||
docker update --restart=no [容器名]
|
||||
docker update --restart=always [容器名]
|
||||
docker update --restart=on-failure:3 [容器名]
|
||||
```
|
||||
@ -570,7 +572,7 @@ Dockerfile 是一个用来构建镜像的文本文件,文本内容包含了一
|
||||
docker build -t nginx:v3 .
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
### 上下文路径
|
||||
|
||||
@ -590,26 +592,26 @@ docker build -t nginx:v3 .
|
||||
|
||||
### 指令详解
|
||||
|
||||
| Dockerfile 指令 | 说明 |
|
||||
| --------------- | ------------------------------------------------------------ |
|
||||
| FROM | 指定基础镜像,用于后续的指令构建。 |
|
||||
| MAINTAINER | 指定Dockerfile的作者/维护者。(已启用,推荐使用LABEL指令) |
|
||||
| LABEL | 添加镜像的元数据,使用键值对的形式。 |
|
||||
| RUN | 在构建过程中在镜像中执行命令。 |
|
||||
| CMD | 指定容器创建时的默认命令。(可以被覆盖) |
|
||||
| ENTRYPOINT | 设置容器创建时的主要命令。(不可被覆盖) |
|
||||
| EXPOSE | 声明容器运行时监听的特定网络端口。 |
|
||||
| ENV | 在容器内部设置环境变量。 |
|
||||
| ADD | 将文件、目录或远程URL复制到镜像中。 |
|
||||
| COPY | 将文件或目录复制到镜像中。 |
|
||||
| VOLUME | 为容器创建挂载点或声明卷。 |
|
||||
| WORKDIR | 设置后续指令的工作目录。 |
|
||||
| USER | 指定后续指令的用户上下文。 |
|
||||
| Dockerfile 指令 | 说明 |
|
||||
| --------------- | ------------------------------------------------------------------ |
|
||||
| FROM | 指定基础镜像,用于后续的指令构建。 |
|
||||
| MAINTAINER | 指定Dockerfile的作者/维护者。(已启用,推荐使用LABEL指令) |
|
||||
| LABEL | 添加镜像的元数据,使用键值对的形式。 |
|
||||
| RUN | 在构建过程中在镜像中执行命令。 |
|
||||
| CMD | 指定容器创建时的默认命令。(可以被覆盖) |
|
||||
| ENTRYPOINT | 设置容器创建时的主要命令。(不可被覆盖) |
|
||||
| EXPOSE | 声明容器运行时监听的特定网络端口。 |
|
||||
| ENV | 在容器内部设置环境变量。 |
|
||||
| ADD | 将文件、目录或远程URL复制到镜像中。 |
|
||||
| COPY | 将文件或目录复制到镜像中。 |
|
||||
| VOLUME | 为容器创建挂载点或声明卷。 |
|
||||
| WORKDIR | 设置后续指令的工作目录。 |
|
||||
| USER | 指定后续指令的用户上下文。 |
|
||||
| ARG | 定义在构建过程中传递给构建器的变量,可使用"docker build"命令设置。 |
|
||||
| ONBUILD | 当该镜像被用作另一个构建过程的基础时,添加触发器。 |
|
||||
| STOPSIGNAL | 设置发送给容器以退出的系统调用信号。 |
|
||||
| HEALTHCHECK | 定义周期性检查容器健康状态的命令。 |
|
||||
| SHELL | 覆盖Docker中默认的shell,用于RUN、CMD和ENTRYPOINT。 |
|
||||
| ONBUILD | 当该镜像被用作另一个构建过程的基础时,添加触发器。 |
|
||||
| STOPSIGNAL | 设置发送给容器以退出的系统调用信号。 |
|
||||
| HEALTHCHECK | 定义周期性检查容器健康状态的命令。 |
|
||||
| SHELL | 覆盖Docker中默认的shell,用于RUN、CMD和ENTRYPOINT。 |
|
||||
|
||||
#### COPY
|
||||
|
||||
@ -847,7 +849,7 @@ redis-server /usr/local/etc/redis/redis.conf
|
||||
# 如报错
|
||||
mkdir -p /usr/redis/bin
|
||||
# 测试连接
|
||||
redis-cli -a <master-password>
|
||||
redis-cli -a <master-password>
|
||||
```
|
||||
|
||||
redis-slave1
|
||||
@ -1022,7 +1024,7 @@ docker run -d -p 15432:5432 --name postgres16 --restart=always -v /usr/local/doc
|
||||
## Docker 安装 Timescaledb
|
||||
|
||||
```shell
|
||||
docker run -d -p 15433:5432 --name timescaledb-pg16 --restart=always -v /usr/local/docker/timescaledb-pg16/pgdata/data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=Wyd210213 timescale/timescaledb:latest-pg16
|
||||
docker run -d -p 15433:5432 --name timescaledb-pg16 --restart=always -v /usr/local/docker/timescaledb-pg16/pgdata/data:/var/lib/postgresql/data -v /etc/localtime:/etc/localtime:ro -e POSTGRES_PASSWORD=Wyd210213 -e TZ=Asia/Shanghai timescale/timescaledb:latest-pg16
|
||||
```
|
||||
|
||||
|
||||
@ -1049,7 +1051,7 @@ docker run \
|
||||
|
||||
```shell
|
||||
mkdir -p /usr/local/docker/mysql57
|
||||
# 宿主机创建配置文件目录映射到容器
|
||||
# 宿主机创建配置文件目录映射到容器
|
||||
mkdir -p /usr/local/docker/mysql57/conf #(需要在此目录下创建"conf.d"、"mysql.conf.d"两个目录)
|
||||
mkdir -p /usr/local/docker/mysql57/conf/conf.d # (建议在此目录创建my.cnf文件并进行相关MySQL配置)
|
||||
mkdir -p /usr/local/docker/mysql57/conf/mysql.conf.d
|
||||
@ -1078,14 +1080,14 @@ mysql -uroot -p
|
||||
# 查看 /etc/mysql/my.cnf 文件权限
|
||||
ls -l /etc/mysql/my.cnf
|
||||
# 如果看到以下输出
|
||||
# -rwxrwxrwx 1 root root 1234 Jan 1 00:00 /etc/mysql/my.cnf
|
||||
# -rwxrwxrwx 1 root root 1234 Jan 1 00:00 /etc/mysql/my.cnf
|
||||
# 那么说明该配置文件确实是对所有人开放了读、写和执行权利。
|
||||
# 接着我们需要修改这个文件的权限,使其只有root用户有读写权,其他用户只有读的权限:
|
||||
chmod 644 /etc/mysql/my.cnf
|
||||
# 再次使用 ls -l命令查看'/etc/mysql/my.cnf'的权限
|
||||
ls -l /etc/mysql/my.cnf
|
||||
# 看到以下输出,则修改成功
|
||||
# -rw-r--r-- 1 root root 1234 Jan 1 00:00 /etc/mysql/my.cnf
|
||||
# -rw-r--r-- 1 root root 1234 Jan 1 00:00 /etc/mysql/my.cnf
|
||||
```
|
||||
|
||||
## Docker 安装 Redis 7
|
||||
@ -1439,7 +1441,7 @@ docker run -p 9000:9000 -p 9001:9001 \
|
||||
-v /usr/local/docker/minio/config:/root/.minio \
|
||||
minio/minio server \
|
||||
/data \
|
||||
--console-address ":9001"
|
||||
--console-address ":9001"
|
||||
|
||||
```
|
||||
|
||||
@ -1448,7 +1450,7 @@ minio/minio server \
|
||||
```shell
|
||||
docker run -d -p 8080:8080 --name tomcat9 \
|
||||
-v /usr/local/docker/tomcat9/webapps:/usr/local/tomcat/webapps \
|
||||
-v /usr/local/docker/tomcat9/logs/:/usr/local/tomcat/logs \
|
||||
-v /usr/local/docker/tomcat9/logs:/usr/local/tomcat/logs \
|
||||
tomcat:9.0.41-jdk8-corretto
|
||||
```
|
||||
|
||||
|
||||
@ -52,6 +52,52 @@ hexo new [layout] <title>
|
||||
|
||||
新建一篇文章。如果没有设置 `layout` 的话,默认使用 [_config.yml](https://hexo.io/zh-cn/docs/configuration) 中的 `default_layout` 参数代替。如果标题包含空格的话,请使用引号括起来。
|
||||
|
||||
## 图片上传
|
||||
|
||||
### 本地目录
|
||||
|
||||
**先将 _config.yml 文件中的 post_asset_folder 选项设为 true**
|
||||
|
||||
该操作的目的就是在使用`hexo new xxx`指令新建md文档博文时,在相同路径下同步创建一个`xxx`文件夹,而`xxx`文件夹就是用来存放新建md文档里的图片的
|
||||
|
||||

|
||||
|
||||
就像这样,新建的md文档和其对于的同名文件夹都在/source/_posts路径下
|
||||
|
||||
但如果你习惯不用hexo new xxx指令创建新md文档,而是直接打开typora写然后保存到/source/_posts下,这个时候你就需要自己手动创建一个**同名的文件夹**才可以。
|
||||
|
||||
#### 解决图片路径问题
|
||||
|
||||
typora的图片插入的语法我是一般不会用的,大多数时候就是复制粘贴图片到md文档里面。这个时候我们再慢慢修改路径到上面我们创建的文件夹下面就太麻烦了。
|
||||
|
||||
我们可以通过以下设置来舒舒服服按照简单粗暴的复制粘贴插入图片:
|
||||
|
||||
**打开typora,点击文件,点击偏好设置,点击图像**
|
||||
|
||||

|
||||
|
||||
第一个,将图片复制到指定路径./$(filename)的效果就是:**我们粘贴图片到md文档的时候,typora会自动把图片再复制一份到我们上面创建的同名文件夹下**
|
||||
|
||||
这样的好处还有一点,就是也不用我们自己创建同名文件夹了,typora会自己帮我们创建(有的话就复制到这里面)(**但 _config.yml文件中的post_asset_folder选项还是得设为 true,这是必须的**)
|
||||
|
||||
效果就像这样:
|
||||
|
||||

|
||||
|
||||
#### 解决md文档转换到html文档路径不一样的问题
|
||||
|
||||
转换需要用到**hexo-asset-img**插件
|
||||
|
||||
在博客的源码文件夹下启动命令行,下载插件hexo-asset-img:
|
||||
|
||||
```shell
|
||||
yarn add hexo-asset-img
|
||||
```
|
||||
|
||||
是**hexo-asset-img**,**不是**其他文章里写的**hexo-asset-image**,这也是我之前用了不好使的原因
|
||||
|
||||
# Butterfly 主题
|
||||
|
||||
## 鼠标样式修改
|
||||
|
||||
1. 在\themes\butterfly\source\css路径下创建一个mouse.css文件,在文件中添加如下代码:
|
||||
@ -79,3 +125,43 @@ hexo new [layout] <title>
|
||||
|
||||
|
||||
3. 重新部署,即可看到效果
|
||||
|
||||
## 增加网站备案信息
|
||||
|
||||
找到`themes/butterfly/layout/includes/footer.pug`文件
|
||||
|
||||
在文件 `if theme.footer.copyright`中增加
|
||||
|
||||
```pug
|
||||
br
|
||||
center
|
||||
| ICP备案号:
|
||||
a(href="https://beian.miit.gov.cn" target="_blank") 辽ICP备2025052969号-1
|
||||
```
|
||||
|
||||
完整如下:
|
||||
|
||||
```pug
|
||||
#footer-wrap
|
||||
if theme.footer.owner.enable
|
||||
- var now = new Date()
|
||||
- var nowYear = now.getFullYear()
|
||||
if theme.footer.owner.since && theme.footer.owner.since != nowYear
|
||||
.copyright!= `©${theme.footer.owner.since} - ${nowYear} By ${config.author}`
|
||||
else
|
||||
.copyright!= `©${nowYear} By ${config.author}`
|
||||
if theme.footer.copyright
|
||||
.framework-info
|
||||
span= _p('footer.framework') + ' '
|
||||
a(href='https://hexo.io')= 'Hexo'
|
||||
span.footer-separator |
|
||||
span= _p('footer.theme') + ' '
|
||||
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
|
||||
br
|
||||
center
|
||||
| ICP备案号:
|
||||
a(href="https://beian.miit.gov.cn" target="_blank") 辽ICP备2025052969号-1
|
||||
if theme.footer.custom_text
|
||||
.footer_custom_text!=`${theme.footer.custom_text}`
|
||||
```
|
||||
|
||||
|
||||
BIN
source/_posts/Hexo/image-20250519143309765.png
Normal file
BIN
source/_posts/Hexo/image-20250519143309765.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
BIN
source/_posts/Hexo/image-20250519143418309.png
Normal file
BIN
source/_posts/Hexo/image-20250519143418309.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
BIN
source/_posts/Hexo/image-20250519143457653.png
Normal file
BIN
source/_posts/Hexo/image-20250519143457653.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@ -1127,6 +1127,211 @@ xfs_growfs /dev/rl/root
|
||||
|
||||

|
||||
|
||||
## 转换分区格式
|
||||
|
||||
### Microsoft 基本数据 -> Linux 文件系统
|
||||
|
||||
```shell
|
||||
fdisk -l
|
||||
...
|
||||
Disk /dev/sdb:2.18 TiB,2400476553216 字节,4688430768 个扇区
|
||||
磁盘型号:DL2400MM0159
|
||||
单元:扇区 / 1 * 512 = 512 字节
|
||||
扇区大小(逻辑/物理):512 字节 / 4096 字节
|
||||
I/O 大小(最小/最佳):4096 字节 / 4096 字节
|
||||
磁盘标签类型:gpt
|
||||
磁盘标识符:6C271C0A-2A82-416E-8A0F-A49EF6D9BA33
|
||||
设备 起点 末尾 扇区 大小 类型
|
||||
/dev/sdb1 2048 4688429055 4688427008 2.2T Microsoft 基本数据
|
||||
...
|
||||
```
|
||||
|
||||
通过查看都为 Microsoft 基本数据 硬盘类型,需要转换成Linux系统能够识别的 Linux 文件系统
|
||||
先将 /dev/sdb 进行转换
|
||||
|
||||
```shell
|
||||
fdisk /dev/sdb
|
||||
# 输入 t 命令 代表转换分区类型
|
||||
t
|
||||
# 20 代表 Linux file system
|
||||
20
|
||||
# 输入 w 命令 代表改动由内存写入到硬盘中
|
||||
```
|
||||
|
||||
手动挂载硬盘
|
||||
|
||||
```shell
|
||||
mkdir /sdb
|
||||
mount -t ext3 /dev/sdb1 /sdb
|
||||
```
|
||||
|
||||
没有报错后,可查看磁盘情况
|
||||
|
||||
```shell
|
||||
df -Th
|
||||
devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev
|
||||
tmpfs tmpfs 16G 0 16G 0% /dev/shm
|
||||
tmpfs tmpfs 6.2G 19M 6.2G 1% /run
|
||||
efivarfs efivarfs 304K 129K 171K 43% /sys/firmware/efi/efivars
|
||||
/dev/mapper/almalinux-root xfs 382G 16G 367G 5% /
|
||||
/dev/sda2 xfs 960M 416M 545M 44% /boot
|
||||
/dev/sda1 vfat 200M 7.1M 193M 4% /boot/efi
|
||||
tmpfs tmpfs 3.1G 100K 3.1G 1% /run/user/0
|
||||
/dev/sdb1 ext3 2.2T 72G 2.0T 4% /sdb
|
||||
```
|
||||
|
||||
看到已经挂载上了,也可以访问了
|
||||
|
||||
系统重启后,挂载会失效,需再改动 /etc/fstab 文件,让其自动挂载
|
||||
|
||||
需查看要挂载的硬盘的UUID,以device方式去挂载,会导致重启后发生盘符交换问题
|
||||
|
||||
查看硬盘的UUID,通过 `blkid`查看
|
||||
|
||||
```shell
|
||||
blkid /dev/sdb1
|
||||
/dev/sdb1: UUID="7d592b46-68dc-41c2-bdb3-7ee410f0bb33" TYPE="ext4" PARTUUID="cc75a3e5-bbfa-4abb-a749-241183f41510"
|
||||
```
|
||||
|
||||
然后修改 /etc/fstab 文件,添加到对应硬盘前即可
|
||||
|
||||
```shell
|
||||
vim /etc/fstab
|
||||
#
|
||||
# /etc/fstab
|
||||
# Created by anaconda on Fri May 16 02:20:43 2025
|
||||
#
|
||||
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
|
||||
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
|
||||
#
|
||||
# After editing this file, run 'systemctl daemon-reload' to update systemd
|
||||
# units generated from this file.
|
||||
#
|
||||
/dev/mapper/almalinux-root / xfs defaults 0 0
|
||||
UUID=d99ec15b-05d5-4311-b5c7-497945d4805d /boot xfs defaults 0 0
|
||||
UUID=0EAB-5879 /boot/efi vfat umask=0077,shortname=winnt 0 2
|
||||
/dev/mapper/almalinux-swap none swap defaults 0 0
|
||||
# 此处追加下面硬盘信息
|
||||
UUID=7d592b46-68dc-41c2-bdb3-7ee410f0bb33 /sdb ext3 defaults 0 0
|
||||
```
|
||||
|
||||
修改 /etc/fstab 文件后,需系统重载配置,才可应用
|
||||
|
||||
```shell
|
||||
systemctl daemon-reload
|
||||
```
|
||||
|
||||
### ext3 升级 ext4
|
||||
|
||||
确认当前文件系统类型
|
||||
|
||||
```shell
|
||||
df -Th | grep /dev/sdb1
|
||||
/dev/sdb1 ext3 2.2T 60G 2.0T 3% /sdb
|
||||
```
|
||||
|
||||
卸载目标分区(⚠️ 注意:不能对正在使用的根分区操作)
|
||||
|
||||
```shell
|
||||
umount /dev/sdb1
|
||||
```
|
||||
|
||||
检查并修复文件系统
|
||||
|
||||
```shell
|
||||
e2fsck -f /dev/sdb1
|
||||
|
||||
e2fsck 1.46.5 (30-Dec-2021)
|
||||
第 1 步:检查inode、块和大小
|
||||
第 2 步:检查目录结构
|
||||
第 3 步:检查目录连接性
|
||||
第 4 步:检查引用计数
|
||||
第 5 步:检查组概要信息
|
||||
/dev/sdb1:26748/146513920 文件(15.5% 为非连续的), 24877668/586053376 块
|
||||
```
|
||||
|
||||
确保文件系统无错误。
|
||||
|
||||
将 ext3 转换为 ext4
|
||||
|
||||
```shell
|
||||
tune2fs -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize /dev/sdb1
|
||||
tune2fs 1.46.5 (30-Dec-2021)
|
||||
```
|
||||
|
||||
查看转换是否成功
|
||||
|
||||
```shell
|
||||
dumpe2fs -h /dev/sdb1 | grep features
|
||||
dumpe2fs 1.46.5 (30-Dec-2021)
|
||||
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
|
||||
Journal features: journal_incompat_revoke
|
||||
```
|
||||
|
||||
确认输出中包含你刚刚添加的特性,例如:
|
||||
|
||||
extent
|
||||
huge_file
|
||||
flex_bg
|
||||
uninit_bg
|
||||
dir_nlink
|
||||
extra_isize
|
||||
如果有这些关键字,说明已经成功启用了这些功能,也就是成功转换成ext4。
|
||||
|
||||
再次检查文件系统
|
||||
|
||||
```shell
|
||||
e2fsck -f /dev/sdb1
|
||||
```
|
||||
|
||||
挂载并验证文件系统类型
|
||||
|
||||
```shell
|
||||
mount -t ext4 /dev/sdb1 /sdb
|
||||
df -Th | grep /dev/sdb1
|
||||
/dev/sdb1 ext4 2.2T 60G 2.0T 3% /sdb
|
||||
```
|
||||
|
||||
修改 /etc/fstab 文件
|
||||
|
||||
```shell
|
||||
/dev/mapper/almalinux-root / xfs defaults 0 0
|
||||
UUID=d99ec15b-05d5-4311-b5c7-497945d4805d /boot xfs defaults 0 0
|
||||
UUID=0EAB-5879 /boot/efi vfat umask=0077,shortname=winnt 0 2
|
||||
/dev/mapper/almalinux-swap none swap defaults 0 0
|
||||
/dev/sdb1 /sdb ext4 defaults 0 0
|
||||
```
|
||||
|
||||
保存并重载配置
|
||||
|
||||
```shell
|
||||
systemctl daemon-reload
|
||||
```
|
||||
|
||||
## 挂载远程卷
|
||||
|
||||
### Windows
|
||||
|
||||
首先创建本地的挂载目录,一般在`/mnt`下
|
||||
|
||||
这里以 `/mnt/wdshare`为例
|
||||
|
||||
```shell
|
||||
mkdir -p /mnt/wdshare/
|
||||
```
|
||||
|
||||
安装`cifs-utils`
|
||||
|
||||
```shell
|
||||
dnf install -y cifs-utils
|
||||
```
|
||||
|
||||
进行挂载
|
||||
|
||||
```shell
|
||||
mount -t cifs -o username=user,password=backup //192.168.0.1/备份 /mnt/wdshare/
|
||||
```
|
||||
|
||||
## 分配Swap
|
||||
|
||||
查看分区大小
|
||||
@ -2645,6 +2850,10 @@ path = /root/mysql_bakup
|
||||
read only = yes
|
||||
```
|
||||
|
||||
### 命令
|
||||
|
||||
|
||||
|
||||
## 安装 Jenkins
|
||||
|
||||
安装 Java
|
||||
@ -2744,3 +2953,63 @@ Environment="JAVA_OPTS=-Djava.awt.headless=true -Duser.language=C.UTF-8"
|
||||
systemctl daemon-reload
|
||||
```
|
||||
|
||||
## 安装 Certbot
|
||||
|
||||
**Certbot** 是由 **Electronic Frontier Foundation (EFF)** 提供的一个开源命令行工具,用于自动化从 Let’s Encrypt 获取和管理 SSL 证书。Certbot 会自动为你处理证书申请、安装和续期等过程。,用于自动化整个 SSL 证书的管理流程。它可以做以下几件事:
|
||||
|
||||
- **申请证书**:使用 ACME 协议从 Let’s Encrypt 获取证书。
|
||||
- **验证域名所有权**:通过 HTTP-01 或 DNS-01 验证确保你拥有该域名。
|
||||
- **安装证书**:将证书自动安装到你的 Web 服务器,并配置相关的加密参数。
|
||||
- **续期证书**:定期自动续期证书,避免证书过期。
|
||||
|
||||
Certbot 的核心工作是通过 **ACME 协议**(自动证书管理环境)与 Let’s Encrypt 通信。ACME 是一套标准协议,用于自动化证书申请、验证和安装的过程。Certbot 使用 ACME 协议与 Let’s Encrypt 进行通信,确保你的网站能够通过安全的 HTTPS 连接。
|
||||
|
||||
推荐使用 Linux 的 snap 包管理工具安装Certbot
|
||||
|
||||
首先需要安装 snap 包管理工具
|
||||
|
||||
> [Installing snap on Rocky Linux | Snapcraft documentation参考官网](https://snapcraft.io/docs/installing-snap-on-rocky)
|
||||
|
||||
### AlmaLinux 安装 snapd
|
||||
|
||||
AlmaLinux OS的快照包可以在Enterprise Linux Extra Packages(EPEL)存储库中找到。使用以下命令将EPEL存储库添加到AlmaLinux OS系统:
|
||||
|
||||
```shell
|
||||
dnf install epel-release
|
||||
dnf upgrade
|
||||
```
|
||||
|
||||
将EPEL存储库添加到AlmaLinux OS安装中后,只需安装Snapd包(以root/或sudo身份):
|
||||
|
||||
```shell
|
||||
dnf install snapd
|
||||
```
|
||||
|
||||
安装后,需要启用管理主快照通信插座的systemd单元:
|
||||
|
||||
```shell
|
||||
systemctl enable --now snapd.socket
|
||||
```
|
||||
|
||||
要启用经典snap支持,请输入以下内容以在`/var/lib/snapd/snap`和`/snap`之间创建符号链接:
|
||||
|
||||
```shell
|
||||
ln -s /var/lib/snapd/snap /snap
|
||||
```
|
||||
|
||||
退出并再次重新登录或重新启动系统以确保快照的路径正确更新。
|
||||
Snap现已安装完毕,即可运行!
|
||||
|
||||
支持snap后可以使用如下命令安装Certbot
|
||||
|
||||
```shell
|
||||
snap install --classic certbot
|
||||
```
|
||||
|
||||
创建一个符号链接,确保可以执行certbot命令(相当于快捷方式)
|
||||
|
||||
```shell
|
||||
ln -s /snap/bin/certbot /usr/bin/certbot
|
||||
```
|
||||
|
||||
### 范
|
||||
|
||||
5
source/_posts/Pug.md
Normal file
5
source/_posts/Pug.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: Pug
|
||||
date: 2025-05-19 13:20:34
|
||||
tags:
|
||||
---
|
||||
@ -4,6 +4,12 @@ date: 2025-04-16 15:18:28
|
||||
tags:
|
||||
---
|
||||
|
||||
# 快捷键
|
||||
|
||||
## 多行编辑:Alt+Click
|
||||
|
||||
|
||||
|
||||
# 插件
|
||||
|
||||
## Remote - SSH
|
||||
|
||||
@ -286,6 +286,12 @@ modelscope download --model deepseek-ai/DeepSeek-R1-Distill-Qwen-7B README.md --
|
||||
|
||||
>
|
||||
|
||||
## 安装
|
||||
|
||||
### minicoda
|
||||
|
||||
|
||||
|
||||
## 常用命令
|
||||
|
||||
### 管理环境
|
||||
|
||||
@ -1,811 +0,0 @@
|
||||
----
|
||||
|
||||
h2. title: 大模型
|
||||
date: 2025-02-18 10:06:57
|
||||
tags:
|
||||
|
||||
h1. Ollama
|
||||
|
||||
h2. 1. 安装
|
||||
|
||||
首先需要下载并安装Ollama,这是运行模型的基础环境。
|
||||
|
||||
!https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250218102658870.png!
|
||||
|
||||
h2. 2. 下载模型
|
||||
|
||||
打开命令行终端,根据需要运行以下命令之一来下载对应版本的模型:
|
||||
|
||||
!https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250218104847668.png!
|
||||
|
||||
以DeepSeek为例:
|
||||
|
||||
7B 版本(推荐显存 8G):
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
ollama pull deepseek-coder:7b
|
||||
{code}
|
||||
|
||||
8B 版本(推荐显存 8G):
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
ollama run huihui_ai/deepseek-r1-abliterated:8b
|
||||
{code}
|
||||
|
||||
14B 版本(推荐显存 12G):
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
ollama run huihui_ai/deepseek-r1-abliterated:14b
|
||||
{code}
|
||||
|
||||
32B 版本(推荐显存 32G):
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
ollama run huihui_ai/deepseek-r1-abliterated:32b
|
||||
{code}
|
||||
|
||||
70B 版本(需要高端显卡支持):
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
ollama run huihui_ai/deepseek-r1-abliterated:70b
|
||||
{code}
|
||||
|
||||
h2. 3. Ollama 常用命令
|
||||
|
||||
在使用 Ollama 时,以下是一些常用的命令操作:
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 启动 Ollama 服务
|
||||
ollama serve
|
||||
|
||||
# 从 Modelfile 创建模型
|
||||
ollama create <模型名称>
|
||||
|
||||
# 显示模型信息
|
||||
ollama show <模型名称>
|
||||
|
||||
# 运行模型
|
||||
ollama run <模型名称>
|
||||
|
||||
# 停止运行中的模型
|
||||
ollama stop <模型名称>
|
||||
|
||||
# 从仓库拉取模型
|
||||
ollama pull <模型名称>
|
||||
|
||||
# 推送模型到仓库
|
||||
ollama push <模型名称>
|
||||
|
||||
# 列出所有已安装的模型
|
||||
ollama list
|
||||
|
||||
# 列出正在运行的模型
|
||||
ollama ps
|
||||
|
||||
# 复制模型
|
||||
ollama cp <源模型> <目标模型>
|
||||
|
||||
# 删除模型
|
||||
ollama rm <模型名称>
|
||||
|
||||
# 显示模型文件
|
||||
ollama show --modelfile <模型名称>
|
||||
{code}
|
||||
|
||||
h2. 4. Ollama模型存储目录
|
||||
|
||||
* macOS: {{~/.ollama/models}}
|
||||
* Linux: {{/usr/share/ollama/.ollama/models}}
|
||||
* Windows: {{C:\Users\%username%\.ollama\models}}
|
||||
|
||||
h3. 如何将它们设置为不同的位置?
|
||||
|
||||
如果需要使用不同的目录,可以将环境变量 {{OLLAMA_MODELS}} 设置为你选择的目录。
|
||||
|
||||
{quote}
|
||||
注意:在 Linux 上使用标准安装程序时,{{ollama}} 用户需要对指定目录有读写权限。要将目录分配给 {{ollama}} 用户,请运行 {{sudo chown -R ollama:ollama <directory>}}.
|
||||
{quote}
|
||||
|
||||
请参考[上面的部分|https://ollama.readthedocs.io/faq/#how-do-i-configure-ollama-server]了解如何在你的平台上设置环境变量。
|
||||
|
||||
!https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250218132430850.png!
|
||||
|
||||
h2. 5. WSL中Ollama使用Windows中的
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 编辑环境变量
|
||||
vim /etc/profile
|
||||
|
||||
# 文件末尾添加
|
||||
export PATH="$PATH:/mnt/c/Program Files/Ollama"
|
||||
alias ollama='ollama.exe'
|
||||
{code}
|
||||
|
||||
h1. nvidia
|
||||
|
||||
h2. cuda-toolkit
|
||||
|
||||
h3. WSL安装
|
||||
|
||||
# 下载 *CUDA Toolkit Installer*
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
wget https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda-repo-rhel9-12-8-local-12.8.1_570.124.06-1.x86_64.rpm
|
||||
sudo rpm -i cuda-repo-rhel9-12-8-local-12.8.1_570.124.06-1.x86_64.rpm
|
||||
sudo dnf clean all
|
||||
sudo dnf -y install cuda-toolkit-12-8
|
||||
{code}
|
||||
# 配置环境变量
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
vim ~/.bashrc
|
||||
|
||||
## 文件末尾添加
|
||||
## cuda 10.2
|
||||
export CUDA_HOME=/usr/local/cuda
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
|
||||
export PATH=$PATH:$CUDA_HOME/bin
|
||||
{code}
|
||||
|
||||
h2. nvidia-smi
|
||||
|
||||
{quote}
|
||||
nvidia-smi是nvidia 的系统管理界面 ,其中smi是System management interface的缩写,它可以收集各种级别的信息,查看显存使用情况。此外, 可以启用和禁用 GPU 配置选项 (如 ECC 内存功能)。
|
||||
{quote}
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
nvidia-smi
|
||||
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
| NVIDIA-SMI 570.86.09 Driver Version: 571.96 CUDA Version: 12.8 |
|
||||
|-----------------------------------------+------------------------+----------------------+
|
||||
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
|
||||
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|
||||
| | | MIG M. |
|
||||
|=========================================+========================+======================|
|
||||
| 0 NVIDIA RTX 4000 Ada Gene... On | 00000000:01:00.0 Off | Off |
|
||||
| N/A 50C P8 7W / 85W | 4970MiB / 12282MiB | 0% Default |
|
||||
| | | N/A |
|
||||
+-----------------------------------------+------------------------+----------------------+
|
||||
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
| Processes: |
|
||||
| GPU GI CI PID Type Process name GPU Memory |
|
||||
| ID ID Usage |
|
||||
|=========================================================================================|
|
||||
| 0 N/A N/A 16221 C /python3.12 N/A |
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
|
||||
{code}
|
||||
|
||||
解释相关参数含义:
|
||||
|
||||
GPU:本机中的GPU编号
|
||||
|
||||
Name:GPU 类型
|
||||
|
||||
Persistence-M:
|
||||
|
||||
Fan:风扇转速
|
||||
|
||||
Temp:温度,单位摄氏度
|
||||
|
||||
Perf:表征性能状态,从P0到P12,P0表示最大性能,P12表示状态最小性能
|
||||
|
||||
Pwr:Usage/Cap:能耗表示
|
||||
|
||||
Bus-Id:涉及GPU总线的相关信息;
|
||||
|
||||
Disp.A:Display Active,表示GPU的显示是否初始化
|
||||
|
||||
Memory-Usage:显存使用率
|
||||
|
||||
Volatile GPU-Util:浮动的GPU利用率
|
||||
|
||||
Uncorr. ECC:关于ECC的东西
|
||||
|
||||
Compute M.:计算模式
|
||||
|
||||
Processes 显示每块GPU上每个进程所使用的显存情况。
|
||||
|
||||
h3. 持续监控
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 使用 watch 命令,它可以定时执行指定的命令并刷新输出。例如,每隔 1 秒刷新一次 GPU 状态,可以使用以下命令
|
||||
watch -n 1 nvidia-smi
|
||||
{code}
|
||||
|
||||
h2. nvidia-smi -L
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 列出所有可用的 NVIDIA 设备
|
||||
nvidia-smi -L
|
||||
GPU 0: NVIDIA RTX 4000 Ada Generation Laptop GPU (UUID: GPU-9856f99a-c32c-fe63-b2ad-7bdee2b12291)
|
||||
{code}
|
||||
|
||||
h1. ModelScope
|
||||
|
||||
h2. 模型下载
|
||||
|
||||
h3. 安装
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
pip install modelscope
|
||||
{code}
|
||||
|
||||
h3. 命令行下载
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 下载完整模型库
|
||||
modelscope download --model deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
|
||||
# 下载单个文件到指定本地文件夹(以下载README.md到当前路径下“dir”目录为例)
|
||||
modelscope download --model deepseek-ai/DeepSeek-R1-Distill-Qwen-7B README.md --local_dir ./dir
|
||||
{code}
|
||||
|
||||
h4. 指定下载单个文件(以'tokenizer.json'文件为例)
|
||||
|
||||
{code:title=none|language=none|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --model 'Qwen/Qwen2-7b' tokenizer.json
|
||||
{code}
|
||||
|
||||
h4. 指定下载多个个文件
|
||||
|
||||
{code:title=none|language=none|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --model 'Qwen/Qwen2-7b' tokenizer.json config.json
|
||||
{code}
|
||||
|
||||
h4. 指定下载某些文件
|
||||
|
||||
{code:title=none|language=none|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --model 'Qwen/Qwen2-7b' --include '*.safetensors'
|
||||
{code}
|
||||
|
||||
h4. 过滤指定文件
|
||||
|
||||
{code:title=none|language=none|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --model 'Qwen/Qwen2-7b' --exclude '*.safetensors'
|
||||
{code}
|
||||
|
||||
h4. 指定下载cache_dir
|
||||
|
||||
{code:title=none|language=none|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --model 'Qwen/Qwen2-7b' --include '*.json' --cache_dir './cache_dir'
|
||||
{code}
|
||||
|
||||
模型文件将被下载到{{'cache_dir/Qwen/Qwen2-7b'}}。
|
||||
|
||||
h4. 指定下载local_dir
|
||||
|
||||
{code:title=none|language=none|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --model 'Qwen/Qwen2-7b' --include '*.json' --local_dir './local_dir'
|
||||
{code}
|
||||
|
||||
模型文件将被下载到{{'./local_dir'}}。
|
||||
|
||||
如果{{cache_dir}}和{{local_dir}}参数同时被指定,{{local_dir}}优先级高,{{cache_dir}}将被忽略。
|
||||
|
||||
h1. Anaconda
|
||||
|
||||
{quote}
|
||||
|
||||
{quote}
|
||||
|
||||
h2. 常用命令
|
||||
|
||||
h3. 管理环境
|
||||
|
||||
# 列出所有的环境
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda env list
|
||||
{code}
|
||||
# 查看conda下的包
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda list
|
||||
{code}
|
||||
# 创建环境
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda create -n env-name [list of package]
|
||||
{code}
|
||||
|
||||
-n env-name 是设置新建环境的名字,list of package 是可选项,选择要为该环境安装的包
|
||||
如果我们没有指定安装python的版本,conda会安装我们最初安装conda所装的那个版本的python
|
||||
若创建特定python版本的包环境,需键入
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda create -n env-name python=3.6
|
||||
{code}
|
||||
# 激活环境
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda activate env-name
|
||||
{code}
|
||||
|
||||
切换到base环境
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda activate base
|
||||
{code}
|
||||
# 删除环境
|
||||
执行以下命令可以将该指定虚拟环境及其中所安装的包都删除。
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda remove --name env_name --all
|
||||
{code}
|
||||
|
||||
如果只删除虚拟环境中的某个或者某些包则是:
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda remove --name env_name package_name
|
||||
{code}
|
||||
|
||||
h2. 问题
|
||||
|
||||
# conda激活[虚拟环境|https://so.csdn.net/so/search?q=虚拟环境&spm=1001.2101.3001.7020],只显示环境名称,不再显示用户名和当前文件夹
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
##在个人环境下修改
|
||||
conda activate gatkenv
|
||||
|
||||
conda env config vars set PS1='($CONDA_DEFAULT_ENV)[\u@\h \W]$'
|
||||
##重启环境就ok了
|
||||
|
||||
conda deactivate
|
||||
|
||||
conda activate gatkenv
|
||||
|
||||
##在所有的虚拟环境下修改,这个命令的意思是在~/.condarc下添加一行
|
||||
|
||||
conda config --set env_prompt "({default_env})[\u@\h \W]$"
|
||||
|
||||
##取消设置
|
||||
|
||||
conda config --remove-key env_prompt
|
||||
{code}
|
||||
# conda 安装后没有将conda置为默认
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
Do you wish to update your shell profile to automatically initialize conda?
|
||||
This will activate conda on startup and change the command prompt when activated.
|
||||
If you'd prefer that conda's base environment not be activated on startup,
|
||||
run the following command when conda is activated:
|
||||
|
||||
conda config --set auto_activate_base false
|
||||
|
||||
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
|
||||
[no] >>>
|
||||
|
||||
You have chosen to not have conda modify your shell scripts at all.
|
||||
To activate conda's base environment in your current shell session:
|
||||
|
||||
eval "$(/home/user/miniconda3/bin/conda shell.YOUR_SHELL_NAME hook)"
|
||||
|
||||
To install conda's shell functions for easier access, first activate, then:
|
||||
|
||||
conda init
|
||||
|
||||
Thank you for installing Miniconda3!
|
||||
|
||||
{code}
|
||||
|
||||
则执行以下shell
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
## eval "$(/home/user/miniconda3/bin/conda shell.SHELL_NAME hook)"
|
||||
## bash 下
|
||||
eval "$(/home/user/miniconda3/bin/conda shell.bash hook)"
|
||||
conda init
|
||||
## zsh 下
|
||||
eval "$(/home/user/miniconda3/bin/conda shell.zsh hook)"
|
||||
conda init
|
||||
{code}
|
||||
#
|
||||
|
||||
h1. Jupyter Notebook
|
||||
|
||||
{quote}
|
||||
|
||||
{quote}
|
||||
|
||||
h2. 安装
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
pip install jupyter
|
||||
{code}
|
||||
|
||||
h2. 运行
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
jupyter notebook
|
||||
# 若是root用户执行,会出现警告 Running as root is not recommended. Use --allow-root to bypass. 需在后面加上 --allow-root
|
||||
jupyter notebook --allow-root
|
||||
{code}
|
||||
|
||||
h1. UnSloth
|
||||
|
||||
h1. vLLM
|
||||
|
||||
h2. 安装
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda create -n vLLM python=3.12
|
||||
conda activate vLLM
|
||||
pip install vLLM
|
||||
|
||||
# FlashInfer is optional but required for specific functionalities such as sliding window attention with Gemma 2.
|
||||
# For CUDA 12.4 & torch 2.4 to support sliding window attention for gemma 2 and llama 3.1 style rope
|
||||
pip install flashinfer -i https://flashinfer.ai/whl/cu124/torch2.4
|
||||
# For other CUDA & torch versions, please check https://docs.flashinfer.ai/installation.html
|
||||
# 也可下载到本地
|
||||
wget https://github.com/flashinfer-ai/flashinfer/releases/download/v0.2.5/flashinfer_python-0.2.5+cu124torch2.6-cp38-abi3-linux_x86_64.whl#sha256=43d767b912c0c43a04be99595e0123eab9385fc72530a2874b5fb08e3145c0be
|
||||
pip install flashinfer_python-0.2.5+cu124torch2.6-cp38-abi3-linux_x86_64.whl --no-deps
|
||||
{code}
|
||||
|
||||
h2. 部署
|
||||
|
||||
h3. deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
CUDA_VISIBLE_DEVICES=0 vllm serve /mnt/e/modelscope/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B --port 8102 --max-model-len 2048 --api-key token-abc123
|
||||
{code}
|
||||
|
||||
* CUDA_VISIBLE_DEVICES=0: 指定使用的 GPU 设备 ID。 0 表示使用第一块 GPU。如果您有多块 GPU,可以根据需要修改为其他 ID (例如 CUDA_VISIBLE_DEVICES=1,2 使用 GPU 1 和 GPU 2)。如果您只有一块 GPU,通常使用 0 即可。
|
||||
* {{/mnt/e/modelscope/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B}}: *模型路径。* 请替换为您在步骤 2 中模型实际保存的路径。
|
||||
* {{--port 8102}}: *服务端口号。* {{8102}} 是服务启动后监听的端口。您可以根据需要修改端口号,例如 {{--port 8000}}。在后续代码调用中,需要使用相同的端口号。
|
||||
* --max-model-len 16384: 模型最大上下文长度。 16384 表示模型处理的最大输入序列长度。您可以根据您的 GPU 显存大小和需求调整此参数。对于 /mnt/e/modelscope/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B 模型,16384 是一个较大的上下文长度。您可以尝试减小此值以减少显存占用,例如 --max-model-len 2048 或更小。
|
||||
* *执行启动命令:* 在终端或命令提示符中执行上述 {{vllm serve}} 命令。
|
||||
* *注意 GPU 显存:* 启动 vLLM 服务会占用 GPU 显存。请确保您的 GPU 显存足够运行模型。如果显存不足,可能会导致启动失败或运行缓慢。您可以尝试减小 {{--max-model-len}} 参数或使用更小规模的模型。
|
||||
|
||||
h3. Qwen/Qwen3-4B
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
vllm serve ~/modelscope/Qwen/Qwen3-4B --api-key token-abc123 --enable-reasoning --reasoning-parser deepseek_r1 --max_model_len=2048 --gpu_memory_utilization=0.85
|
||||
{code}
|
||||
|
||||
h4. supervisor
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
sudo vim vLLM-Qwen-Qwen3-4B.conf
|
||||
[program:vLLM-Qwen-Qwen3-4B.conf]
|
||||
command=zsh -c "source /home/user/miniconda3/bin/activate && source activate vLLM && vllm serve ~/modelscope/Qwen/Qwen3-4B --api-key token-abc123 --enable-reasoning --reasoning-parser deepseek_r1 --max_model_len=2048 --gpu_memory_utilization=0.85"
|
||||
user=user
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stderr_logfile=/var/log/supervisor/vLLM-Qwen-Qwen3-4B/err.log
|
||||
stdout_logfile=/var/log/supervisor/vLLM-Qwen-Qwen3-4B/out.log
|
||||
stopasgroup=true
|
||||
{code}
|
||||
|
||||
h1. LLama.cpp
|
||||
|
||||
{quote}
|
||||
{{llama.cpp}}是一个基于纯{{C/C++}}实现的高性能大语言模型推理引擎,专为优化本地及云端部署而设计。其核心目标在于通过底层硬件加速和量化技术,实现在多样化硬件平台上的高效推理,同时保持低资源占用与易用性。
|
||||
{quote}
|
||||
|
||||
h2. 编译llama.cpp
|
||||
|
||||
首先从{{Github}}上下载{{llama.cpp}}的源码:
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
git clone https://github.com/ggml-org/llama.cpp
|
||||
cd llama.cpp
|
||||
{code}
|
||||
|
||||
{{llama.cpp}}支持多种硬件平台,可根据实际的硬件配置情况选择合适的编译参数进行编译,具体可以参考文档{{docs/build.md}}。
|
||||
|
||||
*安装CMAKE*
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
wget https://github.com/Kitware/CMake/releases/download/v4.0.0-rc4/cmake-4.0.0-rc4-linux-x86_64.sh
|
||||
chmod -R 777 cmake-4.0.0-rc4-linux-x86_64.sh
|
||||
./cmake-4.0.0-rc4-linux-x86_64.sh
|
||||
mv cmake-4.0.0-rc4-linux-x86_64/ /usr/local/cmake
|
||||
echo 'export PATH="/usr/local/cmake/bin:$PATH"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
sudo dnf install gcc-toolset-13-gcc gcc-toolset-13-gcc-c++
|
||||
source /opt/rh/gcc-toolset-13/enable
|
||||
{code}
|
||||
|
||||
*编译CPU版本*
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
cmake -B build
|
||||
cmake --build build --config Release -j 8
|
||||
{code}
|
||||
|
||||
*编译GPU版本*
|
||||
|
||||
编译英伟达{{GPU}}版本需要先装好驱动和{{CUDA}},然后执行下面的命令进行编译
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
cmake -B build -DGGML_CUDA=ON -DGGML_CUDA_ENABLE_UNIFIED_MEMORY=1
|
||||
cmake --build build --config Release -j 8
|
||||
{code}
|
||||
|
||||
{quote}
|
||||
编译完成后,可执行文件和库文件被存放在{{build/bin}}目录下。
|
||||
{quote}
|
||||
|
||||
h2. 模型下载与转换
|
||||
|
||||
首先从魔搭社区下载模型:
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
pip install modelscope
|
||||
modelscope download --model deepseek-ai/DeepSeek-R1-Distill-Qwen-7B --local_dir DeepSeek-R1-Distill-Qwen-7B
|
||||
{code}
|
||||
|
||||
下载好的模型是以{{HuggingFace}}的{{safetensors}}格式存放的,而{{llama.cpp}}使用的是{{GGUF}}格式,因此需要先要把模型转换为{{GGUF}}格式:
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 安装python依赖库
|
||||
pip install -r requirements.txt
|
||||
# 转换模型
|
||||
python convert_hf_to_gguf.py DeepSeek-R1-Distill-Qwen-7B/
|
||||
{code}
|
||||
|
||||
转换成功后,在该目录下会生成一个{{FP16}}精度、{{GGUF}}格式的模型文件{{DeepSeek-R1-Distill-Qwen-7B-F16.gguf}}。
|
||||
|
||||
h2. 模型量化
|
||||
|
||||
{{FP16}}精度的模型跑起来可能会有点慢,我们可以对模型进行量化以提升推理速度。
|
||||
|
||||
{{llama.cpp}}主要采用了分块量化({{Block-wise Quantization}})和{{K-Quantization}}算法来实现模型压缩与加速,其核心策略包括以下关键技术:
|
||||
|
||||
# *分块量化(Block-wise Quantization)*
|
||||
该方法将权重矩阵划分为固定大小的子块(如{{32}}或{{64}}元素为一组),每个子块独立进行量化。通过为每个子块分配独立的缩放因子({{Scale}})和零点({{Zero Point}}),有效减少量化误差。例如,{{Q4_K_M}}表示每个权重用{{4}}比特存储,且子块内采用动态范围调整。
|
||||
# *K-Quantization(混合精度量化)*
|
||||
在子块内部进一步划分更小的单元(称为“超块”),根据数值分布动态选择量化参数。例如,{{Q4_K_M}}将超块拆分为多个子单元,每个子单元使用不同位数的缩放因子(如{{6bit}}的缩放因子和{{4bit}}的量化值),通过混合精度平衡精度与压缩率。
|
||||
# *重要性矩阵(Imatrix)优化*
|
||||
通过分析模型推理过程中各层激活值的重要性,动态调整量化策略。高重要性区域保留更高精度(如{{FP16}}),低重要性区域采用激进量化(如{{Q2_K}}),从而在整体模型性能损失可控的前提下实现高效压缩。
|
||||
# *量化类型分级策略*
|
||||
提供{{Q2_K}}至{{Q8_K}}等多种量化级别,其中字母后缀(如{{_M}}、{{_S}})表示优化级别:
|
||||
# *Q4_K_M*:中等优化级别,平衡推理速度与精度(常用推荐)。
|
||||
# *Q5_K_S*:轻量化级别,侧重减少内存占用
|
||||
|
||||
典型场景下,{{Q4_K_M}}相比{{FP16}}模型可减少{{70%}}内存占用,推理速度提升{{2-3}}倍,同时保持{{95%}}以上的原始模型精度。实际部署时需根据硬件资源(如{{GPU}}显存容量)和任务需求(如生成文本长度)选择量化策略。
|
||||
|
||||
执行下面的命令可将{{FP16}}精度的模型采用{{Q4_K_M}}的量化策略进行量化:
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
./build/bin/llama-quantize DeepSeek-R1-Distill-Qwen-7B/DeepSeek-R1-Distill-Qwen-7B-F16.gguf DeepSeek-R1-Distill-Qwen-7B/DeepSeek-R1-Distill-Qwen-7B-Q4_K_M.gguf Q4_K_M
|
||||
{code}
|
||||
|
||||
量化完成后,模型文件由{{15.2G}}减少到{{4.7G}}。
|
||||
|
||||
h2. 运行模型
|
||||
|
||||
模型量化完后,我们就可以运行模型来试试效果了。{{llama.cpp}}提供了多种运行模型的方式:
|
||||
|
||||
h3. 命令行方式
|
||||
|
||||
执行下面的命令就可以在命令行与模型进行对话了:
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
./build/bin/llama-cli -m DeepSeek-R1-Distill-Qwen-7B/DeepSeek-R1-Distill-Qwen-7B-Q4_K_M.gguf -cnv
|
||||
{code}
|
||||
|
||||
h3. HTTP Server方式
|
||||
|
||||
由于模型是以{{Markdown}}格式输出内容,因此用命令行的方式看着不太方便。{{llama.cpp}}还提供{{HTTP Server}}的方式运行,交互性要好很多。
|
||||
|
||||
首先在终端执行命令
|
||||
|
||||
{code:title=none|language=|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
./build/bin/llama-server -m DeepSeek-R1-Distill-Qwen-7B/DeepSeek-R1-Distill-Qwen-7B-Q4_K_M.gguf --port 8088
|
||||
{code}
|
||||
|
||||
然后打开浏览器,输入地址{{http://127.0.0.1:8088}}就可以在网页上与模型进行交互了,非常方便!
|
||||
|
||||
h1. Ktransformers
|
||||
|
||||
安装
|
||||
|
||||
h1. LLaMA-Factory
|
||||
|
||||
{quote}
|
||||
可参考文章:[DeepSeek-R1-7B-Distill模型微调全过程记录,LLaMA_Factory训练自己的数据集,合并lora微调模型并量化为gguf,接入微信实现自动对话回复_微信_qq_53091149-DeepSeek技术社区|https://deepseek.csdn.net/67b84a893c9cd21f4cb9aab6.html#devmenu2]
|
||||
{quote}
|
||||
|
||||
h2. 安装
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
# 首先 conda创建环境
|
||||
conda create -n LLaMA-Factory python=3.12
|
||||
# 激活环境
|
||||
conda activate LLaMA-Factory
|
||||
# 从GitHub上拉去项目代码到当前目录下
|
||||
git clone https://github.com/hiyouga/LLaMA-Factory.git
|
||||
# 进入目录
|
||||
cd LLaMA-Factory
|
||||
# 安装所需依赖
|
||||
pip install -e ".[torch,metrics]"
|
||||
# 启动webui
|
||||
python src/webui.py
|
||||
{code}
|
||||
|
||||
h2. 微调
|
||||
|
||||
!https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250320152454509.png!
|
||||
|
||||
!https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250320152533756.png!
|
||||
|
||||
合并
|
||||
|
||||
!https://markdownhexo.oss-cn-hangzhou.aliyuncs.com/img/image-20250320152645802.png!
|
||||
|
||||
h1. AutoAWQ量化
|
||||
|
||||
h2. 安装
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
conda create -n AutoAWQ python=3.12
|
||||
conda activate AutoAWQ
|
||||
pip install torch
|
||||
pip install autoawq
|
||||
{code}
|
||||
|
||||
h2. 脚本
|
||||
|
||||
默认AutoAWQ会从Huggingface上下载数据集mit-han-lab/pile-val-backup,会因为网络问题失败
|
||||
|
||||
需事先手动下载,通过modelscope
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
modelscope download --dataset mit-han-lab/pile-val-backup --local_dir ~/modelscope/mit-han-lab/pile-val-backup
|
||||
{code}
|
||||
|
||||
以{{Qwen/Qwen3-4B}}模型为例
|
||||
|
||||
{code:title=none|language=bash|borderStyle=solid|theme=RDark|linenumbers=true|collapse=true}
|
||||
from awq import AutoAWQForCausalLM
|
||||
from transformers import AutoTokenizer
|
||||
from datasets import load_dataset
|
||||
|
||||
# 加载本地数据集
|
||||
def load_calib_data():
|
||||
data=load_dataset('/home/user/modelscope/mit-han-lab/pile-val-backup', split="validation")
|
||||
return [text for text in data["text"] if text.strip() != '' and len(text.split(' ')) > 20]
|
||||
|
||||
model_path = '/home/user/modelscope/Qwen/Qwen3-4B'
|
||||
quant_path = '/home/user/modelscope/Qwen/Qwen3-4B-awq'
|
||||
quant_config = { "zero_point": True, "q_group_size": 128, "w_bit": 4, "version": "GEMM" }
|
||||
|
||||
|
||||
# Load model
|
||||
# 加载模型
|
||||
|
||||
|
||||
model = AutoAWQForCausalLM.from_pretrained(
|
||||
model_path, **{"low_cpu_mem_usage": True, "use_cache": False}
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
||||
|
||||
|
||||
# Quantize
|
||||
# 量化
|
||||
|
||||
calib_data=load_calib_data()
|
||||
model.quantize(tokenizer, quant_config=quant_config, calib_data=calib_data)
|
||||
|
||||
|
||||
# Save quantized model
|
||||
# 保存量化模型
|
||||
|
||||
|
||||
model.save_quantized(quant_path)
|
||||
tokenizer.save_pretrained(quant_path)
|
||||
|
||||
|
||||
print(f'Model is quantized and saved at "{quant_path}"')
|
||||
{code}
|
||||
|
||||
h1. 大模型Dense、MoE 与 Hybrid-MoE 架构的比较
|
||||
|
||||
在大模型架构设计中,Dense(全连接)、MoE(混合专家)和Hybrid-MoE(混合式MoE)是三种主流的参数组织方式,它们在模型容量、计算效率和应用场景上存在显著差异。以下从核心原理、技术特点、优缺点及适用场景进行系统对比:
|
||||
|
||||
----
|
||||
|
||||
h2. *1. 核心原理对比*
|
||||
|
||||
||*架构类型*||*核心思想*||*典型模型*||
|
||||
|*Dense*|所有参数对所有输入生效,每层神经元全连接,统一处理所有输入特征。|GPT-3、BERT、LLAMA|
|
||||
|*MoE*|将模型划分为多个“专家”(子网络),每个输入仅激活部分专家,通过路由机制动态分配任务。|Switch Transformer、GShard|
|
||||
|*Hybrid-MoE*|混合Dense和MoE层:部分层全连接,部分层采用MoE结构,平衡计算效率和模型容量。|DeepSeek-MoE、Google GLaM|
|
||||
|
||||
----
|
||||
|
||||
h2. *2. 技术特点与性能对比*
|
||||
|
||||
||*维度*||*Dense*||*MoE*||*Hybrid-MoE*||
|
||||
|*参数规模*|总参数量=激活参数量,随层数线性增长。|总参数量高(专家数×专家规模),但激活参数量低(仅激活部分专家)。|介于两者之间,MoE层数可控。|
|
||||
|*计算效率*|计算成本高(FLOPs与参数量正相关),适合小规模模型。|相同参数量下,FLOPs显著降低(仅激活部分专家)。|通过调整MoE层比例,灵活平衡计算开销。|
|
||||
|*训练稳定性*|收敛稳定,梯度传播路径简单。|路由机制易导致专家负载不均衡,需复杂正则化。|稳定性优于纯MoE,但仍需路由优化。|
|
||||
|*扩展性*|参数规模受硬件限制,千亿级后成本陡增。|可扩展至万亿参数(如GShard-1.6T),适合超大规模模型。|通过局部MoE化实现高效扩展,适配中等规模。|
|
||||
|*显存占用*|高(需存储全部参数梯度)。|显存需求更高(专家参数独立存储)。|显存介于两者之间,取决于MoE层占比。|
|
||||
|*应用场景*|通用任务、资源受限场景。|超大规模预训练、多任务学习。|需平衡性能与成本的工业级应用。|
|
||||
|
||||
----
|
||||
|
||||
h2. *3. 优缺点对比*
|
||||
|
||||
h3. *Dense架构*
|
||||
|
||||
* *优点*:
|
||||
** 结构简单,训练稳定性高。
|
||||
** 参数利用率最大化,适合小规模高精度任务。
|
||||
* *缺点*:
|
||||
** 计算成本随参数量指数级增长,难以扩展至超大规模。
|
||||
** 显存占用高,限制单卡可训练模型规模。
|
||||
|
||||
h3. *MoE架构*
|
||||
|
||||
* *优点*:
|
||||
** 计算效率高,相同FLOPs下模型容量更大。
|
||||
** 支持万亿级参数扩展,适合分布式训练。
|
||||
* *缺点*:
|
||||
** 路由机制复杂,易出现专家“坍缩”(部分专家未被激活)。
|
||||
** 显存和通信开销大,需定制化负载均衡策略。
|
||||
|
||||
h3. *Hybrid-MoE架构*
|
||||
|
||||
* *优点*:
|
||||
** 灵活性高,可通过调整MoE层位置平衡性能与成本。
|
||||
** 保留关键层的全连接特性,提升任务特定性能。
|
||||
* *缺点*:
|
||||
** 需精心设计MoE层分布,调参成本较高。
|
||||
** 仍面临部分MoE的稳定性挑战。
|
||||
|
||||
----
|
||||
|
||||
h2. *4. 典型应用场景*
|
||||
|
||||
||*架构*||*适用场景*||
|
||||
|*Dense*|- 中小规模模型(<100B参数) - 对训练稳定性要求高的任务(如对话生成) - 边缘设备推理|
|
||||
|*MoE*|- 超大规模预训练(>500B参数) - 多任务/多模态学习 - 云端高性能计算集群|
|
||||
|*Hybrid-MoE*|- 中等规模模型(100B-500B参数) - 需兼顾通用性与效率的工业场景 - 长文本处理任务|
|
||||
|
||||
----
|
||||
|
||||
h2. *5. 技术选型建议*
|
||||
|
||||
* *选择Dense的条件*:
|
||||
** 资源有限(单卡训练/推理)。
|
||||
** 任务单一,无需极高模型容量。
|
||||
** 追求极简架构和稳定收敛。
|
||||
* *选择MoE的条件*:
|
||||
** 追求极致模型性能(如AGI探索)。
|
||||
** 拥有大规模计算集群(千卡级)。
|
||||
** 多任务/多模态需求显著。
|
||||
* *选择Hybrid-MoE的条件*:
|
||||
** 需平衡模型容量与计算成本。
|
||||
** 部分任务依赖全连接层的强表征能力(如逻辑推理)。
|
||||
** 希望渐进式扩展模型规模。
|
||||
|
||||
----
|
||||
|
||||
h2. *6. 未来发展方向*
|
||||
|
||||
# *Dense架构优化*:
|
||||
#* 参数高效微调(LoRA、Adapter)。
|
||||
#* 动态稀疏激活(如微软的DeepSpeed-MoE)。
|
||||
# *MoE架构改进*:
|
||||
#* 更智能的路由机制(如基于强化学习)。
|
||||
#* 专家共享与分层MoE设计。
|
||||
# *Hybrid-MoE创新*:
|
||||
#* 自动化MoE层分布搜索(NAS技术)。
|
||||
#* 异构专家设计(不同专家结构适配不同任务)。
|
||||
|
||||
----
|
||||
|
||||
h2. *总结*
|
||||
|
||||
* *Dense*:简单可靠,适合资源受限场景,但扩展性差。
|
||||
* *MoE*:计算高效,扩展性强,但工程复杂度高。
|
||||
* *Hybrid-MoE*:折中方案,平衡性能与成本,需精细调优。
|
||||
|
||||
实际选型需结合*任务需求*、*硬件资源*和*工程能力*综合评估。对于大多数企业级应用,Hybrid-MoE可能是当前的最优解,而科研前沿更倾向于探索纯MoE的极限能力。
|
||||
|
||||
@ -13,5 +13,9 @@
|
||||
span.footer-separator |
|
||||
span= _p('footer.theme') + ' '
|
||||
a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
|
||||
br
|
||||
center
|
||||
| ICP备案号:
|
||||
a(href="https://beian.miit.gov.cn" target="_blank") 辽ICP备2025052969号-1
|
||||
if theme.footer.custom_text
|
||||
.footer_custom_text!=`${theme.footer.custom_text}`
|
||||
|
||||
@ -29,13 +29,16 @@ mixin rightsideItem(array)
|
||||
if commentsJsLoad
|
||||
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
|
||||
i.fas.fa-comments
|
||||
when 'xxxx'
|
||||
button#xxxx(type="button" title="测试按钮")
|
||||
i.fas.fa-xxxx
|
||||
|
||||
#rightside
|
||||
- const { enable, hide, show } = theme.rightside_item_order
|
||||
- const hideArray = enable ? hide && hide.split(',') : ['readmode','translate','darkmode','hideAside']
|
||||
- const hideArray = enable ? hide && hide.split(',') : ['readmode','translate','darkmode','hideAside', 'xxxx']
|
||||
- const showArray = enable ? show && show.split(',') : ['toc','chat','comment']
|
||||
|
||||
|
||||
|
||||
#rightside-config-hide
|
||||
if hideArray
|
||||
+rightsideItem(hideArray)
|
||||
|
||||
100
yarn.lock
100
yarn.lock
@ -403,17 +403,6 @@ character-parser@^2.2.0:
|
||||
dependencies:
|
||||
is-regex "^1.0.3"
|
||||
|
||||
cheerio@^0.19.0:
|
||||
version "0.19.0"
|
||||
resolved "https://registry.npmmirror.com/cheerio/-/cheerio-0.19.0.tgz"
|
||||
integrity sha512-Fwcm3zkR37STnPC8FepSHeSYJM5Rd596TZOcfDUdojR4Q735aK1Xn+M+ISagNneuCwMjK28w4kX+ETILGNT/UQ==
|
||||
dependencies:
|
||||
css-select "~1.0.0"
|
||||
dom-serializer "~0.1.0"
|
||||
entities "~1.1.1"
|
||||
htmlparser2 "~3.8.1"
|
||||
lodash "^3.2.0"
|
||||
|
||||
cheerio@^0.22.0:
|
||||
version "0.22.0"
|
||||
resolved "https://registry.npmmirror.com/cheerio/-/cheerio-0.22.0.tgz"
|
||||
@ -586,16 +575,6 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.3:
|
||||
shebang-command "^2.0.0"
|
||||
which "^2.0.1"
|
||||
|
||||
css-select@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/css-select/-/css-select-1.0.0.tgz"
|
||||
integrity sha512-/xPlD7betkfd7ChGkLGGWx5HWyiHDOSn7aACLzdH0nwucPvB0EAm8hMBm7Xn7vGfAeRRN7KZ8wumGm8NoNcMRw==
|
||||
dependencies:
|
||||
boolbase "~1.0.0"
|
||||
css-what "1.0"
|
||||
domutils "1.4"
|
||||
nth-check "~1.0.0"
|
||||
|
||||
css-select@~1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmmirror.com/css-select/-/css-select-1.2.0.tgz"
|
||||
@ -606,11 +585,6 @@ css-select@~1.2.0:
|
||||
domutils "1.5.1"
|
||||
nth-check "~1.0.1"
|
||||
|
||||
css-what@1.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/css-what/-/css-what-1.0.0.tgz"
|
||||
integrity sha512-60SUMPBreXrLXgvpM8kYpO0AOyMRhdRlXFX5BMQbZq1SIJCyNE56nqFQhmvREQdUJpedbGRYZ5wOyq3/F6q5Zw==
|
||||
|
||||
css-what@2.1:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.npmmirror.com/css-what/-/css-what-2.1.3.tgz"
|
||||
@ -780,13 +754,6 @@ domexception@^4.0.0:
|
||||
dependencies:
|
||||
webidl-conversions "^7.0.0"
|
||||
|
||||
domhandler@2.3:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.npmmirror.com/domhandler/-/domhandler-2.3.0.tgz"
|
||||
integrity sha512-q9bUwjfp7Eif8jWxxxPSykdRZAb6GkguBGSgvvCrhI9wB71W2K/Kvv4E61CF/mcCfnVJDeDWx/Vb/uAqbDj6UQ==
|
||||
dependencies:
|
||||
domelementtype "1"
|
||||
|
||||
domhandler@^2.3.0:
|
||||
version "2.4.2"
|
||||
resolved "https://registry.npmmirror.com/domhandler/-/domhandler-2.4.2.tgz"
|
||||
@ -813,14 +780,7 @@ dompurify@^3.0.3:
|
||||
resolved "https://registry.npmmirror.com/dompurify/-/dompurify-3.0.6.tgz"
|
||||
integrity sha512-ilkD8YEnnGh1zJ240uJsW7AzE+2qpbOUYjacomn3AvJ6J4JhKGSZ2nh4wUIXPZrEPppaCLx5jFe8T89Rk8tQ7w==
|
||||
|
||||
domutils@1.4:
|
||||
version "1.4.3"
|
||||
resolved "https://registry.npmmirror.com/domutils/-/domutils-1.4.3.tgz"
|
||||
integrity sha512-ZkVgS/PpxjyJMb+S2iVHHEZjVnOUtjGp0/zstqKGTE9lrZtNHlNQmLwP/lhLMEApYbzc08BKMx9IFpKhaSbW1w==
|
||||
dependencies:
|
||||
domelementtype "1"
|
||||
|
||||
domutils@1.5, domutils@1.5.1:
|
||||
domutils@1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.npmmirror.com/domutils/-/domutils-1.5.1.tgz"
|
||||
integrity sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw==
|
||||
@ -881,12 +841,7 @@ ent@^2.2.0:
|
||||
resolved "https://registry.npmmirror.com/ent/-/ent-2.2.0.tgz"
|
||||
integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==
|
||||
|
||||
entities@1.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/entities/-/entities-1.0.0.tgz"
|
||||
integrity sha512-LbLqfXgJMmy81t+7c14mnulFHJ170cM6E+0vMXR9k/ZiZwgX8i5pNgjTCX3SO4VeUsFLV+8InixoretwU+MjBQ==
|
||||
|
||||
entities@^1.1.1, entities@^1.1.2, entities@~1.1.1:
|
||||
entities@^1.1.1, entities@~1.1.1:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.npmmirror.com/entities/-/entities-1.1.2.tgz"
|
||||
integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
|
||||
@ -1291,13 +1246,10 @@ hasown@^2.0.0:
|
||||
dependencies:
|
||||
function-bind "^1.1.2"
|
||||
|
||||
hexo-asset-image@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/hexo-asset-image/-/hexo-asset-image-1.0.0.tgz"
|
||||
integrity sha512-jkuUJNPRMH6v7HqzP2BAwEZavMzVxNWhl8jZl9BmFYB22/aq2+zixGIhV4vedI9cLPydjn9DfII41/MMXtzJTA==
|
||||
dependencies:
|
||||
cheerio "^0.19.0"
|
||||
entities "^1.1.2"
|
||||
hexo-asset-img@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmmirror.com/hexo-asset-img/-/hexo-asset-img-1.2.0.tgz#d6d816fbea47ff3da97da13bce58bd0314bdaaee"
|
||||
integrity sha512-PfjFF8DvG22KZ9ZldzpCFJUerH+IJ7e4ARw9BsD3PtJsAbYJGLQfLt/XFnel/r9d2dDYjMlQf1urFdLirseqEA==
|
||||
|
||||
hexo-bunyan@^1.0.0:
|
||||
version "1.0.0"
|
||||
@ -1622,17 +1574,6 @@ htmlparser2@^9.0.0:
|
||||
domutils "^3.1.0"
|
||||
entities "^4.5.0"
|
||||
|
||||
htmlparser2@~3.8.1:
|
||||
version "3.8.3"
|
||||
resolved "https://registry.npmmirror.com/htmlparser2/-/htmlparser2-3.8.3.tgz"
|
||||
integrity sha512-hBxEg3CYXe+rPIua8ETe7tmG3XDn9B0edOE/e9wH2nLczxzgdu0m0aNHY+5wFZiviLWLdANPJTssa92dMcXQ5Q==
|
||||
dependencies:
|
||||
domelementtype "1"
|
||||
domhandler "2.3"
|
||||
domutils "1.5"
|
||||
entities "1.0"
|
||||
readable-stream "1.1"
|
||||
|
||||
http-errors@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz"
|
||||
@ -1676,7 +1617,7 @@ inflight@^1.0.4:
|
||||
once "^1.3.0"
|
||||
wrappy "1"
|
||||
|
||||
inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3:
|
||||
inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz"
|
||||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
||||
@ -1874,11 +1815,6 @@ is-wsl@^2.2.0:
|
||||
dependencies:
|
||||
is-docker "^2.0.0"
|
||||
|
||||
isarray@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.npmmirror.com/isarray/-/isarray-0.0.1.tgz"
|
||||
integrity sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==
|
||||
|
||||
isarray@1.0.0, isarray@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/isarray/-/isarray-1.0.0.tgz"
|
||||
@ -2072,11 +2008,6 @@ lodash.some@^4.4.0:
|
||||
resolved "https://registry.npmmirror.com/lodash.some/-/lodash.some-4.6.0.tgz"
|
||||
integrity sha512-j7MJE+TuT51q9ggt4fSgVqro163BEFjAt3u97IqU+JA2DkWl80nFTrowzLpZ/BnpN7rrl0JA/593NAdd8p/scQ==
|
||||
|
||||
lodash@^3.2.0:
|
||||
version "3.10.1"
|
||||
resolved "https://registry.npmmirror.com/lodash/-/lodash-3.10.1.tgz"
|
||||
integrity sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==
|
||||
|
||||
lower-case@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz"
|
||||
@ -2345,7 +2276,7 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
|
||||
resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz"
|
||||
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
|
||||
|
||||
nth-check@~1.0.0, nth-check@~1.0.1:
|
||||
nth-check@~1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmmirror.com/nth-check/-/nth-check-1.0.2.tgz"
|
||||
integrity sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==
|
||||
@ -2690,16 +2621,6 @@ range-parser@~1.2.1:
|
||||
resolved "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz"
|
||||
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
|
||||
|
||||
readable-stream@1.1:
|
||||
version "1.1.14"
|
||||
resolved "https://registry.npmmirror.com/readable-stream/-/readable-stream-1.1.14.tgz"
|
||||
integrity sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==
|
||||
dependencies:
|
||||
core-util-is "~1.0.0"
|
||||
inherits "~2.0.1"
|
||||
isarray "0.0.1"
|
||||
string_decoder "~0.10.x"
|
||||
|
||||
readable-stream@3, readable-stream@^3.1.1:
|
||||
version "3.6.0"
|
||||
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz"
|
||||
@ -3045,11 +2966,6 @@ string_decoder@^1.1.1:
|
||||
dependencies:
|
||||
safe-buffer "~5.2.0"
|
||||
|
||||
string_decoder@~0.10.x:
|
||||
version "0.10.31"
|
||||
resolved "https://registry.npmmirror.com/string_decoder/-/string_decoder-0.10.31.tgz"
|
||||
integrity sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==
|
||||
|
||||
string_decoder@~1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.1.1.tgz"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user