{"id":5646218,"date":"2022-06-06T15:22:44","date_gmt":"2022-06-06T19:22:44","guid":{"rendered":"https:\/\/lightningaidev.wpengine.com\/?p=5646218"},"modified":"2022-09-10T11:45:11","modified_gmt":"2022-09-10T15:45:11","slug":"performance-notes-of-pytorch-support-for-m1-and-m2-gpus","status":"publish","type":"post","link":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/","title":{"rendered":"Performance Notes Of PyTorch Support for M1 and M2 GPUs"},"content":{"rendered":"<h2>Running PyTorch on the M1 and M2 GPU<\/h2>\n<p>In 2020, Apple released the first computers with the new ARM-based M1 chip, which has become known for its great performance and energy efficiency. While it was possible to run deep learning code via PyTorch or PyTorch Lightning on the M1\/M2 CPU, PyTorch just recently announced plans to add GPU support for ARM-based Mac processors (M1 &amp; M2).<\/p>\n<p>Some notes about the M1 GPU performance:<\/p>\n<ul>\n<li>I noticed that the convolutional networks need much more RAM when running them on a CPU or M1 GPU (compared to a CUDA GPU), and there may be issues regarding swapping. However, I made sure that training\u00a0<a href=\"https:\/\/twitter.com\/rasbt\/status\/1527115038720512000?s=20&amp;t=k1374Sdramu2rFp0EQGkxA\">the neural networks never exceeded 80% memory utilization<\/a>\u00a0on the MacBook Pro.<\/li>\n<li><a href=\"https:\/\/twitter.com\/DrCMcMaster\/status\/1527117188603461633?s=20&amp;t=k1374Sdramu2rFp0EQGkxA\">As suggested<\/a>, not maxing out the batch size on the M1 GPU runs could be another explanation. However, for fairness, I ran all training runs with a batch size of 32 \u2013 the 2080Ti and 1080Ti couldn\u2019t handle more due to their limited 11Gb VRAM.\u00a0<strong>Update:<\/strong>\u00a0I repeated the M1 Pro GPU run with a batch size of 64 and it was approximately 20% faster compared to a batch size of 32.<\/li>\n<\/ul>\n<p>If you are curious to learn more and see some early benchmarks, check out my article &#8220;Running PyTorch on the M1 GPU&#8221; here: <a href=\"https:\/\/sebastianraschka.com\/blog\/2022\/pytorch-m1-gpu.html\" target=\"_blank\" rel=\"noopener\"><u>https:\/\/sebastianraschka.com\/blog\/2022\/pytorch-m1-gpu.html<\/u><\/a><\/p>\n<p><em>By Sebastian Raschka, Lead AI Educator Lightning AI<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running PyTorch on the M1 and M2 GPU In 2020, Apple released the first computers with the new ARM-based M1 chip, which has become known for its great performance and energy efficiency. While it was possible to run deep learning code via PyTorch or PyTorch Lightning on the M1\/M2 CPU, PyTorch just recently announced plans<a class=\"excerpt-read-more\" href=\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\" title=\"ReadPerformance Notes Of PyTorch Support for M1 and M2 GPUs\">&#8230; Read more &raquo;<\/a><\/p>\n","protected":false},"author":16,"featured_media":5646258,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[105],"tags":[54,52,53,51],"glossary":[],"acf":{"hide_from_archive":null,"content_type":null,"code_embed":null,"code_shortcode":null,"custom_styles":null,"sticky":null,"additional_authors":null,"mathjax":null,"default_editor":null,"sections":null,"show_table_of_contents":null,"table_of_contents":null,"tabs":null,"tab_group":null},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Performance Notes Of PyTorch Support for M1 and M2 GPUs - Lightning AI<\/title>\n<meta name=\"description\" content=\"In this article from Sebastian Raschka, he reviews Apple&#039;s new M1 and M2 GPU and its support for PyTorch, along with some early benchmarks.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Performance Notes Of PyTorch Support for M1 and M2 GPUs - Lightning AI\" \/>\n<meta property=\"og:description\" content=\"In this article from Sebastian Raschka, he reviews Apple&#039;s new M1 and M2 GPU and its support for PyTorch, along with some early benchmarks.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\" \/>\n<meta property=\"og:site_name\" content=\"Lightning AI\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-06T19:22:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-10T15:45:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"JP Hennessy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@LightningAI\" \/>\n<meta name=\"twitter:site\" content=\"@LightningAI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JP Hennessy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\"},\"author\":{\"name\":\"JP Hennessy\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\"},\"headline\":\"Performance Notes Of PyTorch Support for M1 and M2 GPUs\",\"datePublished\":\"2022-06-06T19:22:44+00:00\",\"dateModified\":\"2022-09-10T15:45:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\"},\"wordCount\":237,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg\",\"keywords\":[\"Apple\",\"M1\",\"M2\",\"pytorch\"],\"articleSection\":[\"Community Discussions\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\",\"url\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\",\"name\":\"Performance Notes Of PyTorch Support for M1 and M2 GPUs - Lightning AI\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg\",\"datePublished\":\"2022-06-06T19:22:44+00:00\",\"dateModified\":\"2022-09-10T15:45:11+00:00\",\"description\":\"In this article from Sebastian Raschka, he reviews Apple's new M1 and M2 GPU and its support for PyTorch, along with some early benchmarks.\",\"breadcrumb\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg\",\"width\":2560,\"height\":1280,\"caption\":\"Running PyTorch on the M1 or M2 GPU\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lightning.ai\/pages\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Performance Notes Of PyTorch Support for M1 and M2 GPUs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lightning.ai\/pages\/#website\",\"url\":\"https:\/\/lightning.ai\/pages\/\",\"name\":\"Lightning AI\",\"description\":\"The platform for teams to build AI.\",\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lightning.ai\/pages\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\",\"name\":\"Lightning AI\",\"url\":\"https:\/\/lightning.ai\/pages\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png\",\"width\":1744,\"height\":856,\"caption\":\"Lightning AI\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/LightningAI\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\",\"name\":\"JP Hennessy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g\",\"caption\":\"JP Hennessy\"},\"url\":\"https:\/\/lightning.ai\/pages\/author\/jplightning-ai\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Performance Notes Of PyTorch Support for M1 and M2 GPUs - Lightning AI","description":"In this article from Sebastian Raschka, he reviews Apple's new M1 and M2 GPU and its support for PyTorch, along with some early benchmarks.","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:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/","og_locale":"en_US","og_type":"article","og_title":"Performance Notes Of PyTorch Support for M1 and M2 GPUs - Lightning AI","og_description":"In this article from Sebastian Raschka, he reviews Apple's new M1 and M2 GPU and its support for PyTorch, along with some early benchmarks.","og_url":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/","og_site_name":"Lightning AI","article_published_time":"2022-06-06T19:22:44+00:00","article_modified_time":"2022-09-10T15:45:11+00:00","og_image":[{"width":2560,"height":1280,"url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg","type":"image\/jpeg"}],"author":"JP Hennessy","twitter_card":"summary_large_image","twitter_creator":"@LightningAI","twitter_site":"@LightningAI","twitter_misc":{"Written by":"JP Hennessy","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#article","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/"},"author":{"name":"JP Hennessy","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6"},"headline":"Performance Notes Of PyTorch Support for M1 and M2 GPUs","datePublished":"2022-06-06T19:22:44+00:00","dateModified":"2022-09-10T15:45:11+00:00","mainEntityOfPage":{"@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/"},"wordCount":237,"commentCount":0,"publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"image":{"@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg","keywords":["Apple","M1","M2","pytorch"],"articleSection":["Community Discussions"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/","url":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/","name":"Performance Notes Of PyTorch Support for M1 and M2 GPUs - Lightning AI","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage"},"image":{"@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg","datePublished":"2022-06-06T19:22:44+00:00","dateModified":"2022-09-10T15:45:11+00:00","description":"In this article from Sebastian Raschka, he reviews Apple's new M1 and M2 GPU and its support for PyTorch, along with some early benchmarks.","breadcrumb":{"@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#primaryimage","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/07\/m1-m2-pytorch.jpg","width":2560,"height":1280,"caption":"Running PyTorch on the M1 or M2 GPU"},{"@type":"BreadcrumbList","@id":"https:\/\/lightning.ai\/pages\/community\/community-discussions\/performance-notes-of-pytorch-support-for-m1-and-m2-gpus\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lightning.ai\/pages\/"},{"@type":"ListItem","position":2,"name":"Performance Notes Of PyTorch Support for M1 and M2 GPUs"}]},{"@type":"WebSite","@id":"https:\/\/lightning.ai\/pages\/#website","url":"https:\/\/lightning.ai\/pages\/","name":"Lightning AI","description":"The platform for teams to build AI.","publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lightning.ai\/pages\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/lightning.ai\/pages\/#organization","name":"Lightning AI","url":"https:\/\/lightning.ai\/pages\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png","width":1744,"height":856,"caption":"Lightning AI"},"image":{"@id":"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/LightningAI"]},{"@type":"Person","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6","name":"JP Hennessy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g","caption":"JP Hennessy"},"url":"https:\/\/lightning.ai\/pages\/author\/jplightning-ai\/"}]}},"_links":{"self":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5646218"}],"collection":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/comments?post=5646218"}],"version-history":[{"count":0,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5646218\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media\/5646258"}],"wp:attachment":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media?parent=5646218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/categories?post=5646218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/tags?post=5646218"},{"taxonomy":"glossary","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/glossary?post=5646218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}