{"id":1379,"date":"2023-04-17T06:54:07","date_gmt":"2023-04-17T06:54:07","guid":{"rendered":"http:\/\/tiemensfamily.com\/timoncs\/?p=1379"},"modified":"2023-04-18T00:29:22","modified_gmt":"2023-04-18T00:29:22","slug":"aws-ec2-gpu-instance-comparison","status":"publish","type":"post","link":"https:\/\/tiemensfamily.com\/timoncs\/2023\/04\/17\/aws-ec2-gpu-instance-comparison\/","title":{"rendered":"AWS EC2 GPU instance comparison"},"content":{"rendered":"\n<p>These are the results from running the <a href=\"https:\/\/github.com\/timtiemens\/ml-style-transfer\">ml-style-transfer<\/a> project on three different AWS EC2 instance types.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Instance Name<\/strong><\/td><td><strong>$Cost\/hour<\/strong><\/td><td><strong>250 epochs<\/strong><\/td><td><strong>2,500 epochs<\/strong><\/td><td><strong>50,000 epochs<\/strong><\/td><\/tr><tr><td>p3.2xlarge<\/td><td>$3.06<\/td><td>14s<br>$0.0119<\/td><td>55s<br>$0.0468<\/td><td>928s<br>$0.7888<\/td><\/tr><tr><td>t2.large<\/td><td>$0.093<\/td><td>849s<br>$0.0219<\/td><td>14,676s<br>$0.3791<\/td><td>293,520s<br>(extrapolated)<br>$7.5826<\/td><\/tr><tr><td>c5.4xlarge<\/td><td>$0.68<\/td><td>221s<br>$0.0417<\/td><td>2,152s<br>$0.4065<\/td><td>43,040<br>(extrapolated)<br>$8.1298<\/td><\/tr><\/tbody><\/table><figcaption>Comparing p3.2xlarge GPU with t2.large non-GPU<\/figcaption><\/figure>\n\n\n\n<p>The <a href=\"https:\/\/aws.amazon.com\/ec2\/instance-types\/p3\/\">p3.2xlarge<\/a> is 32x more expensive per hour.  Yet, for the 2,500 epoch tests, it is 266x faster, which combines to be 8x more cost-effective (e.g. $0.05 versus $0.40 for 2,500 epochs).  <\/p>\n\n\n\n<p>The p3.2xlarge also gets results faster (wall clock) &#8211; the 50,000 epoch run on p3.2xlarge only took 15 minutes wall clock, yet the projected run on t2.large is 4,892 minutes (over 3 days).<\/p>\n\n\n\n<p>The c5.4xlarge is a &#8220;compute optimized&#8221; &#8211; large vCPU, large RAM.  It is 7x the hourly price of the t2.large, and on the 2,500 epoch test, delivers about that much wall clock improvement &#8211; so, basically the same cost, but 7x faster delivery of results.<\/p>\n\n\n\n<p>Note: the total test time was approximately 40 minutes on the p3.2xlarge ($2.04) and 280 minutes on the t2.large ($0.44).  But, for a mere 5x total cost difference, the p3.2xlarge performed a 50,000 epoch run that would have taken forever on the t2.large.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>In contrast, purchasing a RTX 3080Ti for $900 and using it for the 2,500 epoch run took 16 seconds (which is barely slower than the current record-holder p3.2xlarge at 14 seconds).<\/p>\n\n\n\n<p>Next up is to upgrade my AWS account to allow &#8220;spot&#8221; pricing for p3.2xlarge &#8211; if Amazon will allow it for my non-commercial account.  The $3.06 on-demand price seems to drop to about $1.01 for spot instances.   Update (1 day later): &#8220;We have approved and processed your service quota increase request&#8221;.  So my &#8220;EC2->Limits->All P Spot Instance Requests now says &#8220;8 vCPUs&#8221;, which is enough for one p3.2xlarge instance.<\/p>\n\n\n\n<p>Just FYI: when that AMI is run under a non-GPU machine type, the first run takes an extra 5+ minutes, as the system says &#8220;Matplotlib is building the font cache; this may take a moment.&#8221;  It only does this the first run.  (This is an example of a thing that cause differences in &#8220;python elapsed time&#8221; and &#8220;wall clock elapsed time&#8221;.)<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>These are the results from running the ml-style-transfer project on three different AWS EC2 instance types. Instance Name $Cost\/hour 250 epochs 2,500 epochs 50,000 epochs p3.2xlarge $3.06 14s$0.0119 55s$0.0468 928s$0.7888 t2.large $0.093 849s$0.0219 14,676s$0.3791 293,520s(extrapolated)$7.5826 c5.4xlarge $0.68 221s$0.0417 2,152s$0.4065 43,040(extrapolated)$8.1298 &hellip; <a href=\"https:\/\/tiemensfamily.com\/timoncs\/2023\/04\/17\/aws-ec2-gpu-instance-comparison\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[17,18],"tags":[],"_links":{"self":[{"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/posts\/1379"}],"collection":[{"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/comments?post=1379"}],"version-history":[{"count":8,"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/posts\/1379\/revisions"}],"predecessor-version":[{"id":1387,"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/posts\/1379\/revisions\/1387"}],"wp:attachment":[{"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/media?parent=1379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/categories?post=1379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tiemensfamily.com\/timoncs\/wp-json\/wp\/v2\/tags?post=1379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}