{"id":3918,"date":"2022-04-20T18:48:33","date_gmt":"2022-04-20T10:48:33","guid":{"rendered":"http:\/\/139.9.1.231\/?p=3918"},"modified":"2022-04-21T09:23:59","modified_gmt":"2022-04-21T01:23:59","slug":"linux-tensorflow","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/04\/20\/linux-tensorflow\/","title":{"rendered":"linux \u5b89\u88c5tensorflow \u8bb0\u5f55"},"content":{"rendered":"\n<p>\u4e00\u7eb8\u8f9b\u9178\u6cea&#8230;&#8230;..<\/p>\n\n\n\n<p>\u5b89\u88c5tensorflow gpu\u9700\u8981\u5148\u5b89\u88c5cudn   \u548c cudnn<\/p>\n\n\n\n<p>\u73b0\u5728\u6211\u5df2\u7ecf\u5b89\u88c5\u597d\u4e86cudn\uff0cnvcc-v \u4e5f\u53ef\u4ee5\u6b63\u5e38\u663e\u793a\uff0c\u4f46\u662f\u5728\/usr\/local\/\u6587\u4ef6\u5939\u4e0b\u5374\u6ca1\u6709cuda\u6587\u4ef6\u5939.<\/p>\n\n\n\n<h3>2.\u95ee\u9898\u7531\u6765<\/h3>\n\n\n\n<p>\u901a\u5e38\u6211\u4eec\u5728\u5b89\u88c5cudnn\u65f6,\u5148\u8fdb\u884c\u5b89\u88c5cuda,\u7136\u540e\u4e0b\u8f7dcudnn\u6587\u4ef6,\u901a\u8fc7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xzvf cudnn-10.2-linux-x64-v7.6.5.32.tgz\n<em>#\u547d\u4ee4\u89e3\u538b\u6587\u4ef6\uff0c\u4f1a\u5f97\u5230\u4e00\u4e2acuda\u6587\u4ef6\u5939\uff0c\u9010\u4e00\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884ccudnn\u7684\u5b89\u88c5<\/em>\nsudo cp cuda\/include\/cudnn*.h \/usr\/local\/cuda\/include\/\nsudo cp cuda\/lib64\/libcudnn* \/usr\/local\/cuda\/lib64\/\nsudo chmod a+r \/usr\/local\/cuda\/include\/cudnn.h\nsudo chmod a+r \/usr\/local\/cuda\/lib64\/libcudnn*\n<em>#\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u67e5\u770b\u5b89\u88c5\u60c5\u51b5\uff0c\u5982\u679c\u7ed3\u679c\u5982\u4e0b\u56fe\u9010\u884c\u663e\u793a\u7248\u672c\u53f7\uff0c\u5219\u5b89\u88c5\u6210\u529f<\/em>\ncat \/usr\/local\/cuda\/include\/cudnn.h | grep CUDNN_MAJOR -A 2\n<\/code><\/pre>\n\n\n\n<p><img src=\"https:\/\/img-blog.csdnimg.cn\/20201225161756765.png#pic_center\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"><br>\u4f46\u662f\u73b0\u5728\u5e76\u6ca1\u6709\u8fd9\u4e2a\u6587\u4ef6\u5939\u8be5\u5982\u4f55\u505a\u5462?<\/p>\n\n\n\n<h3><a><\/a><a><\/a>3.\u95ee\u9898\u5b9a\u4f4d<\/h3>\n\n\n\n<p>\u4f7f\u7528\u6307\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>whereis cuda\n<\/code><\/pre>\n\n\n\n<p>\u8f93\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cuda: \/usr\/lib\/cuda \/usr\/include\/cuda.h\n<\/code><\/pre>\n\n\n\n<p>\u627e\u5230\u4e86cuda\u7684\u4f4d\u7f6e<\/p>\n\n\n\n<h3><a><\/a><a><\/a>4.\u95ee\u9898\u539f\u56e0<\/h3>\n\n\n\n<p>\u4e4b\u6240\u4ee5\u5728\u8fd9\u4e24\u4e2a\u4f4d\u7f6e\u662f\u7531\u4e8e,<mark>\u901a\u8fc7sudo apt install nvidia-cuda-toolkit<\/mark><\/p>\n\n\n\n<p>\u8fd9\u79cd\u5b89\u88c5\u65b9\u6cd5\u5728\/usr\/include\u548c\/usr\/lib\/cuda\/lib64\u4e2d\u5b89\u88c5cuda<\/p>\n\n\n\n<h3><a><\/a><a><\/a>5.\u95ee\u9898\u89e3\u51b3<\/h3>\n\n\n\n<p>\u627e\u4e86cuda\u7684\u4f4d\u7f6e\u540e,\u5b89\u88c5cudnn,\u5c06\u4e0a\u8ff0\u6307\u4ee4\u66ff\u6362\u4e3a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -xzvf cudnn-10.2-linux-x64-v7.6.5.32.tgz\n<em>#\u547d\u4ee4\u89e3\u538b\u6587\u4ef6\uff0c\u4f1a\u5f97\u5230\u4e00\u4e2acuda\u6587\u4ef6\u5939\uff0c\u9010\u4e00\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884ccudnn\u7684\u5b89\u88c5<\/em>\nsudo cp cuda\/include\/cudnn*.h \/usr\/include\/\nsudo cp cuda\/lib64\/libcudnn* \/usr\/lib\/cuda\/lib64\/\nsudo chmod a+r \/usr\/include\/cudnn.h\nsudo chmod a+r \/usr\/lib\/cuda\/lib64\/libcudnn*\n<em>#\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u67e5\u770b\u5b89\u88c5\u60c5\u51b5\uff0c\u5982\u679c\u7ed3\u679c\u5982\u4e0b\u56fe\u9010\u884c\u663e\u793a\u7248\u672c\u53f7\uff0c\u5219\u5b89\u88c5\u6210\u529f<\/em>\ncat \/usr\/include\/cudnn.h | grep CUDNN_MAJOR -A 2\n<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\u9700\u8981\u5c06cuda.h\u4e0ecudnn.h\u6587\u4ef6\u653e\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e0b.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2><strong>nvcc\u548cnvidia-smi\u663e\u793a\u7684cuda\u7248\u672c\u4e0d\u4e00\u81f4\u89e3\u91ca\uff1a<\/strong><\/h2>\n\n\n\n<p>nvcc\u5c5e\u4e8ecuda\u7684\u7f16\u8bd1\u5668\uff0c\u5c06\u7a0b\u5e8f\u7f16\u8bd1\u6210\u53ef\u6267\u884c\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0cnvidia-smi\u5168\u79f0\u662fNVIDIA System Management Interface,\u662f\u4e00\u79cd\u547d\u4ee4\u884c\u4f7f\u7528\u5de5\u5177\uff0c\u65e8\u5728\u5e2e\u52a9\u7ba1\u7406\u548c\u76d1\u63a7NVIDIA GPU\u8bbe\u5907\u3002<\/p>\n\n\n\n<p>cuda\u6709runtime api\u548cdriver api\uff0c\u4e24\u8005\u90fd\u6709\u5bf9\u5e94\u7684cuda\u7248\u672c\uff0cnvcc \u2013version\u663e\u793a\u7684\u5c31\u662f\u524d\u8005\u5bf9\u5e94\u7684cuda\u7248\u672c\uff0c\u800cnvidia-smi\u663e\u793a\u7684\u662f\u540e\u8005\u5bf9\u5e94\u7684cuda\u7248\u672c\u3002<\/p>\n\n\n\n<p>\u7528\u4e8e\u652f\u6301driver api\u7684\u5fc5\u8981\u6587\u4ef6\u7531GPU driver install\u5b89\u88c5\uff0cnvidia-smi\u5c31\u5c5e\u4e8e\u8fd9\u4e00\u7c7bAPI\uff1b\u800c\u7528\u4e8e\u652f\u6301runtime api\u7684\u5fc5\u8981\u6587\u4ef6\u662f\u7531cuda toolkit install\u5b89\u88c5\u7684\u3002nvcc\u662f\u4e0ecuda toolkit\u4e00\u8d77\u5b89\u88c5\u7684cuda compiler-driver tool,\u5b83\u53ea\u77e5\u9053\u81ea\u8eab\u6784\u5efa\u65f6\u7684cuda runtime\u7248\u672c\uff0c\u5e76\u4e0d\u77e5\u9053\u5b89\u88c5\u4e86\u4ec0\u4e48\u7248\u672c\u7684GPU driver\uff0c\u751a\u81f3\u4e0d\u77e5\u9053\u662f\u5426\u5b89\u88c5\u4e86GPU driver\u3002<\/p>\n\n\n\n<p>cuda toolkit install\u901a\u5e38\u4f1a\u96c6\u6210\u4e86GPU driver install\uff0c\u5982\u679c\u4f60\u7684cuda\u5747\u901a\u8fc7cuda toolkit install\u6765\u5b89\u88c5\uff0c\u90a3\u4e48runtime api\u548cdriver api\u7684\u7248\u672c\u5e94\u8be5\u662f\u4e00\u81f4\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0cnvcc -V\u548cnvidia-smi\u663e\u793a\u7684\u7248\u672c\u6b63\u5e38\u662f\u4e00\u6837\u7684\uff0c\u5426\u5219\u4f60\u53ef\u80fd\u4f7f\u7528\u4e86\u5355\u72ec\u7684GPU driver install\u6765\u5b89\u88c5GPU driver\uff0c\u8fd9\u6837\u5c31\u4f1a\u5bfc\u81f4nvidia-smi\u548cnvcc -V\u663e\u793a\u7684\u7248\u672c\u4e0d\u4e00\u6837\u3002<\/p>\n\n\n\n<p>\u901a\u5e38\uff0cdriver api\u7684\u7248\u672c\u80fd\u5411\u4e0b\u517c\u5bb9runtime api\u7684\u7248\u672c\uff0c\u5373nvidia-smi\u663e\u793a\u7684\u7248\u672c\u5927\u4e8envcc -V\u65f6\u901a\u5e38\u662f\u53ef\u4ee5\u4f7f\u7528\u7684\u3002<\/p>\n\n\n\n<p>#runtime api\u5c31\u662frunfile\u7c7b\u578b\u7684\u5b89\u88c5\u6587\u4ef6\uff0cdriver api\u5c31\u662fdeb\u7c7b\u578b\u7684\u5b89\u88c5\u6587\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u7eb8\u8f9b\u9178\u6cea&#8230;&#8230;.. \u5b89\u88c5tensorflow gpu\u9700\u8981\u5148\u5b89\u88c5cudn \u548c cudnn &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/04\/20\/linux-tensorflow\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">linux \u5b89\u88c5tensorflow \u8bb0\u5f55<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/3918"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=3918"}],"version-history":[{"count":3,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/3918\/revisions"}],"predecessor-version":[{"id":3922,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/3918\/revisions\/3922"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=3918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=3918"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=3918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}