当前位置: 首页 > news >正文

云原生之深入解析如何限制Kubernetes集群中文件描述符与线程数量

一、背景

  • linux 中为了防止进程恶意使用资源,系统使用 ulimit 来限制进程的资源使用情况(包括文件描述符,线程数,内存大小等)。同样地在容器化场景中,需要限制其系统资源的使用量。
  • ulimit: docker 默认支持 ulimit 设置,可以在 dockerd 中配置 default-ulimits 可为宿主机所有容器配置默认的 ulimit,docker 启动时可添加 –ulimit 为每个容器配置 ulimit 会覆盖默认的设置,目前 k8s 暂不支持 ulimit。
  • cgroup: docker 默认支持 cgroup 中内存、cpu、pid 等的限制,对于线程限制可通过 –pids-limit 可限制每个容器的 pid 总数,dockerd 暂无默认的 pid limit 设置;k8s 限制线程数,可通过在 kubelet 中开启 SupportPodPidsLimit 特性,设置 pod 级别 pid limit。
  • /etc/securiy/limits.conf,systcl.confg:通过 ulimit 命令设置只对当前登录用户有效,永久设置可通过 limits.conf 配置文件实现,以及系统级别限制可通过 systcl.confg 配置文件。

二、实验对比

① 环境

  • 本地环境:os: Ubuntu 16.04.6 LTS 4.4.0-154-generic docker: 18.09.7 base-image: alpine:v3.9
  • k8s 环境:kubelet: v1.10.11.1 docker: 18.09.6

② ulimit

  • 用户级别资源限制,分为 soft 限制与 hard 限制;
    • soft :用户可修改,但不能超过硬限制;
    • hard:只有 root 用户可修改;
  • 修改方式:ulimit 命令,临时修改;/etc/security/limits.conf,永久修改;
  • 工作原理:根据 PAM ( Pluggable Authentication Modules 简称 PAM)机制,应用程序启动时,按 /etc/pam.d 配置加载 pam_xxxx.so 模块。/etc/pam.d 下包含了 login 、sshd 、su 、sudo 等程序的 PAM 配置文件, 因此用户重新登录时,将调用 pam_limits.so 加载 limits.conf 配置文件。

三、文件描述符限制

RLIMIT_NOFILEThis specifies a value one greater than the maximum filedescriptor number that can be opened by this process.Attempts (open(2), pipe(2), dup(2), etc.)  to exceed thislimit yield the error EMFILE.  (Historically, this limit wasnamed RLIMIT_OFILE on BSD.)Since Linux 4.5, this limit also defines the maximum number offile descriptors that an unprivileged process (one without theCAP_SYS_RESOURCE capability) may have "in flight" to otherprocesses, by being passed across UNIX domain sockets.  Thislimit applies to the sendmsg(2) system call.  For furtherdetails, see unix(7).
  • 根据定义,nofile 限制进程所能最多打开的文件数量,作用范围进程:
    • 设置 ulimit nofile 限制 soft 100/hard 200,默认启动为 root 用户;
$ docker run -d --ulimit nofile=100:200  cr.d.xiaomi.net/containercloud/alpine:webtool top
    • 进入容器查看, fd soft 限制为 100 个:
/ # ulimit -a
-f: file size (blocks)             unlimited
-t: cpu time (seconds)             unlimited
-d: data seg size (kb)             unlimited
-s: stack size (kb)                8192
-c: core file size (blocks)        unlimited
-m: resident set size (kb)         unlimited
-l: locked memory (kb)             64
-p: processes                      unlimited
-n: file descriptors               100
-v: address space (kb)             unlimited
-w: locks                          unlimited
-e: scheduling priority            0
-r: real-time priority             0
    • 使用 ab 测试,并发 90 个 http 请求,创建 90 个 socket,正常运行:
/ # ab -n 1000000 -c 90 http://61.135.169.125:80/ &
/ # lsof | wc -l 
108
/ # lsof | grep -c ab
94
    • 并发 100 个 http 请求,受到 ulimit 限制:
/ #  ab -n 1000000 -c 100 http://61.135.169.125:80/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 61.135.169.125 (be patient)
socket: No file descriptors available (24)

四、线程限制

RLIMIT_NPROCThis is a limit on the number of extant process (or, more pre‐cisely on Linux, threads) for the real user ID of the callingprocess.  So long as the current number of processes belongingto this process's real user ID is greater than or equal tothis limit, fork(2) fails with the error EAGAIN.The RLIMIT_NPROC limit is not enforced for processes that haveeither the CAP_SYS_ADMIN or the CAP_SYS_RESOURCE capability.
  • 由定义可知,nproc 进程限制的范围是对于每个 uid,并且对于 root 用户无效。

五、容器 uid

  • 同一主机上运行的所有容器共享同一个内核(主机的内核),docker 通过 namspace 对 pid/utc/network 等进行了隔离,虽然 docker 中已经实现了 user namespace,但由于各种原因,默认没有开启,见 docker user namespace:
$ docker run -d  cr.d.xiaomi.net/containercloud/alpine:webtool top
  • 宿主机中查看 top 进程,显示 root 用户:
$ ps -ef |grep top
root      4096  4080  0 15:01 ?        00:00:01 top
  • 容器中查看 id,uid 为 0 对应宿主机的 root 用户,虽然同为 root 用户,但 Linux Capabilities 不同,实际权限与宿主机 root 要少很多。
  • 在容器中切换用户到 operator(uid 为 11),执行 sleep 命令,主机中查看对应进程用户为 app,对应 uid 同样为 11:
/ # id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
/ # su operator
/ $ id
uid=11(operator) gid=0(root) groups=0(root)
/ $ sleep 100
$ ps -ef |grep 'sleep 100'
app      19302 19297  0 16:39 pts/0    00:00:00 sleep 100
$ cat /etc/passwd | grep app
app❌11:0::/home/app:

六、验证不同用户下 ulimit 的限制

  • 设置 ulimit nproc 限制 soft 10/hard 20,默认启动为 root 用户:
$ docker run -d --ulimit nproc=10:20  cr.d.xiaomi.net/containercloud/alpine:webtool top
  • 进入容器查看, fd soft 限制为 100 个:
/ # ulimit -a
-f: file size (blocks)             unlimited
-t: cpu time (seconds)             unlimited
-d: data seg size (kb)             unlimited
-s: stack size (kb)                8192
-c: core file size (blocks)        unlimited
-m: resident set size (kb)         unlimited
-l: locked memory (kb)             64
-p: processes                      10
-n: file descriptors               1048576
-v: address space (kb)             unlimited
-w: locks                          unlimited
-e: scheduling priority            0
-r: real-time priority             0
  • 启动 30 个进程:
/ # for i in `seq 30`;do sleep 100 &; done
/ # ps | wc -l 
36
  • 切换到 operator 用户:
/ # su operator# 启动多个进程,到第11个进程无法进行fork
/ $ for i in `seq 8`; do
> sleep 100 &
> done
/ $ sleep 100 &
/ $ sleep 100 &
sh: can't fork: Resource temporarily unavailable
  • root 下查看:
/ # ps -ef | grep operator79 operator  0:00 sh99 operator  0:00 sleep 100100 operator  0:00 sleep 100101 operator  0:00 sleep 100102 operator  0:00 sleep 100103 operator  0:00 sleep 100104 operator  0:00 sleep 100105 operator  0:00 sleep 100106 operator  0:00 sleep 100107 operator  0:00 sleep 100109 root      0:00 grep operator
/ # ps -ef | grep operator| wc -l
10

七、验证 ulimit 在不同容器相同 uid 下的限制

  • 设置 ulimit nproc 限制 soft 3/hard 3,默认启动为 operator 用户,起 4 个容器,第四个启动失败:
$ docker run -d --ulimit nproc=3:3 --name nproc1 -u operator  cr.d.xiaomi.net/containercloud/alpine:webtool top
eeb1551bf757ad4f112c61cc48d7cbe959185f65109e4b44f28085f246043e65
$ docker run -d --ulimit nproc=3:3 --name nproc2 -u operator  cr.d.xiaomi.net/containercloud/alpine:webtool top
42ff29844565a9cb3af2c8dd560308b1f31306041d3dbd929011d65f1848a262
$ docker run -d --ulimit nproc=3:3 --name nproc3 -u operator  cr.d.xiaomi.net/containercloud/alpine:webtool top
b7c9b469e73f969d922841dd77265467959eda28ed06301af8bf83bcf18e8c23
$ docker run -d --ulimit nproc=3:3 --name nproc4 -u operator  cr.d.xiaomi.net/containercloud/alpine:webtool top
b49d8bb58757c88f69903059af2ee7e2a6cc2fa5774bc531941194c52edfd763
$
$ docker ps -a |grep nproc
b49d8bb58757        cr.d.xiaomi.net/containercloud/alpine:webtool      "top"                    16 seconds ago      Exited (1) 15 seconds ago                               nproc4
b7c9b469e73f        cr.d.xiaomi.net/containercloud/alpine:webtool      "top"                    23 seconds ago      Up 22 seconds                                           nproc3
42ff29844565        cr.d.xiaomi.net/containercloud/alpine:webtool      "top"                    31 seconds ago      Up 29 seconds                                           nproc2
eeb1551bf757        cr.d.xiaomi.net/containercloud/alpine:webtool      "top"                    38 seconds ago      Up 36 seconds                                           nproc1

八、总结

① ulimit

  • ulimit 限制 fd 总数,限制级别进程,可对所有用户生效;
  • ulimit 限制线程总数,限制级别用户(uid),限制同一个 uid 下所有线程/进程数,对于 root 账号无效;
  • 对于目前线上情况,有较小的概率因 ulimit 限制导致 fork 失败,如同一个宿主机中有多个 work 容器且基础镜像相同(即 uid 相同),若一个容器线程泄露,由于 ulimit 限制会影响其他容器正常运行。

② cgroup

  • cgroup 中对 pid 进行了隔离,通过更改 docker/kubelet 配置,可以限制 pid 总数,从而达到限制线程总数的目的。线程数限制与系统中多处配置有关,取最小值,参考 stackoverflow 上线程数的设置:
    • docker,容器启动时设置 –pids-limit 参数,限制容器级别 pid 总数;
    • kubelet,开启 SupportPodPidsLimit 特性,设置 –pod-max-pids 参数,限制 node 每个 pod 的 pid 总数,以 kubelet 为例,开启 SupportPodPidsLimit,–feature-gates=SupportPodPidsLimit=true
  • 配置 kubelet,每个 pod 允许最大 pid 数目为 150:
[root@node01 ~]# ps -ef |grep kubelet
root     18735     1 14 11:19 ?        00:53:28 ./kubelet --v=1 --address=0.0.0.0 --feature-gates=SupportPodPidsLimit=true --pod-max-pids=150 --allow-privileged=true --pod-infra-container-image=cr.d.xiaomi.net/kubernetes/pause-amd64:3.1 --root-dir=/home/kubelet --node-status-update-frequency=5s --kubeconfig=/home/xbox/kubelet/conf/kubelet-kubeconfig --fail-swap-on=false --max-pods=254 --runtime-cgroups=/systemd/system.slice/frigga.service --kubelet-cgroups=/systemd/system.slice/frigga.service --make-iptables-util-chains=false
  • 在 pod 中起测试线程,root 下起 100 个线程:
/ # for i in `seq 100`; do
> sleep 1000 &
> done
/ # ps | wc -l
106
  • operator 下,创建线程受到限制,系统最多只能创建 150 个:
/ # su operator
/ $ 
/ $ for i in `seq 100`; do
> sleep 1000 &
> done
sh: can't fork: Resource temporarily unavailable
/ $ ps | wc -l
150
  • 在 cgroup 中查看,pids 达到最大限制:
[root@node01 ~]# cat /sys/fs/cgroup/pids/kubepods/besteffort/pod8b61d4de-a7ad-11e9-b5b9-246e96ad0900/pids.current 
150
[root@node01 ~]# cat /sys/fs/cgroup/pids/kubepods/besteffort/pod8b61d4de-a7ad-11e9-b5b9-246e96ad0900/pids.max 
150
  • 总结 cgroup 对于 pid 的限制能够达到限制线程数目的,目前 docker 只支持对每个容器的限制,不支持全局配置;kubelet 只支持对于 node 所有 pod 的全局配置,不支持具体每个 pod 的配置。

③ limits.conf/sysctl.conf

  • limits.conf 是 ulimit 的具体配置,目录项 /etc/security/limit.d/ 中的配置会覆盖 limits.conf。
  • sysctl.conf 为机器级别的资源限制,root 用户可修改,目录项 /etc/security/sysctl.d/ 中的配置会覆盖 sysctl.conf,在 /etc/sysctl.conf 中添加对应配置(fd: fs.file-max = {}; pid: kernel.pid_max = {})
  • 测试容器中修改 sysctl.conf 文件:
$ docker run -d --ulimit nofile=100:200 cr.d.xiaomi.net/containercloud/alpine:webtool top
cb1250c8fd217258da51c6818fa2ce2e2f6e35bf1d52648f1f432e6ce579cf0d
$ docker exec -it cb1250c sh/ # ulimit -a
-f: file size (blocks)             unlimited
-t: cpu time (seconds)             unlimited
-d: data seg size (kb)             unlimited
-s: stack size (kb)                8192
-c: core file size (blocks)        unlimited
-m: resident set size (kb)         unlimited
-l: locked memory (kb)             64
-p: processes                      unlimited
-n: file descriptors               100
-v: address space (kb)             unlimited
-w: locks                          unlimited
-e: scheduling priority            0
-r: real-time priority             0
/ # 
/ # echo 10 > /proc/sys/kernel/pid_max
sh: can't create /proc/sys/kernel/pid_max: Read-only file system
/ # echo 10 > /proc/sys/kernel/pid_max
sh: can't create /proc/sys/kernel/pid_max: Read-only file system
/ # echo "fs.file-max=5" >> /etc/sysctl.conf
/ # sysctl -p
sysctl: error setting key 'fs.file-max': Read-only file system
  • 以 priviledged 模式测试,谨慎测试:
$ cat /proc/sys/kernel/pid_max
32768
$ docker run -d -- --ulimit nofile=100:200 cr.d.xiaomi.net/containercloud/alpine:webtool top
$ docker exec -it pedantic_vaughan sh
/ # cat /proc/sys/kernel/pid_max
32768
/ # echo 50000 > /proc/sys/kernel/pid_max
/ # cat /proc/sys/kernel/pid_max
50000
/ # exit
$ cat /proc/sys/kernel/pid_max
50000 # 宿主机的文件也变成50000
  • 由于 docker 隔离的不彻底,在 docker 中修改 sysctl 会覆盖主机中的配置,不能用来实现容器级别资源限制 limits.conf 可以在容器中设置,效果同 ulimit。

在这里插入图片描述

  • 推荐方案如下:
    • fd 限制:修改 dockerd 配置 default-ulimits,限制进程级别 fd;
    • thread 限制:修改 kubelet 配置 --feature-gates=SupportPodPidsLimit=true - -pod-max-pids={},cgroup 级别限制 pid,从而限制线程数;
    • 其他注意事项,调整节点 pid.max 参数;放开或者调大镜像中 ulimit 对非 root 账户 nproc 限制。

相关文章:

云原生之深入解析如何限制Kubernetes集群中文件描述符与线程数量

一、背景 linux 中为了防止进程恶意使用资源&#xff0c;系统使用 ulimit 来限制进程的资源使用情况&#xff08;包括文件描述符&#xff0c;线程数&#xff0c;内存大小等&#xff09;。同样地在容器化场景中&#xff0c;需要限制其系统资源的使用量。ulimit: docker 默认支持…...

Django的Auth模块

Auth模块 我们在创建好一个Django项目后执行数据库迁移命令会自动生成很多表 其中有auth_user等表 Django在启动之后就可以直接访问admin路由&#xff0c;需要输入用户名和密码&#xff0c;数据参考的就是auth_user表&#xff0c;并且必须是管理员才能进入 依赖于a…...

敏捷开发方法

理解&#xff1a; 极限编程&#xff08;XP&#xff09;&#xff1a;敏捷开发的典型方法之一&#xff0c;是一种轻量级&#xff08;敏捷&#xff09;、高效&#xff0c;低风险、柔性、可预测的、科学的软件开发方法&#xff0c;它由价值观、原则、实践和行为4个部分组成。其中4大…...

vue 前端实现login页登陆 验证码

实现效果 // template <el-form :model"loginForm" :rules"fieldRules" ref"loginForm" label-position"left" label-width"0px" class"login-container"><span class"tool-bar"></sp…...

python 涉及opencv mediapipe知识,眨眼计数 供初学者参考

基本思路 我们知道正面侦测到人脸时&#xff0c;任意一只眼睛水平方向上的两个特征点构成水平距离&#xff0c;上下两个特征点构成垂直距离 当头像靠近或者远离摄像头时&#xff0c;垂直距离与水平距离的比值基本恒定 根据这一思路 当闭眼时 垂直距离变小 比值固定小于某一个…...

HTTP 和 HTTPS的区别

一、HTTP 1.明文传输&#xff0c;不安全 2.默认端口号&#xff1a;80 3.TCP三次握手即可 二、HTTPS 1.加密传输&#xff0c;更安全(在HTTP层与TCP层之间加上了SSL/TTL安全协议) SSL和TTL是在不同时期的两种叫法&#xff0c;含义相同。 2.默认端口号&#xff1a;443 3.TCP三…...

从零开始训练一个ChatGPT大模型(低资源,1B3)

macrogpt-prertrain 大模型全量预训练(1b3), 多卡deepspeed/单卡adafactor 源码地址&#xff1a;https://github.com/yongzhuo/MacroGPT-Pretrain.git 踩坑 1. 数据类型fp16不太行, 很容易就Nan了, 最好是fp32, tf32, 2. 单卡如果显存不够, 可以用优化器adafactor, 3. 如果…...

从文字到使用,一文读懂Kafka服务使用

&#x1f3c6;作者简介&#xff0c;普修罗双战士&#xff0c;一直追求不断学习和成长&#xff0c;在技术的道路上持续探索和实践。 &#x1f3c6;多年互联网行业从业经验&#xff0c;历任核心研发工程师&#xff0c;项目技术负责人。 &#x1f389;欢迎 &#x1f44d;点赞✍评论…...

什么是https加密协议?

前言&#xff1a; HTTPS&#xff08;全称&#xff1a;Hypertext Transfer Protocol Secure&#xff09; 是一个安全通信通道&#xff0c;它基于HTTP开发用于在客户计算机和服务器之间交换信息。它使用安全套接字层(SSL)进行信息交换&#xff0c;简单来说它是HTTP的安全版&…...

0012Java程序设计-ssm医院预约挂号及排队叫号系统

文章目录 **摘** **要**目 录系统实现5.2后端功能模块5.2.1管理员功能模块5.2.2医生功能模块 开发环境 摘 要 网络的广泛应用给生活带来了十分的便利。所以把医院预约挂号及排队叫号管理与现在网络相结合&#xff0c;利用java技术建设医院预约挂号及排队叫号系统&#xff0c;实…...

