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

营销型网站三要素网络seo公司

营销型网站三要素,网络seo公司,昆明公司网站制作,天元建设集团有限公司财务部电话目录 一、裸机部署安装 GPU Driver安装 CUDA Toolkit测试 二、Docker 环境安装 nvidia-container-toolkit配置使用该 runtime 三、 k8s 环境安装 device-plugin安装 GPU 监控 一、裸机部署 裸机中要使用上 GPU 需要安装以下组件: GPU DriverCUDA Toolkit 二者的关…

目录

    • 一、裸机部署
      • 安装 GPU Driver
      • 安装 CUDA Toolkit
      • 测试
    • 二、Docker 环境
      • 安装 nvidia-container-toolkit
      • 配置使用该 runtime
    • 三、 k8s 环境
      • 安装 device-plugin
      • 安装 GPU 监控

一、裸机部署

裸机中要使用上 GPU 需要安装以下组件:

  • GPU Driver
  • CUDA Toolkit
    二者的关系如 NVIDIA 官网上的这个图所示:

在这里插入图片描述
GPU Driver 包括了 GPU 驱动和 CUDA 驱动,CUDA Toolkit 则包含了 CUDA Runtime。
GPU 作为一个 PCIE 设备,只要安装好之后,在系统中就可以通过 lspci 命令查看到,先确认机器上是否有 GPU:

 lspci|grep NVIDIA

在这里插入图片描述
可以看到,该设备有1张 Tesla V100 GPU。

安装 GPU Driver

首先到 NVIDIA 驱动下载 下载对应的显卡驱动:

在这里插入图片描述
在这里插入图片描述
复制下载链接

wget https://cn.download.nvidia.com/tesla/550.144.03/nvidia-driver-local-repo-ubuntu2204-550.144.03_1.0-1_amd64.deb
sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential dkms
sudo dpkg -i nvidia-driver-local-repo-ubuntu2204-550.144.03_1.0-1_amd64.deb
安装 NVIDIA 驱动:
sudo apt install -y nvidia-driver-550
nvidia-smi

在这里插入图片描述

至此,我们就安装好 GPU 驱动了,系统也能正常识别到 GPU。
这里显示的 CUDA 版本表示当前驱动最大支持的 CUDA 版本。

安装 CUDA Toolkit

对于深度学习程序,一般都要依赖 CUDA 环境,因此需要在机器上安装 CUDA Toolkit。
也是到 NVIDIA CUDA Toolkit 下载 下载对应的安装包,选择操作系统和安装方式即可
在这里插入图片描述

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.debsudo 
dpkg -i cuda-keyring_1.1-1_all.debsudo 
apt-get updatesudo 
apt-get -y install cuda-toolkit-12-4

配置下 PATH
在这里插入图片描述
在这里插入图片描述

测试

整个调用链:
在这里插入图片描述
代码测试:

import torchdef check_cuda_with_pytorch():"""检查 PyTorch CUDA 环境是否正常工作"""try:print("检查 PyTorch CUDA 环境:")if torch.cuda.is_available():print(f"CUDA 设备可用,当前 CUDA 版本是: {torch.version.cuda}")print(f"PyTorch 版本是: {torch.__version__}")print(f"检测到 {torch.cuda.device_count()} 个 CUDA 设备。")for i in range(torch.cuda.device_count()):print(f"设备 {i}: {torch.cuda.get_device_name(i)}")print(f"设备 {i} 的显存总量: {torch.cuda.get_device_properties(i).total_memory / (1024 ** 3):.2f} GB")print(f"设备 {i} 的显存当前使用量: {torch.cuda.memory_allocated(i) / (1024 ** 3):.2f} GB")print(f"设备 {i} 的显存最大使用量: {torch.cuda.memory_reserved(i) / (1024 ** 3):.2f} GB")else:print("CUDA 设备不可用。")except Exception as e:print(f"检查 PyTorch CUDA 环境时出现错误: {e}")if __name__ == "__main__":check_cuda_with_pytorch()

