﻿{"id":4774,"date":"2020-12-19T19:42:39","date_gmt":"2020-12-19T11:42:39","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=4774"},"modified":"2020-12-19T19:42:39","modified_gmt":"2020-12-19T11:42:39","slug":"7-linux-gpu-jiankong","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/7-linux-gpu-jiankong.html","title":{"rendered":"7\u5927Linux GPU\u76d1\u63a7\u548c\u8bca\u65ad\u547d\u4ee4\u884c\u5de5\u5177"},"content":{"rendered":"<p>\u89c6\u9891\u5361\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7535\u8def\u677f\uff0c\u7528\u4e8e\u63a7\u5236\u8ba1\u7b97\u673a\u76d1\u89c6\u5668\u4e0a\u663e\u793a\u7684\u5185\u5bb9\u3002 \u5b83\u4e5f\u79f0\u4e3a\u56fe\u5f62\u5904\u7406\u5355\u5143\uff08GPU\uff09\uff0c\u53ef\u4e3aLinux\u6e38\u620f\u548c\u5176\u4ed6\u7528\u9014\u8ba1\u7b973D\u56fe\u50cf\u548c\u56fe\u5f62\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u89e3\u51b3\u95ee\u9898\u76847\u5927Linux GPU\u76d1\u89c6\u548c\u8bca\u65ad\u547d\u4ee4\u884c\u5de5\u5177\u3002<\/p>\n<p>\u4ee5\u4e0b\u5de5\u5177\u5728Linux\u4e0a\u53ef\u7528\u4e8eGPU\u76d1\u89c6\u548c\u8bca\u65ad\u76ee\u7684\uff0c\u4ee5\u53ca\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff08\u4f8b\u5982FreeBSD\uff09\u4e0a\u8fd0\u884c\u3002 \u5982\u4eca\uff0c\u5927\u591a\u6570Linux\u548cFreeBSD\u7528\u6237\u90fd\u4f7f\u7528Nvidia\uff0cIntel\u548cAMD GPU\u3002<\/p>\n<p><strong>Linux GPU\u76d1\u63a7\u548c\u8bca\u65ad\u547d\u4ee4\u884c\u5de5\u5177<\/strong><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u5de5\u5177\u6765\u76d1\u89c6\u3001\u8bca\u65ad\u548c\u68c0\u67e5\u57fa\u4e8eLinux\u6216*BSD\u7684\u7cfb\u7edf\u3002<\/p>\n<p>\u83b7\u5f97\u56fe\u5f62\u5904\u7406\u5668\u4fe1\u606f\u53ea\u9700\u8fd0\u884c:<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo lshw -C display -short<\/span><br \/>\n[sudo] linuxmi \u7684\u5bc6\u7801\uff1a<\/p>\n<p>\u8f93\u51fa\u5982\u4e0b:<\/p>\n<pre style=\"margin: 1.2em 0px; line-height: 1.2em; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 1em;\"><code style=\"background: #292824; margin: 0px 0.15em; padding: 0.5em; border-radius: 3px; border: 1px solid #cccccc; color: #a6a28c; overflow: auto; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; display: block !important; white-space: pre; -ms-overflow-x: auto; -moz-text-size-adjust: none;\">H\/W path                   Device      Class          Description\r\n=================================================================\r\n<span style=\"color: #d73737;\">\/0\/<\/span><span class=\"hljs-number\" style=\"color: #b65611;\">100<\/span>\/f                               display        SVGA II Adapter\r\n<\/code><\/pre>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$<span style=\"color: #ff0000;\"> lspci -v | more<\/span><\/p>\n<p>1\u3001glmark2 \u2013\u5728Linux\u4e0a\u5bf9GPU\u6027\u80fd\u8fdb\u884c\u538b\u529b\u6d4b\u8bd5<\/p>\n<p>glmark2\u662fOpenGL 2.0\u548cES 2.0\u57fa\u51c6\u547d\u4ee4\u884c\u5b9e\u7528\u7a0b\u5e8f\u3002 \u6211\u4eec\u53ef\u4ee5\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u5b83\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install glmark2<\/span><\/p>\n<p>\u73b0\u5728\uff0c\u5982\u4e0b\u8fd0\u884c\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">glmark2<\/span><\/p>\n<p>\u7136\u540e\u5b83\u5c06\u5f00\u59cb\u5982\u4e0b\u6d4b\u8bd5\uff0c\u5e76\u5c06\u5728Linux\u4e0a\u5bf9\u60a8\u7684GPU\u8fdb\u884c\u538b\u529b\u6d4b\u8bd5\uff1a<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4777\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/12\/glmark2.gif\" alt=\"\" width=\"841\" height=\"763\" \/><\/p>\n<p style=\"text-align: center;\">Linux glmark2\u6d4b\u8bd5\u5c4f\u5e55<\/p>\n<p>\u6211\u7684\u57fa\u51c6\u7ed3\u679c\uff0c\u8fd0\u884c\u5728Ubuntu Linux 20.04 LTS:<\/p>\n<pre style=\"margin: 1.2em 0px; line-height: 1.2em; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 1em;\"><code style=\"background: #292824; margin: 0px 0.15em; padding: 0.5em; border-radius: 3px; border: 1px solid #cccccc; color: #a6a28c; overflow: auto; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 0.85em; display: block !important; white-space: pre; -ms-overflow-x: auto; -moz-text-size-adjust: none;\">** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\r\n** Failed to set swap interval. Results may be bounded above by refresh rate.\r\n=======================================================\r\n    glmark2 <span style=\"color: #b65611;\">2014.03<\/span>+git20150611.fa71af2d\r\n=======================================================\r\n    OpenGL Information\r\n    GL_VENDOR:     Mesa\/X.org\r\n    GL_RENDERER:   llvmpipe (LLVM <span style=\"color: #b65611;\">11.0<\/span><span style=\"color: #b65611;\">.0<\/span>, <span style=\"color: #b65611;\">256<\/span> bits)\r\n    GL_VERSION:    <span style=\"color: #b65611;\">3.1<\/span> Mesa <span style=\"color: #b65611;\">20.2<\/span><span style=\"color: #b65611;\">.1<\/span>\r\n=======================================================\r\n** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\r\n** Failed to set swap interval. Results may be bounded above by refresh rate.\r\n[build] use-vbo=<span style=\"color: #b65611;\">false<\/span>: FPS: <span style=\"color: #b65611;\">150<\/span> FrameTime: <span style=\"color: #b65611;\">6.667<\/span> ms\r\n** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\r\n** Failed to set swap interval. Results may be bounded above by refresh rate.\r\n[build] use-vbo=<span style=\"color: #b65611;\">true<\/span>: FPS: <span style=\"color: #b65611;\">164<\/span> FrameTime: <span style=\"color: #b65611;\">6.098<\/span> ms\r\n** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\r\n** Failed to set swap interval. Results may be bounded above by refresh rate.\r\n[texture] texture-filter=nearest: FPS: <span style=\"color: #b65611;\">190<\/span> FrameTime: <span style=\"color: #b65611;\">5.263<\/span> ms\r\n** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\r\n** Failed to set swap interval. Results may be bounded above by refresh rate.\r\n[texture] texture-filter=linear: FPS: <span style=\"color: #b65611;\">172<\/span> FrameTime: <span style=\"color: #b65611;\">5.814<\/span> ms\r\n=======================================================\r\n                                  glmark2 Score: <span style=\"color: #b65611;\">169<\/span> \r\n=======================================================\r\n<\/code><\/pre>\n<p>2.\u3001glxgears \u2013\u7b80\u5355\u7684Linux GPU\u6027\u80fd\u6d4b\u8bd5\u5de5\u5177<\/p>\n<p>\u5b83\u5c06\u663e\u793a\u4e00\u7ec4\u65cb\u8f6c\u9f7f\u8f6e\u5e76\u5b9a\u671f\u6253\u5370\u51fa\u5e27\u9891\u3002 \u5b83\u5df2\u6210\u4e3aLinux\u548c\u7c7b\u4f3cFreeBSD\u7684\u7c7bUnix\u7cfb\u7edf\u7684\u57fa\u672c\u57fa\u51c6\u6d4b\u8bd5\u5de5\u5177\uff0c\u975e\u5e38\u53d7\u6b22\u8fce\u3002 \u5982\u4e0b\u5b89\u88c5\u5e76\u8fd0\u884c\u5b83\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install mesa-utils<\/span><\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">glxgears<\/span><\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4778\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2020\/12\/glxgears.gif\" alt=\"\" width=\"841\" height=\"763\" \/><\/p>\n<p>\u6bcf\u4e94\u79d2\u949f\u6d4b\u91cf\u4e00\u6b21GPU\u5e27\u901f\u7387\u5e76\u5c06\u5176\u53d1\u5e03\u5728\u5c4f\u5e55\u4e0a\u3002 \u6700\u7ec8\u7ed3\u679c\u5c06\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p>4005 frames in 5.0 seconds = 800.123 FPS<br \/>\n1348 frames in 5.0 seconds = 269.529 FPS<br \/>\n1259 frames in 5.0 seconds = 251.788 FPS<br \/>\n1047 frames in 5.0 seconds = 209.265 FPS<br \/>\n651 frames in 5.0 seconds = 130.198 FPS<br \/>\n651 frames in 5.0 seconds = 130.070 FPS<br \/>\n759 frames in 5.0 seconds = 151.732 FPS<br \/>\n&#8230;&#8230;<\/p>\n<p>3\u3001\u4e00\u4e2a\u5728Linux\u548cFreeBSD Unix\u4e0a\u83b7\u53d6Nvidia GPU\u7edf\u8ba1\u6570\u636e\u7684\u7b80\u5355\u5de5\u5177<\/p>\n<p>\u5b83\u662f\u7528Python\u7f16\u5199\u7684\uff0c\u662fCLI\u7528\u6237\uff0c\u7279\u522b\u662fML\/AI\u5f00\u53d1\u4eba\u5458\u7684\u5b8c\u7f8e\u5de5\u5177\u3002\u53ef\u4ee5\u4f7f\u7528PIP\u5b89\u88c5\u5b83\uff0c\u5982\u4e0b\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">pip install gpustat<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">pip3 install gpustat<\/span><\/p>\n<p>\u5982\u4e0b\u8fd0\u884c\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">gpustat<\/span><\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">gpustat -cp<\/span><\/p>\n<p>\u67e5\u770b\u5e2e\u52a9\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ \u00a0<span style=\"color: #ff0000;\">gpustat -h<\/span><\/p>\n<p>4\u3001intel_gpu_top &#8211; \u5728Linux\u4e0a\u663e\u793a\u82f1\u7279\u5c14GPU\u4f7f\u7528\u60c5\u51b5\u7684\u7c7b\u4f3ctop\u7684\u6458\u8981<\/p>\n<p>\u9996\u5148\u5b89\u88c5\u5de5\u5177\uff0c\u8fd0\u884c:<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install intel-gpu-tools<\/span><\/p>\n<p>## CentOS \/ RHEL \/ Fedora Linux\u7528\u6237\u5c1d\u8bd5dnf\u547d\u4ee4##<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo dnf install intel-gpu-tools<\/span><\/p>\n<p>Fedora\uff0cRHEL\u548cCentOS Linux\u7528\u6237\u53ef\u4ee5\u4f7f\u7528podman\u547d\u4ee4\u8fdb\u884c\u5982\u4e0b\u5b89\u88c5\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">podman run &#8211;rm &#8211;priviledged registry.freedesktop.org\/drm\/igt-gpu-tools\/igt:master<\/span><\/p>\n<p>\u8be5\u5de5\u5177\u4f7f\u7528i915\u548c\u5176\u4ed6\u5e73\u53f0\u9a71\u52a8\u7a0b\u5e8f\uff08\u5982RAPL\uff08\u7535\u6e90\uff09\u548cUncore IMC\uff08\u5185\u5b58\u5e26\u5bbd\uff09\uff09\u516c\u5f00\u7684\u6027\u80fd\u6027\u80fd\u8ba1\u6570\u5668\uff08PMU\uff09\u6536\u96c6\u6570\u636e\u3002 \u5728Linux\u7cfb\u7edf\u4e0a\u6309\u4ee5\u4e0b\u65b9\u5f0f\u8fd0\u884c\u5b83\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$\u00a0<span style=\"color: #ff0000;\">sudo intel_gpu_top<\/span><\/p>\n<p>5\u3001nvidia-smi \u2013 NVIDIA\u7cfb\u7edf\u7ba1\u7406\u754c\u9762\u7a0b\u5e8f<br \/>\nnvidia-smi\u4e3aFermi\u548c\u66f4\u9ad8\u67b6\u6784\u5bb6\u65cf\u7684NVIDIA Tesla\uff0cQuadro\uff0cGRID\u548cGeForce\u8bbe\u5907\u63d0\u4f9b\u76d1\u89c6\u548c\u7ba1\u7406\u529f\u80fd\u3002 \u652f\u6301GeForce Titan\u7cfb\u5217\u8bbe\u5907\u7684\u5927\u591a\u6570\u529f\u80fd\uff0c\u800c\u5269\u4f59\u7684Geforce\u54c1\u724c\u4fe1\u606f\u5219\u975e\u5e38\u6709\u9650\u3002 NVSMI\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u5de5\u5177\uff0c\u652f\u6301\u6240\u6709\u6807\u51c6\u7684NVIDIA\u9a71\u52a8\u7a0b\u5e8f\u652f\u6301\u7684Linux\u548cFreeBSD\u3002 \u5728Ubuntu Linux\u4e0a\u5b89\u88c5Nvidia\u9a71\u52a8\u7a0b\u5e8f\u540e\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$<span style=\"color: #ff0000;\">sudo\u00a0apt install nvidia-smi<\/span><\/p>\n<p>\u6253\u5f00\u7ec8\u7aef\uff0c\u7136\u540e\u8fd0\u884c\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ $ <span style=\"color: #ff0000;\">nvidia-smi -q -g 0 -d UTILIZATION -l 1<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ $ <span style=\"color: #ff0000;\">sudo nvidia-smi<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ $ <span style=\"color: #ff0000;\">nvidia-smi &#8211;help<\/span><\/p>\n<p>6. nvtop \u2013 NVIDIA GPU top<\/p>\n<p>\u53e6\u4e00\u4e2a\u5f88\u68d2\u4f46\u975e\u5e38\u6709\u7528\u7684NVIDIA GPU\u5de5\u5177\u3002 \u4e0ehtop\u547d\u4ee4\u6216top\u547d\u4ee4\u7c7b\u4f3c\uff0c\u5b83\u662f\u7528\u4e8eNVIDIA GPU\u7684\u57fa\u4e8encurses\u7684GPU\u72b6\u6001\u67e5\u770b\u5668\u3002 \u6211\u4eec\u53ef\u4ee5\u5982\u4e0b\u5b89\u88c5\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">apt install nvtop<\/span><br \/>\n## \u8fd0\u884c\u6b64\u653b\u51fb<br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">nvtop<\/span><\/p>\n<p>7\u3001radeontop \u2013\u663e\u793aLinux\u4e0aAMD GPU\u5229\u7528\u7387\u7684\u5de5\u5177<\/p>\n<p>\u67e5\u770b\u60a8\u7684AMD GPU\u5229\u7528\u7387\uff0c\u5305\u62ec\u603b\u6d3b\u52a8\u767e\u5206\u6bd4\u548cLinux\u4e0a\u7684\u5355\u4e2a\u5757\u3002 \u5982\u4e0b\u5b89\u88c5\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install radeontop<\/span><br \/>\nlinuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo radeontop<\/span><\/p>\n<p>\u5b83\u53ef\u4ee5\u4e0eR600\u548c\u66f4\u9ad8\u7684GPU\u914d\u5408\u4f7f\u7528\uff0c\u5373\u4f7fSouthern Islands\u5e94\u8be5\u4e5f\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u3002 \u4e0e\u5f00\u6e90AMD\u9a71\u52a8\u7a0b\u5e8f\u548cAMD Catalyst\u514b\u9686\u6e90\u9a71\u52a8\u7a0b\u5e8f\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n<p>\u60a8\u73b0\u5728\u5df2\u7ecf\u4e86\u89e3\u4e86\u7528\u4e8e\u5728Linux\u548c\u57fa\u4e8eBSD\u7cfb\u7edf\u4e0a\u76d1\u89c6\u548c\u8bca\u65ad\u76ee\u7684\u7684\u5404\u79cdLinux GPU\u547d\u4ee4\u548c\u5de5\u5177\u3002\u5982\u679c\u6211\u9519\u8fc7\u4e86\u4f60\u6700\u559c\u6b22\u7684\u5de5\u5177\uff0c\u8bf7\u5728\u4e0b\u9762\u7684\u8bc4\u8bba\u533a\u544a\u8bc9\u6211\u3002\u8c22\u8c22\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89c6\u9891\u5361\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u7535\u8def\u677f\uff0c\u7528\u4e8e\u63a7\u5236\u8ba1\u7b97\u673a\u76d1\u89c6\u5668\u4e0a\u663e\u793a\u7684\u5185\u5bb9\u3002 \u5b83\u4e5f\u79f0\u4e3a\u56fe\u5f62\u5904\u7406\u5355\u5143\uff08GPU\uff09\uff0c\u53ef\u4e3aL &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-4774","post","type-post","status-publish","format-standard","hentry","category-linux"],"aioseo_notices":[],"views":5646,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/4774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=4774"}],"version-history":[{"count":2,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/4774\/revisions"}],"predecessor-version":[{"id":4780,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/4774\/revisions\/4780"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=4774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=4774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=4774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}