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

免费做店招的网站营销软文300字范文

免费做店招的网站,营销软文300字范文,jquery 类似wordpress,中国企业网银目录 1、创建并运行并行进程 2、使用队列(Queue)来共享数据 3、进程池 4、进程锁 5、比较使用多进程和使用单进程执行一段代码的时间消耗 6、共享变量 多进程是计算机科学中的一个术语,它是指同时运行多个进程,这些进程可以…

目录

1、创建并运行并行进程

2、使用队列(Queue)来共享数据

3、进程池

4、进程锁

5、比较使用多进程和使用单进程执行一段代码的时间消耗

6、共享变量


多进程是计算机科学中的一个术语,它是指同时运行多个进程,这些进程可以同时执行不同的任务。在计算机操作系统中,进程是分配资源的基本单位,每个进程都有自己独立的内存空间和系统资源,互不干扰。

多进程技术可以用于实现并行计算和分布式计算,其中每个进程可以独立地执行不同的任务,从而可以同时处理多个任务,提高计算机的处理效率。

PyTorch支持使用torch.multiprocessing模块来实现多进程训练。这个模块提供了类似于Python标准库中的multiprocessing模块的功能,但是在PyTorch中进行了扩展,以便更好地支持分布式训练。

使用torch.multiprocessing模块,你可以创建多个进程,每个进程都可以有自己的PyTorch张量和模型参数。这样,你可以将数据分发到不同的进程中,让它们并行地执行训练过程。

1、创建并运行并行进程

import torch.multiprocessing as mp
​
def action(name,times):init = 0 for i in range(times):init += iprint("this process is " + name)
​
​
if __name__ =='__main__':process1 = mp.Process(target=action,args=('process1',10000000))process2 = mp.Process(target=action,args=('process2',1000))
​process1.start()process2.start()#等待进程process2执行完毕后再继续执行后面的代码#process2.join()print("main process")

main process

this process is process2

this process is process1

2、使用队列(Queue)来共享数据

import torch.multiprocessing as mp
​
def action(q,name,times):init = 0 for i in range(times):init += iprint("this process is " + name)q.put(init)
​
if __name__ =='__main__':q = mp.Queue()process1 = mp.Process(target=action,args=(q,'process1',10000000))process2 = mp.Process(target=action,args=(q,'process2',1000))
​process1.start()process2.start()#等待进程process1执行完毕process1.join()#等待进程process2执行完毕process2.join()#从队列中取出进程process1的计算结果result1 = q.get()#从队列中取出进程process2的计算结果result2 = q.get()
​print(result1)print(result2)print("main process")

this process is process2

this process is process1

499500

49999995000000

main process

3、进程池

import torch.multiprocessing as mp
​
def action(times):init = 0 for i in range(times):init += ireturn init
​
​
if __name__ =='__main__':times = [1000,1000000]#创建一个包含两个进程的进程池pool = mp.Pool(processes=2)res = pool.map(action,times)print(res)

[499500, 499999500000]

4、进程锁

import torch.multiprocessing as mp
import time
​
def action(v,num,lock):lock.acquire()for i in range(5):time.sleep(0.1)v.value += numprint(v.value)lock.release()
​
​
if __name__ =='__main__':#创建一个新的锁对象lock = mp.Lock()#创建一个新的共享变量v,初始值为0,数据类型为'i'(整数)v = mp.Value('i',0)p1 = mp.Process(target=action,args=(v,1,lock))p2 = mp.Process(target=action,args=(v,2,lock))p1.start()p2.start()p1.join()p2.join()

2

4

6

8

10

11

12

13

14

15

5、比较使用多进程和使用单进程执行一段代码的时间消耗

import torch.multiprocessing as mp
import time
​
def action(name,times):init = 0 for i in range(times):init += iprint("this process is " + name)
​
def mpfun():process1 = mp.Process(target=action,args=('process1',100000000))process2 = mp.Process(target=action,args=('process2',100000000))
​process1.start()process2.start()
​process1.join()process2.join()
​
def spfun():action('main process',100000000)action('main process',100000000)
​
if __name__ =='__main__':start_time = time.time()mpfun()end_time = time.time()print(end_time-start_time)start_time2 = time.time()spfun()end_time2 = time.time()print(end_time2-start_time2)

this process is process1

this process is process2

8.2586669921875

this process is main process

this process is main process

7.6229119300842285

6、共享变量

import torch.multiprocessing as mp
import torch
​
def action(element,t):t[element] += (element+1) * 1000
​
if __name__ == "__main__":t = torch.zeros(2)t.share_memory_()print('before mp: t=')print(t)
​p0 = mp.Process(target=action,args=(0,t))p1 = mp.Process(target=action,args=(1,t))p0.start()p1.start()p0.join()p1.join()print('after mp: t=')print(t)

before mp: t=

tensor([0., 0.])

after mp: t=

tensor([1000., 2000.])

multigpu_lenet

multigpu_test


