1 PyTorch教程6.7之显卡-德赢Vwin官网 网
×

PyTorch教程6.7之显卡

消耗积分:0 | 格式:pdf | 大小:0.20 MB | 2023-06-05

李鑫

分享资料个

表 1.5.1中,我们讨论了过去二十年计算的快速增长。简而言之,自 2000 年以来,GPU 性能每十年增加 1000 倍。这提供了巨大的机会,但也表明提供这种性能的巨大需求。

在本节中,我们将开始讨论如何在您的研究中利用这种计算性能。首先是使用单个 GPU,然后是如何使用多个 GPU 和多个服务器(具有多个 GPU)。

具体来说,我们将讨论如何使用单个 NVIDIA GPU 进行计算。首先,确保您至少安装了一个 NVIDIA GPU。然后,下载NVIDIA驱动和CUDA,根据提示设置合适的路径。这些准备工作完成后,nvidia-smi就可以通过命令查看显卡信息了。

!nvidia-smi
Fri Feb 10 06:11:13 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.106.00  Driver Version: 460.106.00  CUDA Version: 11.2   |
|-------------------------------+----------------------+----------------------+
| GPU Name    Persistence-M| Bus-Id    Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap|     Memory-Usage | GPU-Util Compute M. |
|                |           |        MIG M. |
|===============================+======================+======================|
|  0 Tesla V100-SXM2... Off | 00000000:00:17.0 Off |          0 |
| N/A  35C  P0  76W / 300W |  1534MiB / 16160MiB |   53%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  1 Tesla V100-SXM2... Off | 00000000:00:18.0 Off |          0 |
| N/A  34C  P0  42W / 300W |   0MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  2 Tesla V100-SXM2... Off | 00000000:00:19.0 Off |          0 |
| N/A  36C  P0  80W / 300W |  3308MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  3 Tesla V100-SXM2... Off | 00000000:00:1A.0 Off |          0 |
| N/A  35C  P0  200W / 300W |  3396MiB / 16160MiB |   4%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  4 Tesla V100-SXM2... Off | 00000000:00:1B.0 Off |          0 |
| N/A  32C  P0  56W / 300W |  1126MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  5 Tesla V100-SXM2... Off | 00000000:00:1C.0 Off |          0 |
| N/A  40C  P0  84W / 300W |  1522MiB / 16160MiB |   47%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  6 Tesla V100-SXM2... Off | 00000000:00:1D.0 Off |          0 |
| N/A  34C  P0  57W / 300W |  768MiB / 16160MiB |   3%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  7 Tesla V100-SXM2... Off | 00000000:00:1E.0 Off |          0 |
| N/A  32C  P0  41W / 300W |   0MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                 |
| GPU  GI  CI    PID  Type  Process name         GPU Memory |
|    ID  ID                          Usage   |
|=============================================================================|
|  0  N/A N/A   18049   C  ...l-en-release-1/bin/python   1531MiB |
|  2  N/A N/A   41102   C  ...l-en-release-1/bin/python   3305MiB |
|  3  N/A N/A   41102   C  ...l-en-release-1/bin/python   3393MiB |
|  4  N/A N/A   44560   C  ...l-en-release-1/bin/python   1123MiB |
|  5  N/A N/A   18049   C  ...l-en-release-1/bin/python   1519MiB |
|  6  N/A N/A   44560   C  ...l-en-release-1/bin/python   771MiB |
+-----------------------------------------------------------------------------+

在 PyTorch 中,每个数组都有一个设备,我们通常将其称为上下文。到目前为止,默认情况下,所有变量和相关计算都已分配给 CPU。通常,其他上下文可能是各种 GPU。当我们跨多个服务器部署作业时,事情会变得更加棘手。通过智能地将数组分配给上下文,我们可以最大限度地减少设备之间传输数据所花费的时间。例如,在带有 GPU 的服务器上训练神经网络时,我们通常更希望模型的参数存在于 GPU 上。

!nvidia-smi
Fri Feb 10 08:10:21 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.106.00  Driver Version: 460.106.00  CUDA Version: 11.2   |
|-------------------------------+----------------------+----------------------+
| GPU Name    Persistence-M| Bus-Id    Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap|     Memory-Usage | GPU-Util Compute M. |
|                |           |        MIG M. |
|===============================+======================+======================|
|  0 Tesla V100-SXM2... Off | 00000000:00:17.0 Off |          0 |
| N/A  36C  P0  56W / 300W |  1996MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  1 Tesla V100-SXM2... Off | 00000000:00:18.0 Off |          0 |
| N/A  44C  P0  59W / 300W |  2000MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  2 Tesla V100-SXM2... Off | 00000000:00:19.0 Off |          0 |
| N/A  46C  P0  59W / 300W |  1810MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  3 Tesla V100-SXM2... Off | 00000000:00:1A.0 Off |          0 |
| N/A  43C  P0  58W / 300W |   0MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  4 Tesla V100-SXM2... Off | 00000000:00:1B.0 Off |          0 |
| N/A  37C  P0  57W / 300W |  1834MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  5 Tesla V100-SXM2... Off | 00000000:00:1C.0 Off |          0 |
| N/A  49C  P0  60W / 300W |   0MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  6 Tesla V100-SXM2... Off | 00000000:00:1D.0 Off |          0 |
| N/A  44C  P0  59W / 300W |  1842MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+
|  7 Tesla V100-SXM2... Off | 00000000:00:1E.0 Off |          0 |
| N/A  37C  P0  57W / 300W |  1806MiB / 16160MiB |   0%   Default |
|                |           |         N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                 |
| GPU  GI  CI    PID  Type  Process name         GPU Memory |
|    ID  ID                          Usage   |
|=============================================================================|
|  0  N/A N/A   67249   C  ...l-en-release-1/bin/python   1993MiB |
|  1  N/A N/A   67249   C  ...l-en-release-1/bin/python   1997MiB |
|  2  N/A N/A   28134   C  ...l-en-release-1/bin/python   1807MiB |
|  4  N/A N/A   75456   C  ...l-en-release-1/bin/python   1831MiB |
|  6  N/A N/A   75456   C  ...l-en-release-

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表德赢Vwin官网 网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !

