成本效能FinOps: Crane 部署

目录

 一、实验

1.环境

2.安装kind

3.安装Crane

二、问题

1.脚本安装prometheus报错

2.查看集群信息失败

3.Helm添加grafana 报错

4.查看crane资源失败

5.prometheus部署时kube-state-metrics 拉取镜像显示ImagePullBackOff 

6.Crane 功能与架构


 一、实验

1.环境

(1)主机

表1  主机

主机架构版本IP备注
master1K8S master节点1.20.6192.168.204.180

Docker 20.10.6
Helm3.8.1
kind0.14
master2K8S master节点1.20.6192.168.204.181
node1K8S node节点1.20.6192.168.204.182

(2)查看集群状态

kubectl get node

(3) 查看HELM版本

helm version

(4)查看Docker版本

docker -v

2.安装kind

(1)安装

wget  https://github.com/kubernetes-sigs/kind/releases/download/v0.14.0/kind-linux-amd64
 
mv kind-linux-amd64  /usr/bin/kind
chmod +x /usr/bin/kind

(2)查看kind版本

kind version

3.安装Crane

(1)安装 Crane 以及其依赖 (Prometheus/Grafana)

① 第一种方式

curl -sf https://raw.githubusercontent.com/gocrane/crane/main/hack/local-env-setup.sh | sh -

②第二种方式

如果上面第一种方式安装命令报网络错误,可以下载本地的安装包执行安装

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

function help()
{
  cat  <<EOF

The crane local environment setup

Usage: local-env-setup.sh <[Options]>
Options:
         -h   --help           help for setup
         -m   --mirror         setup crane from helm mirror repo
EOF

}

FROM_MIRROR=false

while [ $# -gt 0 ]
do
    case $1 in
    -h|--help) help ; exit 1;;
    -m|--mirror) FROM_MIRROR=true ;;
    (-*) echo "$0: error - unrecognized option $1" 1>&2; help; exit 1;;
    (*) break;;
    esac
    shift
done


CRANE_KUBECONFIG="${HOME}/.kube/config_crane"
CRANE_CLUSTER_NAME="crane"

PROMETHEUS_HELM_NAME="prometheus-community"
PROMETHEUS_HELM_URL="https://prometheus-community.github.io/helm-charts"
PROMETHEUS_VALUE_URL="https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml"
GRAFANA_HELM_NAME="grafana"
GRAFANA_HELM_URL="https://grafana.github.io/helm-charts"
GRAFANA_HELM_PACKAGE_URL="https://github.com/grafana/helm-charts/releases/download/grafana-6.11.0/grafana-6.11.0.tgz"
GRAFANA_VALUE_URL="https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml"
CRANE_HELM_NAME="crane"
CRANE_HELM_URL="https://gocrane.github.io/helm-charts"

# check if setup is from mirror repo

if [ "$FROM_MIRROR" = true ]; then
  PROMETHEUS_HELM_NAME="prometheus-community-gocrane"
  PROMETHEUS_HELM_URL="https://finops-helm.pkg.coding.net/gocrane/prometheus-community"
  PROMETHEUS_VALUE_URL="https://gitee.com/finops/helm-charts/raw/main/integration/prometheus/override_values.yaml"
  GRAFANA_HELM_NAME="grafana-gocrane"
  GRAFANA_HELM_URL="https://finops-helm.pkg.coding.net/gocrane/grafana"
  GRAFANA_HELM_PACKAGE_URL="https://finops-generic.pkg.coding.net/gocrane/generic/grafana-6.11.0.tgz\?version\=latest"
  GRAFANA_VALUE_URL="https://gitee.com/finops/helm-charts/raw/main/integration/grafana/override_values.yaml"
  CRANE_HELM_NAME="crane-mirror"
  CRANE_HELM_URL="https://finops-helm.pkg.coding.net/gocrane/gocrane"
fi

echo "Step1: Create local cluster: " ${CRANE_KUBECONFIG}
kind delete cluster --name="${CRANE_CLUSTER_NAME}" 2>&1
kind create cluster --kubeconfig "${CRANE_KUBECONFIG}" --name "${CRANE_CLUSTER_NAME}" --image kindest/node:v1.21.1
export KUBECONFIG="${CRANE_KUBECONFIG}"
echo "Step1: Create local cluster finished."

