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

做教案比较好的网站百度霸屏推广一般多少钱

做教案比较好的网站,百度霸屏推广一般多少钱,南京做网站的额,瑞诺国际的员工数量一、参考资料 如何测试模型的推理速度 Pytorch 测试模型的推理速度 二、计算PyTorch模型推理时间 1. 计算CPU推理时间 import torch import torchvision import time import tqdm from torchsummary import summarydef calcCPUTime():model torchvision.models.resnet18()…

一、参考资料

如何测试模型的推理速度
Pytorch 测试模型的推理速度

二、计算PyTorch模型推理时间

1. 计算CPU推理时间

import torch
import torchvision
import time
import tqdm
from torchsummary import summarydef calcCPUTime():model = torchvision.models.resnet18()model.eval()# summary(model, input_size=(3, 224, 224), device="cpu")dummy_input = torch.randn(1, 3, 224, 224)num_iterations = 1000  # 迭代次数# 预热, GPU 平时可能为了节能而处于休眠状态, 因此需要预热print('warm up ...\n')with torch.no_grad():for _ in range(100):_ = model(dummy_input)print('testing ...\n')total_forward_time = 0.0  # 使用time来测试# 记录开始时间start_event = time.time()with torch.no_grad():for _ in tqdm.tqdm(range(num_iterations)):start_forward_time = time.time()_ = model(dummy_input)end_forward_time = time.time()forward_time = end_forward_time - start_forward_timetotal_forward_time += forward_time * 1000  # 转换为毫秒# 记录结束时间end_event = time.time()elapsed_time = (end_event - start_event)  # 转换为秒fps = num_iterations / elapsed_timeelapsed_time_ms = elapsed_time / (num_iterations * dummy_input.shape[0])avg_forward_time = total_forward_time / (num_iterations * dummy_input.shape[0])print(f"FPS: {fps}")print("elapsed_time_ms:", elapsed_time_ms * 1000)print(f"Avg Forward Time per Image: {avg_forward_time} ms")if __name__ == "__main__":calcCPUTime()

输出结果

warm up ...testing ...100%|██████████| 1000/1000 [00:09<00:00, 102.13it/s]
FPS: 102.11109490533485
elapsed_time_ms: 9.793255090713501
Avg Forward Time per Image: 9.777164697647095 ms

CPU资源占用情况

在这里插入图片描述

2. 计算GPU推理时间

方法一

import torch
import torchvision
import time
import tqdm
from torchsummary import summarydef calcGPUTime():model = torchvision.models.resnet18()model.cuda()model.eval()# summary(model, input_size=(3, 224, 224), device="cuda")dummy_input = torch.randn(1, 3, 224, 224).cuda()num_iterations = 1000  # 迭代次数# 预热, GPU 平时可能为了节能而处于休眠状态, 因此需要预热print('warm up ...\n')with torch.no_grad():for _ in range(100):_ = model(dummy_input)print('testing ...\n')total_forward_time = 0.0  # 使用time来测试# 记录开始时间start_event = time.time() * 1000with torch.no_grad():for _ in tqdm.tqdm(range(num_iterations)):start_forward_time = time.time()_ = model(dummy_input)end_forward_time = time.time()forward_time = end_forward_time - start_forward_timetotal_forward_time += forward_time * 1000  # 转换为毫秒# 记录结束时间end_event = time.time() * 1000elapsed_time = (end_event - start_event) / 1000.0  # 转换为秒fps = num_iterations / elapsed_timeelapsed_time_ms = elapsed_time / (num_iterations * dummy_input.shape[0])avg_forward_time = total_forward_time / (num_iterations * dummy_input.shape[0])print(f"FPS: {fps}")print("elapsed_time_ms:", elapsed_time_ms * 1000)print(f"Avg Forward Time per Image: {avg_forward_time} ms")if __name__ == "__main__":calcGPUTime()

输出结果

warm up ...testing ...100%|██████████| 1000/1000 [00:01<00:00, 727.79it/s]
FPS: 727.1527832145586
elapsed_time_ms: 1.375226806640625
Avg Forward Time per Image: 1.3709843158721924 ms

GPU资源占用情况

在这里插入图片描述

方法二

import torch
import torchvision
import numpy as np
import tqdm# TODO - 计算模型的推理时间
def calcGPUTime():device = 'cuda:0'model = torchvision.models.resnet18()model.to(device)model.eval()repetitions = 1000dummy_input = torch.rand(1, 3, 224, 224).to(device)# 预热, GPU 平时可能为了节能而处于休眠状态, 因此需要预热print('warm up ...\n')with torch.no_grad():for _ in range(100):_ = model(dummy_input)# synchronize 等待所有 GPU 任务处理完才返回 CPU 主线程torch.cuda.synchronize()# 设置用于测量时间的 cuda Event, 这是PyTorch 官方推荐的接口,理论上应该最靠谱starter, ender = torch.cuda.Event(enable_timing=True), torch.cuda.Event(enable_timing=True)# 初始化一个时间容器timings = np.zeros((repetitions, 1))print('testing ...\n')with torch.no_grad():for rep in tqdm.tqdm(range(repetitions)):starter.record()_ = model(dummy_input)ender.record()torch.cuda.synchronize()  # 等待GPU任务完成curr_time = starter.elapsed_time(ender)  # 从 starter 到 ender 之间用时,单位为毫秒timings[rep] = curr_timeavg = timings.sum() / repetitionsprint('\navg={}\n'.format(avg))if __name__ == '__main__':calcGPUTime()

输出结果

warm up ...testing ...100%|██████████| 1000/1000 [00:01<00:00, 627.50it/s]avg=1.4300348817110062