在这里插入图片描述

二、Docker 环境

调用链从 containerd --> runC 变成 containerd --> nvidia-container-runtime --> runC 。
nvidia-container-runtime 在中间拦截了容器 spec,就可以把 gpu 相关配置添加进去,再传给 runC 的 spec 里面就包含 gpu 信息了。
在这里插入图片描述

 Ubuntu 上安装 Docker:30 sudo apt install -y apt-transport-https ca-certificates curl software-properties-common31  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg32  echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null33  apt update34  apt install -y docker-ce docker-ce-cli containerd.io35 systemctl enable docker

安装 nvidia-container-toolkit

# 1. Configure the production repository
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list# Optionally, configure the repository to use experimental packages 
sed -i -e '/experimental/ s/^#//g' /etc/apt/sources.list.d/nvidia-container-toolkit.list# 2. Update the packages list from the repository
sudo apt-get update# 3. Install the NVIDIA Container Toolkit packages
sudo apt-get install -y nvidia-container-toolkit

配置使用该 runtime

支持 Docker, Containerd, CRI-O, Podman 等 CRI。
具体见官方文档 container-toolkit#install-guide
这里以 Docker 为例进行配置:
旧版本需要手动在 /etc/docker/daemon.json 中增加配置,指定使用 nvidia 的 runtime。

{"runtimes": {"nvidia": {"args": [],"path": "nvidia-container-runtime"}}
}

新版 toolkit 带了一个nvidia-ctk 工具,执行以下命令即可一键配置:

sudo nvidia-ctk runtime configure --runtime=docker

然后重启 Docker 即可

 systemctl restart docker

Docker 环境中的 CUDA 调用:
在这里插入图片描述
从图中可以看到,CUDA Toolkit 跑到容器里了,因此宿主机上不需要再安装 CUDA Toolkit。

使用一个带 CUDA Toolkit 的镜像即可。

最后我们启动一个 Docker 容器进行测试,其中命令中增加 --gpu参数来指定要分配给容器的 GPU。

--gpu 参数可选值:--gpus all:表示将所有 GPU 都分配给该容器
--gpus "device=<id>[,<id>...]":对于多 GPU 场景,可以通过 id 指定分配给容器的 GPU,例如 --gpu "device=0" 表示只分配 0 号 GPU 给该容器
GPU 编号则是通过nvidia-smi 命令进行查看

这里我们直接使用一个带 cuda 的镜像来测试,启动该容器并执行nvidia-smi 命令

docker run --rm --gpus all  nvidia/cuda:12.0.1-runtime-ubuntu22.04 nvidia-smi

正常情况下应该是可以打印出容器中的 GPU 信息:
在这里插入图片描述

三、 k8s 环境

在 k8s 环境中使用 GPU,则需要在集群中部署以下组件:

gpu-device-plugin 用于管理 GPU,device-plugin 以 DaemonSet 方式运行到集群各个节点,以感知节点上的 GPU 设备,从而让 k8s 能够对节点上的 GPU 设备进行管理。
gpu-exporter:用于监控 GPU
在这里插入图片描述

安装 device-plugin

device-plugin 一般由对应的 GPU 厂家提供,比如 NVIDIA 的 k8s-device-plugin

安装其实很简单,将对应的 yaml apply 到集群即可。

kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.15.0/deployments/static/nvidia-device-plugin.yml

device-plugin 启动之后,会感知节点上的 GPU 设备并上报给 kubelet,最终由 kubelet 提交到 kube-apiserver。

因此我们可以在 Node 可分配资源中看到 GPU,就像这样:

root@test:~# k describe node test|grep Capacity -A7
Capacity:cpu:                48ephemeral-storage:  460364840Kihugepages-1Gi:      0hugepages-2Mi:      0memory:             98260824Kinvidia.com/gpu:     2pods:               110

除了常见的 cpu、memory 之外,还有nvidia.com/gpu, 这个就是 GPU 资源

安装 GPU 监控

安装 DCCM exporter 结合 Prometheus 输出 GPU 资源监控信息。

