{"id":1765,"date":"2022-11-28T18:14:48","date_gmt":"2022-11-28T10:14:48","guid":{"rendered":"https:\/\/qishiya.com\/?p=1765"},"modified":"2022-11-28T18:14:49","modified_gmt":"2022-11-28T10:14:49","slug":"tensorflow-%e5%ae%b9%e5%99%a8%e6%94%af%e6%8c%81-gpu","status":"publish","type":"post","link":"https:\/\/qishiya.com\/?p=1765","title":{"rendered":"<strong>TensorFlow \u5bb9\u5668\u652f\u6301 GPU<\/strong>"},"content":{"rendered":"\n<p>\u4e00\u53f0 GPU \u673a\u5668\uff0c\u76f4\u63a5\u8bbf\u95ee gpu \u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4f46\u662f\u5b89\u88c5 tensorflow \u540e\uff0c\u4e00\u76f4\u8bbf\u95ee\u4e0d\u5230 GPU\uff0c\u770b\u4e86\u4e00\u4e0b TensorFlow \u652f\u6301\u5bb9\u5668\u5316\u5b89\u88c5\uff0c\u662f\u53ef\u4ee5\u652f\u6301 GPU \u7684\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_61 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ff6200;color:#ff6200\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ff6200;color:#ff6200\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/qishiya.com\/?p=1765\/#tensorflow_%E5%AE%B9%E5%99%A8%E5%8C%96%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4\" title=\"tensorflow \u5bb9\u5668\u5316\u5b89\u88c5\u6b65\u9aa4\">tensorflow \u5bb9\u5668\u5316\u5b89\u88c5\u6b65\u9aa4<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/qishiya.com\/?p=1765\/#%E5%89%8D%E6%8F%90\" title=\"\u524d\u63d0\">\u524d\u63d0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/qishiya.com\/?p=1765\/#%E5%AE%89%E8%A3%85_nvidia-docker\" title=\"\u5b89\u88c5 nvidia-docker\">\u5b89\u88c5 nvidia-docker<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/qishiya.com\/?p=1765\/#%E5%AE%89%E8%A3%85_tensorflow\" title=\"\u5b89\u88c5 tensorflow\">\u5b89\u88c5 tensorflow<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/qishiya.com\/?p=1765\/#%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%AE%89%E8%A3%85%E6%88%90%E5%8A%9F\" title=\"\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\">\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/qishiya.com\/?p=1765\/#%E5%90%AF%E5%8A%A8_tensorflow\" title=\"\u542f\u52a8 tensorflow\">\u542f\u52a8 tensorflow<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/qishiya.com\/?p=1765\/#%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E6%94%AF%E6%8C%81_gpu\" title=\"\u68c0\u67e5\u662f\u5426\u652f\u6301 gpu\">\u68c0\u67e5\u662f\u5426\u652f\u6301 gpu<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"tensorflow_%E5%AE%B9%E5%99%A8%E5%8C%96%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4\"><\/span>tensorflow \u5bb9\u5668\u5316\u5b89\u88c5\u6b65\u9aa4<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%89%8D%E6%8F%90\"><\/span>\u524d\u63d0<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u5fc5\u987b\u5148\u5728\u5bbf\u4e3b\u673a\u4e0a \u5b89\u88c5 <strong><a href=\"https:\/\/docs.nvidia.com\/datacenter\/tesla\/tesla-installation-notes\/index.html\">NVIDIA driver<\/a><\/strong> \u548c Docker\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%89%E8%A3%85_nvidia-docker\"><\/span>\u5b89\u88c5 nvidia-docker<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><a href=\"https:\/\/docs.nvidia.com\/datacenter\/cloud-native\/container-toolkit\/install-guide.html#installing-on-centos-7-8\">Installation Guide \u2014 NVIDIA Cloud Native Technologies documentation<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%89%E8%A3%85_tensorflow\"><\/span>\u5b89\u88c5 tensorflow<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>docker pull tensorflow\/tensorflow:2.11.0-gpu<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E5%AE%89%E8%A3%85%E6%88%90%E5%8A%9F\"><\/span>\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%90%AF%E5%8A%A8_tensorflow\"><\/span>\u542f\u52a8 tensorflow<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run --gpus all -it   -v $PWD:\/tmp -w \/tmp tensorflow\/tensorflow:2.11.0-gpu bash<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A3%80%E6%9F%A5%E6%98%AF%E5%90%A6%E6%94%AF%E6%8C%81_gpu\"><\/span>\u68c0\u67e5\u662f\u5426\u652f\u6301 gpu<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>nvidia-smi\n\n docker run --gpus all -it --rm tensorflow\/tensorflow:2.11.0-gpu \\\n   python -c \"import tensorflow as tf; print(tf.reduce_sum(tf.random.normal(&#91;1000, 1000])))\"<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u53f0 GPU \u673a\u5668\uff0c\u76f4\u63a5\u8bbf\u95ee gpu \u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4f46\u662f\u5b89\u88c5 tensorflow \u540e\uff0c\u4e00\u76f4\u8bbf\u95ee\u4e0d\u5230 GPU\uff0c\u770b\u4e86\u4e00\u4e0b TensorFlow \u652f\u6301\u5bb9\u5668\u5316\u5b89\u88c5\uff0c\u662f\u53ef\u4ee5\u652f\u6301 GPU \u7684\u3002 tensorflow \u5bb9\u5668\u5316\u5b89\u88c5\u6b65\u9aa4 \u524d\u63d0 \u5fc5\u987b\u5148\u5728\u5bbf\u4e3b &#8230; <a title=\"TensorFlow \u5bb9\u5668\u652f\u6301 GPU\" class=\"read-more\" href=\"https:\/\/qishiya.com\/?p=1765\" aria-label=\"\u66f4\u591a TensorFlow \u5bb9\u5668\u652f\u6301 GPU\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"templates\/template-full-width.php","format":"standard","meta":{"footnotes":""},"categories":[496,5],"tags":[531,538,537],"class_list":["post-1765","post","type-post","status-publish","format-standard","hentry","category-496","category-5","tag-docker","tag-gpu","tag-tensorflow"],"_links":{"self":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/1765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1765"}],"version-history":[{"count":1,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/1765\/revisions"}],"predecessor-version":[{"id":1766,"href":"https:\/\/qishiya.com\/index.php?rest_route=\/wp\/v2\/posts\/1765\/revisions\/1766"}],"wp:attachment":[{"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qishiya.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}