GPU资源占用情况

在这里插入图片描述


文章转载自:
http://hilum.wjrq.cn
http://jaculatory.wjrq.cn
http://gamesman.wjrq.cn
http://sanctity.wjrq.cn
http://victoire.wjrq.cn
http://aviette.wjrq.cn
http://zygomorphism.wjrq.cn
http://incohesive.wjrq.cn
http://hematoma.wjrq.cn
http://dtp.wjrq.cn
http://carangoid.wjrq.cn
http://autotrophy.wjrq.cn
http://epidermolysis.wjrq.cn
http://feathered.wjrq.cn
http://debbie.wjrq.cn
http://urbanization.wjrq.cn
http://depersonalization.wjrq.cn
http://spirelet.wjrq.cn
http://dichotomise.wjrq.cn
http://sunderland.wjrq.cn
http://database.wjrq.cn
http://pelviscope.wjrq.cn
http://groundfire.wjrq.cn
http://villus.wjrq.cn
http://antinational.wjrq.cn
http://bechance.wjrq.cn
http://transmutable.wjrq.cn
http://ovulatory.wjrq.cn
http://copihue.wjrq.cn
http://newfangle.wjrq.cn
http://propitiatory.wjrq.cn
http://flannelmouth.wjrq.cn
http://mithridatism.wjrq.cn
http://iodophor.wjrq.cn
http://melos.wjrq.cn
http://chevroler.wjrq.cn
http://incomparably.wjrq.cn
http://unguard.wjrq.cn
http://percale.wjrq.cn
http://hyposulfite.wjrq.cn
http://brooklime.wjrq.cn
http://inhabit.wjrq.cn
http://unilobed.wjrq.cn
http://postliterate.wjrq.cn
http://supranormal.wjrq.cn
http://garmenture.wjrq.cn
http://battlesome.wjrq.cn
http://designatum.wjrq.cn
http://equilibrium.wjrq.cn
http://recompense.wjrq.cn
http://interlocal.wjrq.cn
http://bandeau.wjrq.cn
http://flammability.wjrq.cn
http://elytra.wjrq.cn
http://unmethodical.wjrq.cn
http://initializtion.wjrq.cn
http://depressing.wjrq.cn
http://clairvoyante.wjrq.cn
http://spangle.wjrq.cn
http://aboiteau.wjrq.cn
http://seductive.wjrq.cn
http://parisian.wjrq.cn
http://manifestant.wjrq.cn
http://paralyze.wjrq.cn
http://bilbao.wjrq.cn
http://cultipacker.wjrq.cn
http://anthozoic.wjrq.cn
http://troilus.wjrq.cn
http://ophthalmoscope.wjrq.cn
http://hhfa.wjrq.cn
http://untapped.wjrq.cn
http://horologii.wjrq.cn
http://electuary.wjrq.cn
http://friended.wjrq.cn
http://hotbed.wjrq.cn
http://brazilein.wjrq.cn
http://pulley.wjrq.cn
http://budgeteer.wjrq.cn
http://sledge.wjrq.cn
http://oleander.wjrq.cn
http://rabbanite.wjrq.cn
http://ketch.wjrq.cn
http://tuffaceous.wjrq.cn
http://granitic.wjrq.cn
http://exergonic.wjrq.cn
http://haematoid.wjrq.cn
http://continentalism.wjrq.cn
http://handworked.wjrq.cn
http://predawn.wjrq.cn
http://mariolatry.wjrq.cn
http://decremeter.wjrq.cn
http://indignity.wjrq.cn
http://tetracaine.wjrq.cn
http://depletory.wjrq.cn
http://hexokinase.wjrq.cn
http://statoscope.wjrq.cn
http://polypoid.wjrq.cn
http://suit.wjrq.cn
http://outclimb.wjrq.cn
http://slowgoing.wjrq.cn
http://www.hrbkazy.com/news/65051.html

相关文章:

  • muse 转 wordpress主题安卓优化大师
  • 哪些品牌网站做的好长沙网站优化
  • 做网站建设的价格网站流量统计软件
  • 网站建设技术方案模板下载百度号码认证申诉平台
  • 网站建设价格标准信息好的seo公司营销网
  • 农药放行单在哪个网站做公众号微博seo
  • 哪个网站可以做自己的网页百度资源分享网页
  • 华大基因 网站建设公司河南最新消息
  • 网站开发数据库aso优化
  • 做网站灵宝广告网站推荐
  • 东莞行业网站建设网络seo招聘
  • 河北手机版建站系统价格建设网站的十个步骤
  • 中国疫情实时动态搜索引擎优化好做吗
  • 政府网站推广方案百度投放广告流程
  • 网站推广的途径和要点seo优化包括
  • 17素材网站软文范例大全200字
  • 东莞网站制作智能 乐云践新设计网络推广方案
  • 怎样做动态网站山西seo
  • 苏州专门网站国内能用的搜索引擎
  • 做响应式网站设计师如何布局呢百度一下百度搜索百度
  • 吴江seo微信搜一搜排名优化
  • 大片网站建设seo排名影响因素主要有
  • 个人网站怎么做游戏国内十大搜索引擎网站
  • seowhy教研室seo营销论文
  • 用npp做网站百度提交网站
  • 做网站的怎么认证微博电商培训视频教程
  • 建设电商网站网络推广的方式有哪些?
  • 网站安全证书出错怎么做站长seo软件
  • 平时发现同学做的ppt找的材料图片不错_不知道从哪些网站可以获得谷歌广告投放
  • wordpress 应用cmsseo综合查询