echo "Step2: Installing Prometheus "
helm repo add ${PROMETHEUS_HELM_NAME} ${PROMETHEUS_HELM_URL}
helm install prometheus -n crane-system --version 19.6.1 \
                        --set prometheus-pushgateway.enabled=false \
                        --set alertmanager.enabled=false \
                        --set server.persistentVolume.enabled=false \
                        -f ${PROMETHEUS_VALUE_URL} \
                        --create-namespace  ${PROMETHEUS_HELM_NAME}/prometheus
echo "Step2: Installing Prometheus finished."

echo "Step3: Installing Grafana "

helm install grafana \
    -f ${GRAFANA_VALUE_URL} \
    -n crane-system \
    --create-namespace ${GRAFANA_HELM_PACKAGE_URL}

echo "Step3: Installing Grafana finished."

echo "Step4: Installing Crane "
helm repo add ${CRANE_HELM_NAME} ${CRANE_HELM_URL}
helm repo update
helm install crane -n crane-system --set craneAgent.enable=false --create-namespace ${CRANE_HELM_NAME}/crane
helm install fadvisor -n crane-system --create-namespace ${CRANE_HELM_NAME}/fadvisor
echo "Step4: Installing Crane finished."

kubectl get deploy -n crane-system
echo "Please wait for all pods ready"
echo "After all pods ready, Get the Crane Dashboard URL to visit by running these commands in the same shell:"
echo "    export KUBECONFIG=${HOME}/.kube/config_crane"
echo "    kubectl -n crane-system port-forward service/craned 9090:9090"

在命令行中执行以下安装命令

bash installation/local-env-setup.sh

③查看目录

tree -l

④ 安装(第二种方式)

[root@master1 trainning]# bash installation/local-env-setup.sh
Step1: Create local cluster:  /root/.kube/config_crane
Deleting cluster "crane" ...
Creating cluster "crane" ...
 ? Ensuring node image (kindest/node:v1.21.1) ?? 
 ? Preparing nodes ??  
 ? Writing configuration ?? 
 ? Starting control-plane ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? 
 ? Installing CNI ?? 
 ? Installing StorageClass ?? 
Set kubectl context to "kind-crane"
You can now use your cluster with:

kubectl cluster-info --context kind-crane --kubeconfig /root/.kube/config_crane

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community ??
Step1: Create local cluster finished.
Step2: Installing Prometheus 
"prometheus-community" already exists with the same configuration, skipping
NAME: prometheus
LAST DEPLOYED: Sat Feb 17 12:04:46 2024
NAMESPACE: crane-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The Prometheus server can be accessed via port 8080 on the following DNS name from within your cluster:
prometheus-server.crane-system.svc.cluster.local


