{"id":32,"date":"2023-12-18T15:04:14","date_gmt":"2023-12-18T07:04:14","guid":{"rendered":"http:\/\/blog.thirdbody.cn\/?p=32"},"modified":"2023-12-18T15:04:41","modified_gmt":"2023-12-18T07:04:41","slug":"32","status":"publish","type":"post","link":"http:\/\/blog.thirdbody.cn\/index.php\/2023\/12\/18\/32\/","title":{"rendered":"ubuntu\u914d\u7f6ecuda\u73af\u5883\u4e09\uff1a\u5b89\u88c5PyTorch"},"content":{"rendered":"<h3>\u5b89\u88c5GPU\u7248\u672c\u7684PyTorch<\/h3>\n<p>\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee[PyTorch\u5b98\u7f51]()\u751f\u6210\u5b89\u88c5\u547d\u4ee4\uff0c\u4f46\u662f\u4e0b\u8f7d\u901f\u5ea6\u8f83\u6162<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/pictures-1258408207.cos.ap-nanjing.myqcloud.com\/cuda%E5%92%8Ccudnn%E5%AE%89%E8%A3%85\/pytorchDownloadMl.png\" alt=\"\" \/><\/p>\n<p>\u6b64\u5904\uff0c\u53ef\u4ee5\u5230\u6b64<a href=\"https:\/\/download.pytorch.org\/whl\/torch\/\">\u94fe\u63a5<\/a>\u4e0b\u8f7d\u5bf9\u5e94\u7684\u79bb\u7ebf\u5305\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/pictures-1258408207.cos.ap-nanjing.myqcloud.com\/cuda%E5%92%8Ccudnn%E5%AE%89%E8%A3%85\/pytorchLx.png\" alt=\"\" \/><\/p>\n<p>\u4e0b\u8f7d\u597d\u79bb\u7ebf\u5305\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<pre><code class=\"language-bash\">pip install torch-1.7.0+cu101-cp38-cp38-linux_x86_64.whl -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\/<\/code><\/pre>\n<p>\u518d\u5b89\u88c5\u5176\u4ed6\u7684\u5e93(\u6309\u9700\u5b89\u88c5)<\/p>\n<pre><code class=\"language-bash\">pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 torchaudio==0.7.0 -f https:\/\/download.pytorch.org\/whl\/torch_stable.html<\/code><\/pre>\n<p>\u6700\u540e\u53ef\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u6d4b\u8bd5\u73af\u5883\u662f\u5426\u5b89\u88c5\u6210\u529f<\/p>\n<pre><code class=\"language-python\">import torch\nimport torchvision\n\nif __name__ == &quot;__main__&quot;:\n    print(torch.__version__)  # \u67e5\u770btorch\u5f53\u524d\u7248\u672c\u53f7\n    print(torchvision.__version__)\n\n    # \u67e5\u770bCUDA\u7248\u672c\u53f7\uff1a\n    print(torch.version.cuda)  # \u7f16\u8bd1\u5f53\u524d\u7248\u672c\u7684torch\u4f7f\u7528\u7684cuda\u7248\u672c\u53f7\n\n    # \u6d4b\u8bd5Cudnn\u662f\u5426\u5b89\u88c5\u6210\u529f\n    from torch.backends import cudnn\n    print(cudnn.is_available())\n\n    # \u662f\u5426GPU\u53ef\u7528\n    print(torch.cuda.is_available())  # \u67e5\u770b\u5f53\u524dcuda\u662f\u5426\u53ef\u7528\u4e8e\u5f53\u524d\u7248\u672c\u7684Torch\uff0c\u5982\u679c\u8f93\u51faTrue\uff0c\u5219\u8868\u793a\u53ef\u7528\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5GPU\u7248\u672c\u7684PyTorch \u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee[PyTorch\u5b98\u7f51]()\u751f\u6210\u5b89\u88c5\u547d\u4ee4\uff0c\u4f46\u662f\u4e0b\u8f7d\u901f\u5ea6\u8f83\u6162 \u6b64\u5904\uff0c\u53ef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":33,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4,5,6],"class_list":["post-32","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-env_config","tag-cuda","tag-pytorch","tag-ubuntu"],"_links":{"self":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":2,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":35,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/posts\/32\/revisions\/35"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/media\/33"}],"wp:attachment":[{"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.thirdbody.cn\/index.php\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}