{"id":298,"date":"2022-03-24T23:06:49","date_gmt":"2022-03-24T15:06:49","guid":{"rendered":"https:\/\/www.lazybirds.top\/?p=298"},"modified":"2022-07-20T10:44:54","modified_gmt":"2022-07-20T02:44:54","slug":"anaconda-pytorch-%e5%ae%89%e8%a3%85%e8%b8%a9%e5%9d%91","status":"publish","type":"post","link":"https:\/\/www.lazybirds.top\/?p=298","title":{"rendered":"Anaconda + Pytorch \u5b89\u88c5\u8e29\u5751"},"content":{"rendered":"\n<p>\u5728\u5bf9\u786c\u76d8\u7a7a\u95f4\u7684\u6700\u540e\u538b\u69a8\u548c\u5bf9\u6821\u7f51\u7684\u65e0\u5c3d\u6298\u78e8\u540e\uff0c\u7ec8\u4e8e\u88c5\u4e0a\u4e86..<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3>\u6d4b\u8bd5\u7cfb\u7edf\u4fe1\u606f<\/h3>\n\n\n\n<ul><li>Windows 10 \u5bb6\u5ead\u4e2d\u6587\u7248 21H1<\/li><li>NVIDIA GeForce RTX 2060 with Max-Q Design<\/li><li>AMD Ryzen 7 4800HS with Radeon Graphics 2.90 GHz<\/li><li>NVCUDA64.DLL 11.6.127 (\u53ef\u5728 NVIDIA\u63a7\u5236\u9762\u677f &#8211; \u5e2e\u52a9 &#8211; \u7cfb\u7edf\u4fe1\u606f &#8211; \u7ec4\u4ef6 \u91cc\u67e5\u8be2)<\/li><\/ul>\n\n\n\n<h2>\u5b89\u88c5ANACONDA<\/h2>\n\n\n\n<p>Anaconda\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Python\u53d1\u884c\u7248\u672c\uff0c\u5185\u542bconda, python, numpy\u7b49180\u591a\u4e2a\u79d1\u5b66\u5305\u53ca\u5176\u4f9d\u8d56\u9879\u3002<\/p>\n\n\n\n<p>\u5728<a href=\"%5BAnaconda%20%7C%20Individual%20Edition%5D(https:\/\/www.anaconda.com\/products\/individual#Downloads)\">\u5b98\u7f51<\/a>\u4e0b\u8f7d\u5b89\u88c5\u5305\u5b89\u88c5\u5373\u53ef\u3002\u5b89\u88c5\u6210\u529f\u540e\u53ef\u4ee5\u4f7f\u7528Anaconda Navigator\u901a\u8fc7\u56fe\u5f62\u754c\u9762\u521b\u5efa\u865a\u62dfpython\u73af\u5883\uff0c\u6216\u4f7f\u7528Anaconda Prompt\u4ee5\u547d\u4ee4\u884c\u7684\u65b9\u5f0f\u521b\u5efa\u865a\u62dfpython\u73af\u5883\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u5728\u5b89\u88c5\u65f6\u52fe\u9009\u4e86\u5c06\u5176\u6dfb\u52a0\u81f3\u73af\u5883\u53d8\u91cf\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7cmd\u6216powershell\u65b9\u4fbf\u5730\u8c03\u7528python,conda\u7b49\u6307\u4ee4\u3002\u4e0d\u8fc7\uff0c\u8003\u8651\u5230\u6211\u5df2\u7ecf\u88c5\u4e86python\u7684\u53e6\u4e00\u4e2a\u7248\u672c\uff0c\u4e3a\u4e86\u907f\u514d\u91cd\u590d\u5b89\u88c5\u5176\u4ed6\u8f6f\u4ef6\uff08\u4f8b\u5982VSCode\u7684\u4e00\u4e9b\u63d2\u4ef6\uff09\u7684\u4f9d\u8d56\u5305\uff0c\u8fd8\u662f\u9009\u62e9\u901a\u8fc7Anaconda Prompt\u8c03\u7528\u5427\u3002<\/p>\n\n\n\n<h2>ANACONDA\u6362\u6e90<\/h2>\n\n\n\n<p>\u8fd9\u91cc\u4f7f\u7528<a href=\"https:\/\/mirror.tuna.tsinghua.edu.cn\/help\/anaconda\/\">anaconda | \u955c\u50cf\u7ad9\u4f7f\u7528\u5e2e\u52a9 | \u6e05\u534e\u5927\u5b66\u5f00\u6e90\u8f6f\u4ef6\u955c\u50cf\u7ad9 | Tsinghua Open Source Mirror<\/a><\/p>\n\n\n\n<p>\u6309\u7167\u63d0\u793a\u4fee\u6539.condarc\u6587\u4ef6\uff0c\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">conda clean -i<\/code><\/pre>\n\n\n\n<h2>\u5b89\u88c5CUDA*<\/h2>\n\n\n\n<p>\uff08Anaconda\u81ea\u5e26\u4e86pytorch\u4e0ecudatoolkit\uff0c\u4f46\u4e0d\u77e5\u4e3a\u5565\uff0c\u5b9e\u6d4b\u65e0\u6cd5\u6210\u529f\u8c03\u7528cuda&#8230;\u8fd8\u662f\u8001\u8001\u5b9e\u5b9e\u5730\u628acuda\u4e0b\u4e0b\u6765\u5427&#8230;<\/p>\n\n\n\n<p>\u6ce8\u610f\u5230\u6211\u7684cuda\u7248\u672c\u662f11.6.x\uff0c\u56e0\u6b64\u4e0b\u8f7d\u76f8\u5e94\u7248\u672c\u7684<a href=\"https:\/\/developer.nvidia.com\/cuda-downloads\">CUDA Toolkit 11.6 Update 1 Downloads | NVIDIA Developer<\/a><\/p>\n\n\n\n<p>\uff08\u7f51\u4e0a\u7684\u6559\u7a0b\u5927\u90fd\u7ed9\u4e86\u8fd9\u6b65\uff0c\u540e\u6765\u53d1\u73b0\u8fd9\u4e00\u6b65\u9aa4\u4f3c\u4e4e\u4e0d\u662f\u5fc5\u8981\u7684&#8230;\u6839\u636e\u4ee5\u4e0b\u535a\u5ba2\uff0c\u8c8c\u4f3c\u53ea\u8981\u901a\u8fc7conda\u5b89\u88c5\u76f8\u5e94\u7248\u672c\u7684cudatoolkit\u5373\u53ef&#8230;<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/qq_41094058\/article\/details\/116207333\">\u4e00\u6587\u8bb2\u6e05\u695aCUDA\u3001CUDA toolkit\u3001CUDNN\u3001NVCC\u5173\u7cfb<em>\u50650000\u7684\u535a\u5ba2-CSDN\u535a\u5ba2<\/em>cudatoolkit\u548ccuda\u6709\u5173\u7cfb\u5417<\/a><\/p>\n\n\n\n<h2>\u5b89\u88c5pytorch<\/h2>\n\n\n\n<p>\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u865a\u62dfpython\u73af\u5883\uff0c\u8fd9\u91cc\u547d\u540d\u4e3atest\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">conda create -n test<\/code><\/pre>\n\n\n\n<p>\u6fc0\u6d3btest\u73af\u5883\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">conda activate test<\/code><\/pre>\n\n\n\n<p>\u6839\u636e<a href=\"%5BStart%20Locally%20%7C%20PyTorch%5D(https:\/\/pytorch.org\/get-started\/locally\/)\">\u5b98\u7f51<\/a>\u7ed9\u51fa\u7684\u63d0\u793a\uff0c\u5b89\u88c5pytorch<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e00\u6b65\u5927\u7ea6\u9700\u8981\u4e0b\u8f7d\u51e0\u4e2aG\u7684\u6587\u4ef6\u3002\u7531\u4e8e\u670d\u52a1\u5668\u5728\u56fd\u5916\uff0c\u9700\u8981\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u3002\u671f\u95f4\u5982\u679c\u51fa\u73b0\u7f51\u7edc\u62a5\u9519\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u590d\u8be5\u547d\u4ee4\u3002<\/p>\n\n\n\n<h2>\u6d4b\u8bd5pytorch<\/h2>\n\n\n\n<p>\u6253\u5f00python<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">python<\/code><\/pre>\n\n\n\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import torch\nx = torch.rand(5, 3)\nprint(x)<\/code><\/pre>\n\n\n\n<p>\u82e5\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u7c7b\u4f3c\u7ed3\u679c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">tensor([[0.3380, 0.3845, 0.3217],\n &nbsp; &nbsp; &nbsp;  [0.8337, 0.9050, 0.2650],\n &nbsp; &nbsp; &nbsp;  [0.2979, 0.7141, 0.9069],\n &nbsp; &nbsp; &nbsp;  [0.1449, 0.1132, 0.1375],\n &nbsp; &nbsp; &nbsp;  [0.4675, 0.3947, 0.1426]])<\/code><\/pre>\n\n\n\n<p>\u8bf4\u660epytorch\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n\n\n\n<p>\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import torch\ntorch.cuda.is_available()<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u8fd4\u56deTrue\uff0c\u90a3\u4e48Congratulation\uff01cuda\u5df2\u6b63\u786e\u914d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5bf9\u786c\u76d8\u7a7a\u95f4\u7684\u6700\u540e\u538b\u69a8\u548c\u5bf9\u6821\u7f51\u7684\u65e0\u5c3d\u6298\u78e8\u540e\uff0c\u7ec8\u4e8e\u88c5\u4e0a\u4e86..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[26,25],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts\/298"}],"collection":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=298"}],"version-history":[{"count":6,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts\/298\/revisions"}],"predecessor-version":[{"id":348,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=\/wp\/v2\/posts\/298\/revisions\/348"}],"wp:attachment":[{"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lazybirds.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}