PaddleClas学习3——使用PPLCNet模型对车辆朝向进行识别(c++)

使用PPLCNet模型对车辆朝向进行识别 1 准备环境2 准备模型2.1 模型导出2.2 修改配置文件3 编译3.1 使用CMake生成项目文件3.2 编译3.3 执行3.4 添加后处理程序3.4.1 postprocess.h3.4.2 postprocess.cpp3.4.3 在cls.h中添加函数声明3.4.4 在cls.cpp中添加函数定义3.4.5 在main.…...

学习记录---kubernetes中备份和恢复etcd

一、简介 ETCD是kubernetes的重要组成部分&#xff0c;它主要用于存储kubernetes的所有元数据&#xff0c;我们在kubernetes中的所有资源(node、pod、deployment、service等)&#xff0c;如果该组件出现问题&#xff0c;则可能会导致kubernetes无法使用、资源丢失等情况。因此…...

使用单例模式+观察者模式实现参数配置实时更新

使用vector存储观察者列表 #include <iostream> #include <vector> #include <functional> #include <algorithm>// 配置参数结构体 struct MyConfigStruct {int parameter1;std::string parameter2; };class Config { public:using Observer std::f…...

区块链实验室(28) - 拜占庭节点劫持区块链仿真

在以前的FISCO环境中仿真拜占庭节点攻击区块链网络。该环境共有100个节点&#xff0c;采用PBFT作为共识机制&#xff0c;节点编号分别为&#xff1a;Node0&#xff0c;Node&#xff0c;… &#xff0c;Node99。这100个节点的前2010区块完全相同&#xff0c;自区块2011开始分叉。…...

聊聊AsyncHttpClient的ChannelPool