Get the Prometheus server URL by running these commands in the same shell:
  export POD_NAME=$(kubectl get pods --namespace crane-system -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
  kubectl --namespace crane-system port-forward $POD_NAME 9090
#################################################################################
######   WARNING: Persistence is disabled!!! You will lose your data when   #####
######            the Server pod is terminated.                             #####
#################################################################################


#################################################################################
######   WARNING: Pod Security Policy has been disabled by default since    #####
######            it deprecated after k8s 1.25+. use                        #####
######            (index .Values "prometheus-node-exporter" "rbac"          #####
###### .          "pspEnabled") with (index .Values                         #####
######            "prometheus-node-exporter" "rbac" "pspAnnotations")       #####
######            in case you still need it.                                #####
#################################################################################



For more information on running Prometheus, visit:
https://prometheus.io/
Step2: Installing Prometheus finished.
Step3: Installing Grafana 
W0217 12:05:03.547672   75224 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
W0217 12:05:03.550698   75224 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
W0217 12:05:03.670581   75224 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
W0217 12:05:03.670892   75224 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
NAME: grafana
LAST DEPLOYED: Sat Feb 17 12:05:03 2024
NAMESPACE: crane-system
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:

   kubectl get secret --namespace crane-system grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

2. The Grafana server can be accessed via port 8082 on the following DNS name from within your cluster:

   grafana.crane-system.svc.cluster.local

   Get the Grafana URL to visit by running these commands in the same shell:

     export POD_NAME=$(kubectl get pods --namespace crane-system -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=grafana" -o jsonpath="{.items[0].metadata.name}")
     kubectl --namespace crane-system port-forward $POD_NAME 3000

3. Login with the password from step 1 and the username: admin
#################################################################################
######   WARNING: Persistence is disabled!!! You will lose your data when   #####
######            the Grafana pod is terminated.                            #####
#################################################################################
Step3: Installing Grafana finished.
Step4: Installing Crane 
"crane" has been added to your repositories
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "aliyun" chart repository
...Successfully got an update from the "crane" chart repository
...Successfully got an update from the "bitnami" chart repository
...Successfully got an update from the "prometheus-community" chart repository
...Successfully got an update from the "grafana" chart repository
Update Complete. ?Happy Helming!?
NAME: crane
LAST DEPLOYED: Sat Feb 17 12:07:58 2024
NAMESPACE: crane-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NAME: fadvisor
LAST DEPLOYED: Sat Feb 17 12:08:02 2024
NAMESPACE: crane-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
Step4: Installing Crane finished.
NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
craned                          0/1     1            0           4s
fadvisor                        0/1     1            0           1s
grafana                         1/1     1            1           3m
metric-adapter                  0/1     1            0           4s
prometheus-kube-state-metrics   0/1     1            0           3m16s
prometheus-server               1/1     1            1           3m17s
Please wait for all pods ready
After all pods ready, Get the Crane Dashboard URL to visit by running these commands in the same shell:
    export KUBECONFIG=/root/.kube/config_crane
    kubectl -n crane-system port-forward service/craned 9090:9090

Step1

Step2

Step3

Step4

(3)设置环境变量

export KUBECONFIG=${HOME}/.kube/config_crane

(4)查看deploy

kubectl get deploy -n crane-system

(5)查看pod

kubectl get pod -n crane-system


(7)查看svc 

kubectl get svc -n crane-system

(8) 访问dashboard (端口映射)

 增加端口映射后,访问127.0.0.1:9090即可

kubectl -n crane-system port-forward service/craned 9090:9090

(9)访问dashboard(NodePort)

# Change service type
kubectl patch svc craned -n crane-system -p '{"spec": {"type": "NodePort"}}'

# Get Dashboard link base on your cluster configuration
PORT=$(kubectl get svc -n crane-system craned -o jsonpath='{.spec.ports[?(@.name == "dashboard-service")].nodePort}')
NODE_IP=$(kubectl get node -ojsonpath='{.items[].status.addresses[?(@.type == "InternalIP")].address}')
echo "Dashboard link: http://${NODE_IP}:${PORT}"

二、问题

1.脚本安装prometheus报错

(1)报错

Error: INSTALLATION FAILED: failed to download "prometheus-community/prometheus" at version "19.6.1"

(2)原因分析

helm下载prometheus-community 失败

(3)解决方法

更新 charts 列表

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

helm repo list

helm repo update

2.查看集群信息失败

(1)报错

Unable to connect to the server: dial tcp 192.168.204.199:16443: connect: no route to host

(2)原因分析

查询网卡信息,发现虚拟ip:192.168.204.199未生效

ip a s ens33

(3)解决方法

重启keepalived

systemctl restart keepalived.service

成功

3.Helm手动添加grafana 报错

(1)报错

Error: context deadline exceeded

(2)原因分析

超时。

(3)解决方法

 更新 charts 列表

 helm repo add grafana https://grafana.github.io/helm-charts

helm repo list

helm repo update

如需手动添加crane

​helm repo add crane https://gocrane.github.io/helm-charts

helm repo list

4.查看crane资源失败

(1)报错

(2)原因分析

未申明变量。

(3)解决方法

申明变量

export KUBECONFIG=${HOME}/.kube/config_crane

成功:

5. prometheus部署时kube-state-metrics 拉取镜像显示ImagePullBackOff 

(1)报错

(2)原因分析

[root@master1 trainning]# kubectl describe pod prometheus-kube-state-metrics-69c44479cb-wfn62 -n crane-system
Name:         prometheus-kube-state-metrics-69c44479cb-wfn62
Namespace:    crane-system
Priority:     0
Node:         crane-control-plane/172.18.0.2
Start Time:   Sat, 17 Feb 2024 12:05:04 +0800
Labels:       app.kubernetes.io/component=metrics
              app.kubernetes.io/instance=prometheus
              app.kubernetes.io/managed-by=Helm
              app.kubernetes.io/name=kube-state-metrics
              app.kubernetes.io/part-of=kube-state-metrics
              app.kubernetes.io/version=2.8.0
              helm.sh/chart=kube-state-metrics-4.30.0
              pod-template-hash=69c44479cb
Annotations:  <none>
Status:       Pending
IP:           10.244.0.4
IPs:
  IP:           10.244.0.4
Controlled By:  ReplicaSet/prometheus-kube-state-metrics-69c44479cb
Containers:
  kube-state-metrics:
    Container ID:  
    Image:         ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4
    Image ID:      
    Port:          8080/TCP
    Host Port:     0/TCP
    Args:
      --port=8080
      --resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Liveness:       http-get http://:8080/healthz delay=5s timeout=5s period=10s #success=1 #failure=3
    Readiness:      http-get http://:8080/ delay=5s timeout=5s period=10s #success=1 #failure=3
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mnqcw (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  kube-api-access-mnqcw:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age                   From               Message
  ----     ------            ----                  ----               -------
  Warning  FailedScheduling  12m (x3 over 13m)     default-scheduler  0/1 nodes are available: 1 node(s) had taint {node.kubernetes.io/not-ready: }, that the pod didn't tolerate.
  Normal   Scheduled         12m                   default-scheduler  Successfully assigned crane-system/prometheus-kube-state-metrics-69c44479cb-wfn62 to crane-control-plane
  Warning  Failed            12m                   kubelet            Failed to pull image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": rpc error: code = FailedPrecondition desc = failed to pull and unpack image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": failed commit on ref "layer-sha256:be53542da88544c0fa283026dcdfb7abe500f5ec3c52e1d67c2fdbc8a8600953": unexpected commit digest sha256:bf49da642e8b7be842a34571397692cc0a84b174cc3f43b11a7f2f566c73b011, expected sha256:be53542da88544c0fa283026dcdfb7abe500f5ec3c52e1d67c2fdbc8a8600953: failed precondition
  Warning  Failed            11m                   kubelet            Failed to pull image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": rpc error: code = FailedPrecondition desc = failed to pull and unpack image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": failed commit on ref "layer-sha256:be53542da88544c0fa283026dcdfb7abe500f5ec3c52e1d67c2fdbc8a8600953": unexpected commit digest sha256:405ad6c7e360ee2ec0d1d209e0a6b0223afeadf27eb2e779414fffcbe6667274, expected sha256:be53542da88544c0fa283026dcdfb7abe500f5ec3c52e1d67c2fdbc8a8600953: failed precondition
  Warning  Failed            11m                   kubelet            Failed to pull image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": rpc error: code = FailedPrecondition desc = failed to pull and unpack image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": failed commit on ref "layer-sha256:bd14ac32149bba6a560651d8a6a836bc6dde7781109aeef9b6c693e2b7b96bfa": unexpected commit digest sha256:b4979e55d7058c14cee5e1e44a26215b7243234a88a3dabeda63a17962acfedc, expected sha256:bd14ac32149bba6a560651d8a6a836bc6dde7781109aeef9b6c693e2b7b96bfa: failed precondition
  Normal   Pulling           10m (x4 over 12m)     kubelet            Pulling image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4"
  Warning  Failed            10m (x4 over 12m)     kubelet            Error: ErrImagePull
  Warning  Failed            10m                   kubelet            Failed to pull image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": rpc error: code = FailedPrecondition desc = failed to pull and unpack image "ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4": failed commit on ref "layer-sha256:bd14ac32149bba6a560651d8a6a836bc6dde7781109aeef9b6c693e2b7b96bfa": unexpected commit digest sha256:744e5904c346df90e59a66226736e6f8dac711cb61713852eeaa8e1336b78996, expected sha256:bd14ac32149bba6a560651d8a6a836bc6dde7781109aeef9b6c693e2b7b96bfa: failed precondition
  Warning  Failed            10m (x6 over 12m)     kubelet            Error: ImagePullBackOff
  Normal   BackOff           2m33s (x38 over 12m)  kubelet            Back-off pulling image "ccr.ccs.tencentyun.com/tkeimages/kube-stat

(3)解决方法

node节点 搜索拉取的镜像信息

docker search kube-state-metrics

拉取到本地镜像仓库

docker pull bitnami/kube-state-metrics

查看镜像

docker images

master节点查看deploy

kubectl get deploy -n crane-system

master节点修改deploy

 kubectl edit deploy prometheus-kube-state-metrics -n  crane-system

修改前:

 image: ccr.ccs.tencentyun.com/tkeimages/kube-state-metrics:2.2.4

修改后:

image: docker.io/bitnami/kube-state-metrics:latest

成功:

6.Crane 功能与架构

(1)查阅

#官网
https://gocrane.io/

#Github
https://github.com/gocrane/crane

#中文安装
https://gocrane.io/zh-cn/docs/getting-started/installation/installation/

(2)功能

(3)架构

核心组件:
1)Craned 
它是 Crane 的最核心组件,它管理了 CRDs 的生命周期以及API。
Craned 通过 Deployment 方式部署且由两个容器组成:
Craned: 运行了 Operators 用来管理 CRDs,向 Dashboard 提供了 WebApi,Predictors 提供了 TimeSeries API
Dashboard: 基于 TDesign‘s Starter 脚手架研发的前端项目,提供了易于上手的产品功能

2)Fadvisor 
它提供一组 Exporter 计算集群云资源的计费和账单数据并存储到我们的监控系统,比如 Prometheus。
Fadvisor 通过 Cloud Provider 支持了多云计费的 API。

3)Metric Adapter
它实现了一个 Custom Metric Apiserver. Metric Adapter 读取 CRDs 信息并提供基于 Custom/External Metric API 的 HPA Metric 的数据。