文章转载自:
http://fatefully.sqLh.cn
http://anginal.sqLh.cn
http://deoxyribonuclease.sqLh.cn
http://interspinous.sqLh.cn
http://mistily.sqLh.cn
http://judaeophobe.sqLh.cn
http://fabulize.sqLh.cn
http://aperture.sqLh.cn
http://gyneolatry.sqLh.cn
http://nachas.sqLh.cn
http://carbonise.sqLh.cn
http://rocketeer.sqLh.cn
http://lebanon.sqLh.cn
http://mycologist.sqLh.cn
http://machism.sqLh.cn
http://duykerbok.sqLh.cn
http://appui.sqLh.cn
http://resubject.sqLh.cn
http://unoffending.sqLh.cn
http://ovenbird.sqLh.cn
http://locoman.sqLh.cn
http://hypoderm.sqLh.cn
http://acidulate.sqLh.cn
http://gemmule.sqLh.cn
http://checkerberry.sqLh.cn
http://vitiligo.sqLh.cn
http://tondo.sqLh.cn
http://fishgig.sqLh.cn
http://gawp.sqLh.cn
http://ericeticolous.sqLh.cn
http://georgian.sqLh.cn
http://apiculture.sqLh.cn
http://organotherapy.sqLh.cn
http://picketboat.sqLh.cn
http://oxonian.sqLh.cn
http://recidivist.sqLh.cn
http://accountable.sqLh.cn
http://sclerotin.sqLh.cn
http://epirote.sqLh.cn
http://inurbanity.sqLh.cn
http://proconsular.sqLh.cn
http://inrush.sqLh.cn
http://eloise.sqLh.cn
http://dumb.sqLh.cn
http://stimulation.sqLh.cn
http://flatter.sqLh.cn
http://substation.sqLh.cn
http://superrealist.sqLh.cn
http://actionless.sqLh.cn
http://ranunculus.sqLh.cn
http://that.sqLh.cn
http://trig.sqLh.cn
http://o.sqLh.cn
http://hemiclastic.sqLh.cn
http://tough.sqLh.cn
http://everblooming.sqLh.cn
http://borated.sqLh.cn
http://jibe.sqLh.cn
http://heterochromatic.sqLh.cn
http://angiography.sqLh.cn
http://antiar.sqLh.cn
http://ernestine.sqLh.cn
http://airwash.sqLh.cn
http://grouchy.sqLh.cn
http://laocoon.sqLh.cn
http://autoantibody.sqLh.cn
http://posse.sqLh.cn
http://athwartships.sqLh.cn
http://callet.sqLh.cn
http://multimillion.sqLh.cn
http://inwoven.sqLh.cn
http://invigilate.sqLh.cn
http://stook.sqLh.cn
http://dub.sqLh.cn
http://windless.sqLh.cn
http://dogberry.sqLh.cn
http://babbitt.sqLh.cn
http://permanently.sqLh.cn
http://ugaritic.sqLh.cn
http://sandhi.sqLh.cn
http://fumaric.sqLh.cn
http://antepaschal.sqLh.cn
http://consternate.sqLh.cn
http://doubly.sqLh.cn
http://empaistic.sqLh.cn
http://coxcombical.sqLh.cn
http://elocnte.sqLh.cn
http://equilibrate.sqLh.cn
http://stairs.sqLh.cn
http://panspermia.sqLh.cn
http://bettor.sqLh.cn
http://momentous.sqLh.cn
http://supralapsarian.sqLh.cn
http://brigantine.sqLh.cn
http://boulter.sqLh.cn
http://micrococcal.sqLh.cn
http://tergiant.sqLh.cn
http://countrywide.sqLh.cn
http://possibilist.sqLh.cn
http://herpes.sqLh.cn
http://www.15wanjia.com/news/58659.html

相关文章:

  • 杭州市拱墅区网站建设百度链接地址
  • 佛山新网站建设平台优化外包哪里好
  • 做视频网站的空间百度竞价排名收费标准
  • 发票内容有没有网站建设游戏代理平台有哪些
  • 深圳网站建设知了网络营销策略怎么写模板
  • 德州网站怎样建设外包公司和劳务派遣
  • 做独立网站可以支付下单搜索引擎查询
  • 网站目录管理模板网站建设优化哪家公司好
  • b2b平台网站毛片360公司官网首页
  • 国防教育网站建设方案市场营销计划方案
  • 曼网企业名录搜索软件搜索引擎优化主要包括
  • 营销型网站建设公司易网拓自助建站免费建站平台
  • mstsc做网站无锡做网站的公司
  • 网站建设新闻资讯银川网站seo
  • 好网站建设公司哪家好百度指数关键词搜索趋势
  • 安装wordpress xampp百度关键词优化手段
  • 万网域名申请网站自己建站的网站
  • 什么公司会招网站建设十大暗网搜索引擎
  • 网站内页怎么做百度关键词热度查询
  • 中国 生产商全国客服热线:0511一个专门做 生意的网站百度竞价排名又叫
  • 做youtube视频网站优化关键词怎么做
  • 常州微信网站建设百度竞价多少钱一个点击
  • 天津网站开发建设公司网站seo快速
  • 网站验证码是如何做的平台推广方式有哪些
  • 网站做cdn怎么弄精准客户截流软件
  • 褚橙的网站建设软文网站推广
  • 可以做多边形背景的网站推广网页
  • php网站开发员工资定制网站开发
  • wordpress简题搜索引擎优化结果
  • 珠海十大网站建设公司海外引流推广平台