序 本文主要研究一下AsyncHttpClient的ChannelPool ChannelPool org/asynchttpclient/channel/ChannelPool.java public interface ChannelPool {/*** Add a channel to the pool** param channel an I/O channel* param partitionKey a key used to retrieve the cac…...

[MySQL] MySQL复合查询(多表查询、子查询)

前面我们学习了MySQL简单的单表查询。但是我们发现&#xff0c;在很多情况下单表查询并不能很好的满足我们的查询需求。本篇文章会重点讲解MySQL中的多表查询、子查询和一些复杂查询。希望本篇文章会对你有所帮助。 文章目录 一、基本查询回顾 二、多表查询 2、1 笛卡尔积 2、2…...

[架构之路-256]:目标系统 - 设计方法 - 软件工程 - 软件设计 - 架构设计 - 软件系统不同层次的复用与软件系统向越来越复杂的方向聚合

目录 前言&#xff1a; 一、CPU寄存器级的复用&#xff1a;CPU寄存器 二、指令级复用&#xff1a;二进制指令 三、过程级复用&#xff1a;汇编语言 四、函数级复用&#xff1a;C语言 五、对象级复用&#xff1a;C, Java, Python 六、组件级复用 七、服务级复用 八、微…...

C++初学教程三

目录 一、运算符 一、自增自减运算符 二、位运算符 三、关系运算符...

雷达点云数据.pcd格式转.bin格式

雷达点云数据.pcd格式转.bin格式 注意&#xff0c;方法1原则上可行&#xff0c;但是本人没整好pypcd的环境 方法2是绝对可以的。 方法1 1 源码如下&#xff1a; def pcb2bin1(): # save as bin formatimport os# import pypcdfrom pypcd import pypcdimport numpy as np…...

Fiddler抓包测试

模拟弱网测试 操作&#xff1a;一、Rules - Customize Rules &#xff08;快捷键CtrlR&#xff09;弹出编辑器 二、接着CtrlF查找m_SimulateModem标志位 三、默认上传300ms&#xff0c;下载150ms 四、更改后&#xff0c;继续Rules - Performances - Simulate Modem Speeds勾上 …...

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…...

零门槛NAS搭建:WinNAS如何让普通电脑秒变私有云?

一、核心优势&#xff1a;专为Windows用户设计的极简NAS WinNAS由深圳耘想存储科技开发&#xff0c;是一款收费低廉但功能全面的Windows NAS工具&#xff0c;主打“无学习成本部署” 。与其他NAS软件相比&#xff0c;其优势在于&#xff1a; 无需硬件改造&#xff1a;将任意W…...

练习(含atoi的模拟实现,自定义类型等练习)

一、结构体大小的计算及位段 &#xff08;结构体大小计算及位段 详解请看&#xff1a;自定义类型&#xff1a;结构体进阶-CSDN博客&#xff09; 1.在32位系统环境&#xff0c;编译选项为4字节对齐&#xff0c;那么sizeof(A)和sizeof(B)是多少&#xff1f; #pragma pack(4)st…...

leetcodeSQL解题:3564. 季节性销售分析

leetcodeSQL解题&#xff1a;3564. 季节性销售分析 题目&#xff1a; 表&#xff1a;sales ---------------------- | Column Name | Type | ---------------------- | sale_id | int | | product_id | int | | sale_date | date | | quantity | int | | price | decimal | -…...

NLP学习路线图(二十三):长短期记忆网络(LSTM)

在自然语言处理(NLP)领域,我们时刻面临着处理序列数据的核心挑战。无论是理解句子的结构、分析文本的情感,还是实现语言的翻译,都需要模型能够捕捉词语之间依时序产生的复杂依赖关系。传统的神经网络结构在处理这种序列依赖时显得力不从心,而循环神经网络(RNN) 曾被视为…...

汇编常见指令

汇编常见指令 一、数据传送指令 指令功能示例说明MOV数据传送MOV EAX, 10将立即数 10 送入 EAXMOV [EBX], EAX将 EAX 值存入 EBX 指向的内存LEA加载有效地址LEA EAX, [EBX4]将 EBX4 的地址存入 EAX&#xff08;不访问内存&#xff09;XCHG交换数据XCHG EAX, EBX交换 EAX 和 EB…...

OPENCV形态学基础之二腐蚀

一.腐蚀的原理 (图1) 数学表达式&#xff1a;dst(x,y) erode(src(x,y)) min(x,y)src(xx,yy) 腐蚀也是图像形态学的基本功能之一&#xff0c;腐蚀跟膨胀属于反向操作&#xff0c;膨胀是把图像图像变大&#xff0c;而腐蚀就是把图像变小。腐蚀后的图像变小变暗淡。 腐蚀…...

Xen Server服务器释放磁盘空间

disk.sh #!/bin/bashcd /run/sr-mount/e54f0646-ae11-0457-b64f-eba4673b824c # 全部虚拟机物理磁盘文件存储 a$(ls -l | awk {print $NF} | cut -d. -f1) # 使用中的虚拟机物理磁盘文件 b$(xe vm-disk-list --multiple | grep uuid | awk {print $NF})printf "%s\n"…...

Aspose.PDF 限制绕过方案:Java 字节码技术实战分享(仅供学习)

Aspose.PDF 限制绕过方案&#xff1a;Java 字节码技术实战分享&#xff08;仅供学习&#xff09; 一、Aspose.PDF 简介二、说明&#xff08;⚠️仅供学习与研究使用&#xff09;三、技术流程总览四、准备工作1. 下载 Jar 包2. Maven 项目依赖配置 五、字节码修改实现代码&#…...

springboot整合VUE之在线教育管理系统简介

可以学习到的技能 学会常用技术栈的使用 独立开发项目 学会前端的开发流程 学会后端的开发流程 学会数据库的设计 学会前后端接口调用方式 学会多模块之间的关联 学会数据的处理 适用人群 在校学生&#xff0c;小白用户&#xff0c;想学习知识的 有点基础&#xff0c;想要通过项…...