{"id":36959,"date":"2025-05-13T01:04:03","date_gmt":"2025-05-12T17:04:03","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/36959.html"},"modified":"2025-05-13T01:04:03","modified_gmt":"2025-05-12T17:04:03","slug":"pytorch-%e7%89%88%e6%9c%ac%e3%80%81torchvision-%e7%89%88%e6%9c%ac%e5%92%8c-python-%e7%89%88%e6%9c%ac%e7%9a%84%e5%af%b9%e5%ba%94%e5%85%b3%e7%b3%bb","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/36959.html","title":{"rendered":"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb"},"content":{"rendered":"<h3>PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/h3>\n<\/p>\n<p>\u00a0\u00a0\u5728\u6df1\u5ea6\u5b66\u4e60\u9886\u57df&#xff0c;PyTorch \u53ca\u5176\u914d\u5957\u5e93 torchvision \u7684\u4f7f\u7528\u6781\u4e3a\u5e7f\u6cdb\u3002\u4f46\u4e0d\u540c\u7248\u672c\u7684 PyTorch\u3001torchvision \u4e0e Python \u4e4b\u95f4\u5b58\u5728\u4e25\u683c\u7684\u5bf9\u5e94\u5173\u7cfb&#xff0c;\u82e5\u7248\u672c\u642d\u914d\u4e0d\u5f53&#xff0c;\u4f1a\u5bfc\u81f4\u4ee3\u7801\u8fd0\u884c\u51fa\u9519\u3001\u529f\u80fd\u65e0\u6cd5\u5b9e\u73b0\u7b49\u95ee\u9898\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u68b3\u7406\u4e09\u8005\u7684\u5bf9\u5e94\u5173\u7cfb&#xff0c;\u5e76\u4ecb\u7ecd\u57fa\u4e8e conda \u7684\u5b89\u88c5\u65b9\u6cd5\u4e0e\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u3002<\/p>\n<h3>\u4e00\u3001\u7248\u672c\u5bf9\u5e94\u5173\u7cfb<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"932\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512170401-68222a0198557.png\" width=\"1100\" \/><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u5b9e\u9645\u5e94\u7528\u4e2d\u5e94\u53c2\u8003 PyTorch \u5b98\u65b9\u6587\u6863\u83b7\u53d6\u6700\u65b0\u3001\u6700\u51c6\u786e\u7684\u7248\u672c\u5bf9\u5e94\u4fe1\u606f&#xff0c;\u56e0\u4e3a CUDA \u7248\u672c\u7b49\u56e0\u7d20\u4e5f\u4f1a\u5f71\u54cd\u7248\u672c\u517c\u5bb9\u6027\u3002<\/p>\n<h3>\u4e8c\u3001\u57fa\u4e8e conda \u5b89\u88c5 PyTorch<\/h3>\n<p>conda \u662f\u5f3a\u5927\u7684\u5305\u7ba1\u7406\u5668\u548c\u73af\u5883\u7ba1\u7406\u5668&#xff0c;\u4f7f\u7528\u5b83\u5b89\u88c5 PyTorch\u3001\u7ba1\u7406 Python \u73af\u5883\u5341\u5206\u4fbf\u6377&#xff0c;\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b&#xff1a;<\/p>\n<h4>&#xff08;\u4e00&#xff09;\u521b\u5efa\u5e76\u6fc0\u6d3b conda \u73af\u5883<\/h4>\n<p>conda create -n myenv python&#061;3.8<br \/>\nconda activate myenv<\/p>\n<p>\u4e0a\u8ff0\u547d\u4ee4\u4e2d&#xff0c;conda create -n myenv python&#061;3.8 \u7528\u4e8e\u521b\u5efa\u540d\u4e3a myenv &#xff0c;Python \u7248\u672c\u4e3a 3.8 \u7684\u65b0\u73af\u5883&#xff1b;conda activate myenv \u5219\u53ef\u6fc0\u6d3b\u8be5\u73af\u5883\u3002<\/p>\n<h4>&#xff08;\u4e8c&#xff09;\u5b89\u88c5\u6307\u5b9a\u7248\u672c PyTorch \u53ca\u76f8\u5173\u5e93<\/h4>\n<p>\u6839\u636e PyTorch \u5b98\u65b9\u6307\u4ee4\u5b89\u88c5\u76ee\u6807\u7248\u672c\u3002\u4ee5\u5b89\u88c5 PyTorch 1.9.1 \u7248\u672c\u4e3a\u4f8b&#xff1a;<\/p>\n<p>conda install pytorch&#061;&#061;1.9.1 torchvision&#061;&#061;0.10.1 torchaudio&#061;&#061;0.9.1 cudatoolkit&#061;10.2 -c pytorch<\/p>\n<p>\u8be5\u547d\u4ee4\u4f1a\u5b89\u88c5 PyTorch 1.9.1&#xff0c;\u540c\u65f6\u5b89\u88c5\u4e0e\u5176\u517c\u5bb9\u7684 torchvision&#xff08;\u8ba1\u7b97\u673a\u89c6\u89c9\u5e93&#xff09;\u3001torchaudio&#xff08;\u97f3\u9891\u5904\u7406\u5e93&#xff09;&#xff0c;cudatoolkit&#061;10.2 \u7528\u4e8e\u6307\u5b9a CUDA \u5de5\u5177\u5305\u7248\u672c&#xff0c;-c pytorch \u8868\u793a\u4ece pytorch \u6e20\u9053\u83b7\u53d6\u5b89\u88c5\u5305\u3002<\/p>\n<h3>\u4e09\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u7b54<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u95ee\u9898 1&#xff1a;\u5b89\u88c5 PyTorch \u540e\u8fd0\u884c\u51fa\u73b0\u7248\u672c\u4e0d\u517c\u5bb9\u9519\u8bef<\/h4>\n<p>\u89e3\u7b54&#xff1a;\u5148\u68c0\u67e5 PyTorch \u4e0e Python \u7248\u672c\u662f\u5426\u5339\u914d\u3002\u82e5\u4e0d\u5339\u914d&#xff0c;\u5378\u8f7d\u5f53\u524d\u7248\u672c&#xff0c;\u91cd\u65b0\u5b89\u88c5\u7b26\u5408\u5bf9\u5e94\u5173\u7cfb\u7684\u7248\u672c\u7ec4\u5408\u3002\u540c\u65f6&#xff0c;\u786e\u4fdd\u5176\u4ed6\u4f9d\u8d56\u5e93\u4e5f\u4e0e PyTorch \u7248\u672c\u517c\u5bb9\u3002<\/p>\n<h4>&#xff08;\u4e8c&#xff09;\u95ee\u9898 2&#xff1a;\u60f3\u4f7f\u7528\u6700\u65b0 PyTorch \u7248\u672c&#xff0c;\u4f46\u9879\u76ee\u4f9d\u8d56\u65e7\u7248 Python<\/h4>\n<p>\u89e3\u7b54&#xff1a;\u5229\u7528 conda \u521b\u5efa\u591a\u4e2a\u73af\u5883&#xff0c;\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u5206\u522b\u8bbe\u7f6e\u6240\u9700\u7684 Python \u548c PyTorch \u7248\u672c&#xff0c;\u5b9e\u73b0\u4e0d\u540c\u7248\u672c\u9879\u76ee\u72ec\u7acb\u8fd0\u884c&#xff0c;\u907f\u514d\u73af\u5883\u51b2\u7a81\u3002<\/p>\n<h4>&#xff08;\u4e09&#xff09;\u95ee\u9898 3&#xff1a;\u5982\u4f55\u83b7\u53d6 PyTorch \u548c Python \u7248\u672c\u4fe1\u606f<\/h4>\n<p>\u89e3\u7b54&#xff1a;\u5728 Python \u89e3\u91ca\u5668\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u4ee3\u7801&#xff1a;<\/p>\n<p>import torch<br \/>\nprint(torch.__version__)  # \u8f93\u51faPyTorch\u7248\u672c<br \/>\nimport sys<br \/>\nprint(sys.version)  # \u8f93\u51faPython\u7248\u672c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb532\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf10\u6b21\u3002PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb_python \u7248\u672c\u548c\u5305\u5bf9\u5e94\u5173\u7cfb<\/p>\n","protected":false},"author":2,"featured_media":36958,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,152,50,207,86,3194],"topic":[],"class_list":["post-36959","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-python","tag-pytorch","tag-50","tag-207","tag-86","tag-3194"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/36959.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb532\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf10\u6b21\u3002PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb_python \u7248\u672c\u548c\u5305\u5bf9\u5e94\u5173\u7cfb\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/36959.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-12T17:04:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512170401-68222a0198557.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36959.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/36959.html\",\"name\":\"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-12T17:04:03+00:00\",\"dateModified\":\"2025-05-12T17:04:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/36959.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/36959.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36959.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/36959.html","og_locale":"zh_CN","og_type":"article","og_title":"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb532\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf10\u6b21\u3002PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb_python \u7248\u672c\u548c\u5305\u5bf9\u5e94\u5173\u7cfb","og_url":"https:\/\/www.wsisp.com\/helps\/36959.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-12T17:04:03+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512170401-68222a0198557.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/36959.html","url":"https:\/\/www.wsisp.com\/helps\/36959.html","name":"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-12T17:04:03+00:00","dateModified":"2025-05-12T17:04:03+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/36959.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/36959.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/36959.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"PyTorch \u7248\u672c\u3001torchvision \u7248\u672c\u548c Python \u7248\u672c\u7684\u5bf9\u5e94\u5173\u7cfb"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=36959"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36959\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/36958"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=36959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=36959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=36959"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=36959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}