{"id":256,"date":"2024-03-16T14:32:47","date_gmt":"2024-03-16T06:32:47","guid":{"rendered":"https:\/\/duothinking.com\/?p=256"},"modified":"2025-11-06T12:27:17","modified_gmt":"2025-11-06T04:27:17","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-windows-%e4%b8%8a%e6%87%89%e7%94%a8%e6%9c%80%e6%96%b0%e7%89%88%e7%9a%84-tensorflow-%e8%a8%93%e7%b7%b4%e6%a8%a1%e5%9e%8b%ef%bc%9f%e4%bd%a0%e9%9c%80%e8%a6%81-wsl-v2","status":"publish","type":"post","link":"https:\/\/ourblog.duothinking.com\/?p=256","title":{"rendered":"\u5982\u4f55\u5728 Windows \u4e0a\u61c9\u7528\u6700\u65b0\u7248\u7684 Tensorflow \u8a13\u7df4\u6a21\u578b\uff1f\u4f60\u9700\u8981 WSL v2"},"content":{"rendered":"\n<p>\u6700\u8fd1\u5728\u5b78\u7fd2\u4f7f\u7528 Tensorflow \u5efa\u7acb AI \u6a21\u578b\u3002Google Colab \u514d\u8cbb\u4e5f\u5f88\u597d\u7528\uff0c\u96e2\u5cf0\u6642\u6bb5\u9084\u80fd\u4f7f\u7528 GPU or TPU\u3002\u4f46\u662f\u6709\u6642\u5019\u5c31\u6703\u60f3\u5728\u81ea\u5df1\u7684\u6a5f\u5668\u4e0a\u5229\u7528 GPU \u4f86\u5efa\u6a21\u3002Tensorflow \u5b98\u65b9\u5b89\u88dd\u7db2\u7ad9 <a href=\"https:\/\/www.tensorflow.org\/install\/pip\">https:\/\/www.tensorflow.org\/install\/pip<\/a> \u63d0\u5230 Windows \u539f\u751f\u652f\u63f4\u53ea\u5230 v2.10 \u800c\u5df2\u3002\u800c\u64b0\u5beb\u672c\u6587\u6642\u6700\u65b0\u7248\u672c\u5df2\u7d93\u4f86\u5230 v2.16\uff0c\u96e3\u9053 Windows \u4f7f\u7528\u8005\u5c31\u5f97\u7528\u865b\u64ec\u6a5f\u5668\u8dd1 Linux \u6216\u662f\u5c0b\u627e\u5176\u4ed6\u96f2\u7aef\u8cc7\u6e90\u55ce\uff1f<\/p>\n\n\n\n<p>\u4e0d\u5fc5\u3002\u53ea\u8981\u4f60\u7684 Windows \u53ef\u4ee5\u8dd1 WSL v2 \u5c31\u80fd\u8dd1\u6700\u65b0\u7248\u7684 Tensorflow\uff01<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u5728 <a href=\"https:\/\/www.tensorflow.org\/install\/pip\">https:\/\/www.tensorflow.org\/install\/pip<\/a> \u6709\u63d0\u5230\uff0cWindows 10 64-bit \u7248\u672c 19044 \u6216\u66f4\u65b0\u7248\uff0c\u6216\u662f Windows 11 \u90fd\u652f\u63f4 WSL v2\u3002\u5728 WSL v2 \u4e2d\uff0c\u53ef\u4ee5\u9078\u64c7\u904b\u884c Ubuntu 20.04 LTS \u6216\u662f Ubuntu 22.04 LTS\uff0c\u90fd\u662f\u80fd\u57f7\u884c Tensorflow \u6700\u65b0\u7248\u7684\u74b0\u5883\u3002<\/p>\n\n\n\n<p>\u9019\u908a\u6211\u7528\u6211\u7684 Surface Book 3 \u4f86\u793a\u7bc4\u4e00\u6b21\u3002Surface Book 3 \u642d\u8f09\u4e00\u5f35 NVIDIA GTX 1660 Ti \u7368\u7acb\u986f\u793a\u5361\uff0c\u6709 6GB \u7684 VRAM\u3002\u96d6\u7136\u4e0d\u5927\u4f46\u9084\u80fd\u62ff\u4f86\u8a13\u7df4\u6a21\u578b\u3002<\/p>\n\n\n\n<p>\u8981\u5efa\u7f6e\u74b0\u5883\uff0c\u9996\u5148\u8981\u5148\u78ba\u8a8d\u5b89\u88dd WSL v2 \u4ee5\u53ca Ubuntu\u3002\u9019\u908a\u6211\u9078\u7528\u7684\u662f 22.04 LTS\u3002\u5b89\u88dd WSL v2 \u7684\u65b9\u6cd5\u8acb\u81ea\u884c\u5c0b\u627e\u3002<\/p>\n\n\n\n<p>\u88dd\u597d WSL v2 \u4ee5\u53ca Ubuntu \u74b0\u5883\u5f8c\uff0c\u9996\u5148\u8981\u5148\u78ba\u8a8d NVIDIA \u9a45\u52d5\u7a0b\u5f0f\u662f\u5426\u6b63\u5e38\u904b\u4f5c\u3002\u555f\u52d5 WSL \u5f8c\u57f7\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nvidia-smi<\/code><\/pre>\n\n\n\n<p>\u61c9\u8a72\u53ef\u4ee5\u5f97\u5230\u985e\u4f3c\u4e0b\u5716\u7684\u756b\u9762<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/duothinking.files.wordpress.com\/2024\/03\/nvidia-smi.png?w=1024\" alt=\"\" class=\"wp-image-262\" \/><\/figure>\n\n\n\n<p>\u6211\u4e4b\u524d\u66fe\u7d93\u9047\u904e\u4e00\u500b\u72c0\u6cc1\uff1a\u57f7\u884c nvidia-smi \u5f8c\uff0c\u51fa\u73fe\u4e86 segmentation fault \u7684\u932f\u8aa4\u8a0a\u606f\uff0c\u985e\u4f3c\u4e0b\u9762\u9019\u6a23\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/duothinking.files.wordpress.com\/2024\/03\/nvidia-smi-segmentation-fault-1.png?w=1024\" alt=\"\" class=\"wp-image-265\" \/><\/figure>\n\n\n\n<p>\u96d6\u7136\u6211\u7e7c\u7e8c\u5b89\u88dd\u4e86 tensorflow\uff0c\u6700\u5f8c\u4f9d\u7136\u627e\u4e0d\u5230 GPU\u3002\u7576\u6642\u6211\u7684 laptop \u5b89\u88dd\u7684\u662f NVIDIA \u5b98\u7db2\u4e0b\u8f09\u7684\u6700\u65b0\u7248\u9a45\u52d5\u7a0b\u5f0f\u3002\u5f8c\u4f86\u89e3\u6c7a\u7684\u65b9\u6cd5\u662f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5148\u4f7f\u7528 <a href=\"https:\/\/www.guru3d.com\/download\/display-driver-uninstaller-download\/\">Display driver uninstaller<\/a> \u79fb\u9664 NVIDIA \u9a45\u52d5\u7a0b\u5f0f<\/li>\n\n\n\n<li>\u7136\u5f8c\u8b93 Windows Update \u5b89\u88dd\u9a45\u52d5\u7a0b\u5f0f\u3002<\/li>\n\n\n\n<li>\u7531\u65bc Windows Update \u63d0\u4f9b\u7684\u9a45\u52d5\u7a0b\u5f0f\u7248\u672c\u53ea\u6709\u5230 51x\uff0c\u5be6\u5728\u662f\u592a\u820a\u4e86\uff0c\u6211\u5c31\u53c8\u4e0a\u4e86 NVIDIA \u5b98\u7db2\uff0c\u627e\u4e00\u500b\u7a0d\u5fae\u820a\u4e00\u9ede\u7684\u7248\u672c\uff08\u4e5f\u5c31\u662f 546.29\uff09\u4f86\u7528\u3002\u5b89\u88dd\u6642\u6211\u9078\u64c7\u5feb\u901f\u5b89\u88dd\uff08Express installation\uff09\u3002\u5b8c\u6210\u5f8c\u5728 WSL \u5167\u57f7\u884c nvidia-smi \u5f97\u5230\u7684\u7d50\u679c\u5c31\u662f\u6b63\u5e38\u7684\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u63a5\u4e0b\u4f86\u5c31\u662f\u6309\u7167 <a href=\"https:\/\/www.tensorflow.org\/install\/pip#step-by-step_instructions\">https:\/\/www.tensorflow.org\/install\/pip#step-by-step_instructions<\/a> \u7684\u4ecb\u7d39\u4f9d\u5e8f\u5b89\u88dd\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>CUDA ToolKit\u3002\u5b89\u88dd CUDA toolkit \u8981\u6ce8\u610f\u7248\u672c\u5c0d\u61c9\u3002\u53ef\u4ee5\u53c3\u8003 <a href=\"https:\/\/docs.nvidia.com\/cuda\/cuda-toolkit-release-notes\/index.html#id5\">https:\/\/docs.nvidia.com\/cuda\/cuda-toolkit-release-notes\/index.html#id5<\/a> \u4f8b\u5982\u8aaa\u8981\u5b89\u88dd CUDA toolkit v12 \u4ee5\u4e0a\u7684\u8a71\uff0c\u9a45\u52d5\u7a0b\u5f0f\u7248\u672c\u8981\u5927\u65bc\u7b49\u65bc 525.60.13\u3002\u5b89\u88dd\u7684\u65b9\u6cd5\u5c31\u662f\u5230 <a href=\"https:\/\/developer.nvidia.com\/cuda-toolkit-archive\">https:\/\/developer.nvidia.com\/cuda-toolkit-archive<\/a> \u627e\u4f60\u8981\u5b89\u88dd\u7684\u7248\u672c\uff0c\u9ede\u64ca\u8a72\u7248\u672c\u7684\u9023\u7d50\u5f8c\uff0c\u9078 Linux\uff0c\u4f60\u7684\u5e73\u53f0\u683c\u5f0f\uff08\u65e2\u7136\u662f Windows\uff0c\u61c9\u8a72\u5c31\u662f x86_64\uff09\uff0c\u7136\u5f8c WSL-Ubuntu\u3002\u6700\u5f8c\u5b89\u88dd\u683c\u5f0f\u6839\u64da\u81ea\u5df1\u9700\u6c42\u9078\u64c7\u3002\u9078\u64c7\u5b8c\u7562\u5f8c\uff0c\u8a72\u9801\u9762\u6703\u63d0\u4f9b\u5b89\u88dd\u6307\u5f15\uff0c\u7167\u8457\u505a\u5373\u53ef\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/duothinking.files.wordpress.com\/2024\/03\/cudatoolkit.png?w=1024\" alt=\"\" class=\"wp-image-268\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>\u4e0b\u4e00\u6b65\uff0c\u8981\u5b89\u88dd cuDNN SDK\u3002\u5230 <a href=\"https:\/\/developer.nvidia.com\/cudnn\">https:\/\/developer.nvidia.com\/cudnn<\/a> \u3002\u9019\u908a\u5c31\u4e0d\u50cf CUDA toolkit \u9084\u8981\u9078\u7248\u672c\uff0c\u76f4\u63a5\u9ede Download cuDNN library \u5c31\u884c\u4e86\u3002\u5728 distrubution \u9078 Ubuntu \u5c31\u597d\uff0c\u7136\u5f8c version \u9078\u64c7\u81ea\u5df1\u5b89\u88dd\u7684 Ubuntu \u7248\u672c\u3002\u6700\u4e0b\u9762\u5b89\u88dd\u6307\u5f15\u4e5f\u6709\u63d0\u9192\u5982\u4f55\u5b89\u88dd\u7b26\u5408\u7279\u5b9a CUDA Toolkit \u7248\u672c\u7684 cuDNN\u3002<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/duothinking.files.wordpress.com\/2024\/03\/cudnn.png?w=1024\" alt=\"\" class=\"wp-image-271\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>\u57f7\u884c\u4e0b\u5217\u6307\u4ee4\uff0c\u78ba\u4fdd pip \u662f\u6700\u65b0\u7248<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install --upgrrade pip<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>\u57f7\u884c\u4e0b\u5217\u6307\u4ee4\uff0c\u5b89\u88dd\u652f\u63f4 GPU \u904b\u7b97\u7684 tensorflow<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install tensorflow&#091;and-cuda]<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u57f7\u884c\u4e0b\u5217\u6307\u4ee4\u6aa2\u67e5\u8f38\u51fa\u7d50\u679c<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 -c \"import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))\"<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u61c9\u8a72\u6703\u5f97\u5230\u985e\u4f3c\u4e0b\u5716\u7684\u8f38\u51fa<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/duothinking.files.wordpress.com\/2024\/03\/tensorflow_stdout_gpudetection.png?w=1024\" alt=\"\" class=\"wp-image-275\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u5b78\u7fd2\u4f7f\u7528 Tensorflow \u5efa\u7acb AI \u6a21\u578b\u3002Google Colab \u514d\u8cbb\u4e5f\u5f88\u597d\u7528\uff0c\u96e2\u5cf0\u6642\u6bb5\u9084\u80fd\u4f7f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[2,7,10,14],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-22","tag-ai","tag-nvidia","tag-tensorflow","tag-wsl"],"_links":{"self":[{"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=256"}],"version-history":[{"count":1,"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":318,"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions\/318"}],"wp:attachment":[{"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ourblog.duothinking.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}