4)Crane Agent
它是一个用于在 Kubernetes 集群中管理 Docker 镜像的工具
通过 DaemonSet 部署在集群的节点上。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/391105.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

智慧公厕的主要应用

在现代社会中&#xff0c;随着城市化进程的加速推进&#xff0c;公共卫生设施的建设和管理变得愈加重要。而智慧公厕作为一种新型城市公共设施&#xff0c;正以其智能化、高效化的特点&#xff0c;成为改善城市卫生环境的重要手段。智慧公厕运用物联网、互联网、大数据、云计算…

HAL/LL/STD STM32 U8g2库 +I2C SSD1306/sh1106 WouoUI磁贴案例

HAL/LL/STD STM32 U8g2库 I2C SSD1306/sh1106 WouoUI磁贴案例 &#x1f4cd;基于STM32F103C8T6 LL库驱动版本&#xff1a;https://gitee.com/chcsx/platform-test/tree/master/MDK-ARM&#x1f3ac;视频演示&#xff1a; WouoUI移植磁贴案例&#xff0c;新增确认弹窗 &#x1f…

无人驾驶LQR控制算法 c++ 实现

参考博客&#xff1a; &#xff08;1&#xff09;LQR的理解与运用 第一期——理解篇 &#xff08;2&#xff09;线性二次型调节器(LQR)原理详解 &#xff08;3&#xff09;LQR控制基本原理&#xff08;包括Riccati方程具体推导过程&#xff09; &#xff08;4&#xff09;【基础…