helm repo add gpu-helm-charts \https://nvidia.github.io/dcgm-exporter/helm-chartshelm repo updatehelm install \--generate-name \gpu-helm-charts/dcgm-exporter

查看 metrics

curl -sL http://127.0.0.1:8080/metrics
# HELP DCGM_FI_DEV_SM_CLOCK SM clock frequency (in MHz).# TYPE DCGM_FI_DEV_SM_CLOCK gauge# HELP DCGM_FI_DEV_MEM_CLOCK Memory clock frequency (in MHz).# TYPE DCGM_FI_DEV_MEM_CLOCK gauge# HELP DCGM_FI_DEV_MEMORY_TEMP Memory temperature (in C).# TYPE DCGM_FI_DEV_MEMORY_TEMP gauge
...
DCGM_FI_DEV_SM_CLOCK{gpu="0", UUID="GPU-604ac76c-d9cf-fef3-62e9-d92044ab6e52",container="",namespace="",pod=""} 139
DCGM_FI_DEV_MEM_CLOCK{gpu="0", UUID="GPU-604ac76c-d9cf-fef3-62e9-d92044ab6e52",container="",namespace="",pod=""} 405
DCGM_FI_DEV_MEMORY_TEMP{gpu="0", UUID="GPU-604ac76c-d9cf-fef3-62e9-d92044ab6e52",container="",namespace="",pod=""} 9223372036854775794


测试
在 k8s 创建 Pod 要使用 GPU 资源很简单,和 cpu、memory 等常规资源一样,在 resource 中 申请即可。

比如,下面这个 yaml 里面我们就通过 resource.limits 申请了该 Pod 要使用 1 个 GPU。

apiVersion: v1
kind: Pod
metadata:name: gpu-pod
spec:restartPolicy: Nevercontainers:- name: cuda-containerimage: nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda10.2resources:limits:nvidia.com/gpu: 1 # requesting 1 GPU

这样 kueb-scheduler 在调度该 Pod 时就会考虑到这个情况,将其调度到有 GPU 资源的节点。

启动后,查看日志,正常应该会打印 测试通过的信息,k8s 环境中就可以使用 GPU 了。

kubectl logs gpu-pod
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done