'+ '

'+ '

'+ ''+ '
'+ ''+ ''+ '
'+ ''+ '' ); $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code ==5){ $(pop_this).attr('href',"//www.hzfubeitong.com/m/login/index.html"); return false } if(data.code == 2){ //跳转到VIP升级页面 window.location.href="https://m.elecfans.com/vip/index?aid=" + webid return false } //是会员 if (data.code > 0) { $('body').append(htmlSetNormalDownload); var getWidth=$("#poplayer").width(); $("#poplayer").css("margin-left","-"+getWidth/2+"px"); $('#tips').html(data.msg) $('.download_confirm').click(function(){ $('#dialog').remove(); }) } else { var down_url = $('#vipdownload').attr('data-url'); isBindAnalysisForm(pop_this, down_url, 1) } }); }); //是否开通VIP $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code == 2 || data.code ==5){ //跳转到VIP升级页面 $('#vipdownload>span').text("开通VIP 免费下载") return false }else{ // 待续费 if(data.code == 3) { vipExpiredInfo.ifVipExpired = true vipExpiredInfo.vipExpiredDate = data.data.endoftime } $('#vipdownload .icon-vip-tips').remove() $('#vipdownload>span').text("VIP免积分下载") } }); }).on("click",".download_cancel",function(){ $('#dialog').remove(); }) var setWeixinShare={};//定义默认的微信分享信息,页面如果要自定义分享,直接更改此变量即可 if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'){ var d={ title:'PyTorch教程6.7之显卡',//标题 desc:$('[name=description]').attr("content"), //描述 imgUrl:'https://'+location.host+'/static/images/ele-logo.png',// 分享图标,默认是logo link:'',//链接 type:'',// 分享类型,music、video或link,不填默认为link dataUrl:'',//如果type是music或video,则要提供数据链接,默认为空 success:'', // 用户确认分享后执行的回调函数 cancel:''// 用户取消分享后执行的回调函数 } setWeixinShare=$.extend(d,setWeixinShare); $.ajax({ url:"//www.hzfubeitong.com/app/wechat/index.php?s=Home/ShareConfig/index", data:"share_url="+encodeURIComponent(location.href)+"&format=jsonp&domain=m", type:'get', dataType:'jsonp', success:function(res){ if(res.status!="successed"){ return false; } $.getScript('https://res.wx.qq.com/open/js/jweixin-1.0.0.js',function(result,status){ if(status!="success"){ return false; } var getWxCfg=res.data; wx.config({ //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId:getWxCfg.appId, // 必填,公众号的唯一标识 timestamp:getWxCfg.timestamp, // 必填,生成签名的时间戳 nonceStr:getWxCfg.nonceStr, // 必填,生成签名的随机串 signature:getWxCfg.signature,// 必填,签名,见附录1 jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function(){ //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 wx.onMenuShareTimeline({ title: setWeixinShare.title, // 分享标题 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享给朋友”按钮点击状态及自定义分享内容接口 wx.onMenuShareAppMessage({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 type: setWeixinShare.type, // 分享类型,music、video或link,不填默认为link dataUrl: setWeixinShare.dataUrl, // 如果type是music或video,则要提供数据链接,默认为空 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ”按钮点击状态及自定义分享内容接口 wx.onMenuShareQQ({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 wx.onMenuShareWeibo({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 wx.onMenuShareQZone({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); }); }); } }); } function openX_ad(posterid, htmlid, width, height) { if ($(htmlid).length > 0) { var randomnumber = Math.random(); var now_url = encodeURIComponent(window.location.href); var ga = document.createElement('iframe'); ga.src = 'https://www1.elecfans.com/www/delivery/myafr.php?target=_blank&cb=' + randomnumber + '&zoneid=' + posterid+'&prefer='+now_url; ga.width = width; ga.height = height; ga.frameBorder = 0; ga.scrolling = 'no'; var s = $(htmlid).append(ga); } } openX_ad(828, '#berry-300', 300, 250);