精品jsp+ssm鲜花销售管理系统-购物商城

《[含文档PPT源码等]精品jspssm鲜花销售管理系统[包运行成功]》该项目含有源码、文档、PPT、配套开发软件、软件安装教程、项目发布教程、包运行成功&#xff01; 使用技术&#xff1a; 开发语言&#xff1a;Java 框架&#xff1a;ssm 技术&#xff1a;JSP JDK版本&#x…

微信小程序如何配置服务器域名

目录 一、微信小程序 二、域名 三、服务器 四、如何配置服务器域名 一、微信小程序 微信小程序是一种轻量级的应用程序&#xff0c;用户无需下载安装即可使用&#xff0c;具有便捷、快捷的特点。微信小程序可以在微信内直接使用&#xff0c;无需离开微信即可完成各种功能&…

Leetcode - 周赛384

目录 一&#xff0c;3033. 修改矩阵 二&#xff0c;3035. 回文字符串的最大数量 三&#xff0c;3036. 匹配模式数组的子数组数目 II 一&#xff0c;3033. 修改矩阵 这道题直接暴力求解&#xff0c;先算出每一列的最大值&#xff0c;再将所有为-1的区域替换成该列的最大值&am…

人工智能学习与实训笔记(七):神经网络之推荐系统处理

九、模型压缩与知识蒸馏 出于对响应速度&#xff0c;存储大小和能耗的考虑&#xff0c;往往需要对大模型进行压缩。 模型压缩方法主要可以分为以下四类&#xff1a; 参数修剪和量化&#xff08;Parameter pruning and quantization&#xff09;&#xff1a;用于消除对模型表…

Java 学习和实践笔记(12)

这个就比较有意思了&#xff01;所有的事情&#xff0c;拆分完之后&#xff0c;都有且只有这三种状态流程&#xff01; //TIP To <b>Run</b> code, press <shortcut actionId"Run"/> or // click the <icon src"AllIcons.Actions.Execute&…

Vue源码系列讲解——模板编译篇【二】(整体运行流程)

目录 1. 整体流程 2. 回到源码 3. 总结 1. 整体流程 上篇文章中我们说了&#xff0c;在模板解析阶段主要做的工作是把用户在<template></template>标签内写的模板使用正则等方式解析成抽象语法树&#xff08;AST&#xff09;。而这一阶段在源码中对应解析器&…