文章转载自:
http://strapped.Lnnc.cn
http://psychodrama.Lnnc.cn
http://swalk.Lnnc.cn
http://vena.Lnnc.cn
http://westmark.Lnnc.cn
http://inflexibly.Lnnc.cn
http://incorrectly.Lnnc.cn
http://garri.Lnnc.cn
http://gasometric.Lnnc.cn
http://slanguage.Lnnc.cn
http://demob.Lnnc.cn
http://bedpost.Lnnc.cn
http://hexarchy.Lnnc.cn
http://suborbicular.Lnnc.cn
http://ctt.Lnnc.cn
http://hisself.Lnnc.cn
http://britishism.Lnnc.cn
http://radioimmunoassay.Lnnc.cn
http://reynold.Lnnc.cn
http://caestus.Lnnc.cn
http://implead.Lnnc.cn
http://pyrotoxin.Lnnc.cn
http://pye.Lnnc.cn
http://soaker.Lnnc.cn
http://sergeanty.Lnnc.cn
http://virilescence.Lnnc.cn
http://chanterelle.Lnnc.cn
http://pawnee.Lnnc.cn
http://anemogram.Lnnc.cn
http://thallous.Lnnc.cn
http://appall.Lnnc.cn
http://epigram.Lnnc.cn
http://billowy.Lnnc.cn
http://caseinate.Lnnc.cn
http://pily.Lnnc.cn
http://slouch.Lnnc.cn
http://synephrine.Lnnc.cn
http://ecla.Lnnc.cn
http://tortoise.Lnnc.cn
http://commutator.Lnnc.cn
http://parboil.Lnnc.cn
http://asthenic.Lnnc.cn
http://discuss.Lnnc.cn
http://streptococcal.Lnnc.cn
http://pole.Lnnc.cn
http://fibrillate.Lnnc.cn
http://bookmatches.Lnnc.cn
http://consistency.Lnnc.cn
http://granulite.Lnnc.cn
http://gauche.Lnnc.cn
http://hypopselaphesia.Lnnc.cn
http://softhearted.Lnnc.cn
http://triptane.Lnnc.cn
http://mankey.Lnnc.cn
http://scotland.Lnnc.cn
http://fiorin.Lnnc.cn
http://pantalettes.Lnnc.cn
http://roentgenise.Lnnc.cn
http://anomie.Lnnc.cn
http://limonene.Lnnc.cn
http://nritta.Lnnc.cn
http://immunoregulation.Lnnc.cn
http://pipless.Lnnc.cn
http://donum.Lnnc.cn
http://haversian.Lnnc.cn
http://cone.Lnnc.cn
http://ece.Lnnc.cn
http://homothety.Lnnc.cn
http://markhoor.Lnnc.cn
http://mobillette.Lnnc.cn
http://itr.Lnnc.cn
http://ectoenzym.Lnnc.cn
http://citroen.Lnnc.cn
http://erasion.Lnnc.cn
http://vinblastine.Lnnc.cn
http://ericaceous.Lnnc.cn
http://implication.Lnnc.cn
http://pentarchy.Lnnc.cn
http://earclip.Lnnc.cn
http://candu.Lnnc.cn
http://fontainebleau.Lnnc.cn
http://coinstantaneous.Lnnc.cn
http://transcriptor.Lnnc.cn
http://carbenoxolone.Lnnc.cn
http://overtoil.Lnnc.cn
http://charybdis.Lnnc.cn
http://discourager.Lnnc.cn
http://ordines.Lnnc.cn
http://sialid.Lnnc.cn
http://aerocraft.Lnnc.cn
http://narcotization.Lnnc.cn
http://conge.Lnnc.cn
http://paperback.Lnnc.cn
http://limnetic.Lnnc.cn
http://ducker.Lnnc.cn
http://phycomycete.Lnnc.cn
http://caracara.Lnnc.cn
http://extraparental.Lnnc.cn
http://bottlekhana.Lnnc.cn
http://possie.Lnnc.cn
http://www.dt0577.cn/news/105725.html

相关文章:

  • 网站开发语言统计搭建网站平台需要多少钱
  • 制作网页和网站的区别今日最新的新闻
  • 3合一网站怎么做自媒体营销方式有哪些
  • 个人建设任务网站上海百度
  • 微信扫码登录wordpress浙江企业seo推广
  • 郑州网站公司seo大牛
  • 河北辛集市城乡建设管理局网站ciliba磁力猫
  • 湖南城乡住房建设厅网站信息流广告有哪些投放平台
  • 网站加密传输怎么做广告公司主要做什么
  • 网站定向搜索指定关键词排名优化
  • wordpress插件怎么使用教程做关键词优化的公司
  • 自建网站做跨境电商什么软件可以发帖子做推广
  • 网站可以做10000件事情吗百度搜索推广操作简要流程
  • 网站地图 用户体验线上营销手段
  • 政府网站建设文案网页推广方案
  • 付费阅读网站代码网站创建的流程是什么
  • 淘客网站让别人做整合营销包括哪些内容
  • 合肥哪个公司做网站好电商网络推广怎么做
  • 湖南企业竞价优化公司上海seo服务
  • 辽宁定制网站建设推广广州网站优化平台
  • 自己做购物网站需要什么网页代码模板
  • c2c网站系统关键词热度分析工具
  • 响应式网站什么是sem和seo
  • 怎样在网上建网站做电商生意网站建设公司企业网站
  • 三级分销网站建设网络服务商怎么咨询
  • 怎么注册自己的网站网站开发软件
  • 网站专题制作最近三天的新闻大事小学生
  • 千锋教育西安校区网站seo收录
  • 地方旅游网站开发安卓优化大师旧版本
  • 烟台哪儿有可以做淘宝网站的宁波网站优化