《区块链公链数据分析简易速速上手小册》第7章:数据获取和分析的挑战(2024 最新版)

文章目录 7.1 数据准确性和完整性验证7.1.1 基础知识7.1.2 重点案例&#xff1a;验证加密货币交易数据准备工作实现步骤步骤1: 从 API 获取比特币交易数据步骤2: 数据转换和初步校验步骤3: 验证交易数据的格式和范围 结论 7.1.3 拓展案例 1&#xff1a;使用哈希校验数据完整性准…

NLP_Transformer架构

文章目录 Transformer架构剖析编码器-解码器架构各种注意力的应用Transformer中的自注意力Transformer中的多头自注意力Transformer中的编码器-解码器注意力Transformer中的注意力掩码和因果注意力 编码器的输入和位置编码编码器的内部结构编码器的输出和编码器-解码器的连接解…

NBA2K24 精品蔡徐坤面补

NBA2K24 精品蔡徐坤面补 NBA2K23-NBA2K24通用 精品蔡徐坤面补 下载地址&#xff1a; https://www.changyouzuhao.cn/13072.html

BUGKU-WEB eval

题目描述 题目截图如下&#xff1a; 进入场景看看&#xff1a; <?phpinclude "flag.php";$a $_REQUEST[hello];eval( "var_dump($a);");show_source(__FILE__); ?>解题思路 PHP代码审计咯 相关工具 百度搜索PHP相关知识 解题步骤 分析脚…

C++数据结构与算法——栈与队列

C第二阶段——数据结构和算法&#xff0c;之前学过一点点数据结构&#xff0c;当时是基于Python来学习的&#xff0c;现在基于C查漏补缺&#xff0c;尤其是树的部分。这一部分计划一个月&#xff0c;主要利用代码随想录来学习&#xff0c;刷题使用力扣网站&#xff0c;不定时更…

java+SSM+mysql 开放式实验管理系统78512-计算机毕业设计项目选题推荐(免费领源码)

摘 要 我国高校开放式实验管理普遍存在实验设备使用率较低、管理制度不完善,实验设备共享程度不高等诸多问题。要在更大范围推行开放式实验管理,就必须在开放式实验教学管理流程中,通过引入信息化管理加大信息技术在其中的应用,才能真正发挥这种教学模式的开放性优势。 本系统…

C#,二进制数的非0位数统计(Bits Count)的算法与源代码

计算一个十进制数的二进制表示有多少位1&#xff1f; 1 遍历法&#xff08;递归或非递归&#xff09; 使用循环按位统计1的个数。 2 哈希查表法 利用一个数组或哈希生成一张表&#xff0c;存储不同二进制编码对应的值为1的二进制位数&#xff0c;那么在使用时&#xff0c;只…

MIT-BEVFusion系列八--onnx导出2 spconv network网络导出

这里写目录标题 export-scn.py加载模型设置每层的精度属性初始化输入参数导出模型model.encoder_layers 设置初始化参数设置 indice_key 属性更改 lidar backbone 的 forward更改lidar网络内各个层的forward带参数装饰器&#xff0c;钩子函数代码使用装饰器修改forward举例 跟踪…

GPU芯片逆势扩张,NVIDIA成为2023年全球芯片的唯一赢家

市调机构Gartner发布数据指出2023年全球诸多芯片行业都在下滑&#xff0c;唯一取得增长的仅有GPU/AI芯片&#xff0c;GPU芯片的市场规模增加了一倍&#xff0c;而领头羊NVIDIA无疑成为最大的赢家。 从2022年下半年以来&#xff0c;全球芯片行业就已步入供给过剩的阶段&#xff…

HarmonyOS—状态管理概述

在前文的描述中&#xff0c;我们构建的页面多为静态界面。如果希望构建一个动态的、有交互的界面&#xff0c;就需要引入“状态”的概念。 图1 效果图 上面的示例中&#xff0c;用户与应用程序的交互触发了文本状态变更&#xff0c;状态变更引起了UI渲染&#xff0c;UI从“He…

C++中对象的构造与析构顺序

一、对象的构造顺序 对象的构造&#xff0c;先被创建的对象&#xff0c;先被构造&#xff0c;先调用其构造函数 class A { private:int _a 0; public://构造函数A(int a 0){_a a;cout << "A(int a 0)" << " " << _a << endl…