{"id":197,"date":"2018-04-24T02:18:20","date_gmt":"2018-04-23T18:18:20","guid":{"rendered":"https:\/\/codestrian.com\/?p=197"},"modified":"2018-07-02T10:33:01","modified_gmt":"2018-07-02T02:33:01","slug":"integrating-cuda-with-visual-studio-2017","status":"publish","type":"post","link":"https:\/\/codestrian.com\/index.php\/2018\/04\/24\/integrating-cuda-with-visual-studio-2017\/","title":{"rendered":"Integrating CUDA with Visual Studio 2017"},"content":{"rendered":"<p>Recently, I was tasked to speed up an algorithm using the CUDA framework. And I ran into issues getting the CUDA project to compile in the VS2017. After spending all the time searching all over the internet for the solutions\/guides, I have decided to put up a guide myself so that someone else will benefit from it. Let's get started!<\/p>\n<h1>Software<\/h1>\n<p><strong>So first of all, you will need to download all the softwares that I have listed below:<\/strong><br \/>\n<a href=\"https:\/\/www.visualstudio.com\/downloads\/\">Visual Studio 2017<\/a><br \/>\nCUDA <a href=\"https:\/\/developer.nvidia.com\/cuda-90-download-archive\">9.0<\/a>\/<a href=\"https:\/\/developer.nvidia.com\/cuda-downloads\">9.1<\/a><\/p>\n<h1>CUDA Library Setup<\/h1>\n<p>Copy the files<br \/>\nfrom <strong><em>C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.1\\extras\\visual_studio_integration\\MSBuildExtensions<\/em><\/strong><br \/>\n<a href=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-201 size-large\" src=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2-1024x575.jpg\" alt=\"\" width=\"1024\" height=\"575\" srcset=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2-1024x575.jpg 1024w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2-300x168.jpg 300w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2-768x431.jpg 768w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2-200x112.jpg 200w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda2.jpg 1128w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><br \/>\nto <strong><em>C:\\Program Files (x86)\\MSBuild\\Microsoft.Cpp\\v4.0\\v140\\BuildCustomizations<\/em><\/strong><br \/>\n<a href=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-202\" src=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1-1024x578.jpg\" alt=\"\" width=\"1024\" height=\"578\" srcset=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1-1024x578.jpg 1024w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1-300x169.jpg 300w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1-768x433.jpg 768w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1-200x113.jpg 200w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/cuda1.jpg 1131w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h1>Visual Studio 2017 Setup<\/h1>\n<p>After you have installed visual studio 2017, you will realize that a new CUDA project is not able to compile. That is because there are still some missing dependencies. At the point of writing this article, the latest CUDA versions 9.0\/9.1 are not compatible with Visual Studio 2017 by default. For it to be able to compile, it requires the VS2015 toolset and an older version of Win 10 SDK.<br \/>\n<a href=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1.jpg\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-199 size-large\" src=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1-1024x521.jpg\" alt=\"\" width=\"1024\" height=\"521\" srcset=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1-1024x521.jpg 1024w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1-300x153.jpg 300w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1-768x390.jpg 768w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1-200x102.jpg 200w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs1.jpg 1255w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><br \/>\nFirst, Select <em><strong>VC++ 2015.3 v140 toolset for desktop (x86,x64)<\/strong><\/em> from the list<br \/>\n<a href=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-200 size-large\" src=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2-1024x521.jpg\" alt=\"\" width=\"1024\" height=\"521\" srcset=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2-1024x521.jpg 1024w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2-300x153.jpg 300w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2-768x391.jpg 768w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2-200x102.jpg 200w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs2.jpg 1252w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><br \/>\nNext, scroll to the bottom and select <em><strong>Windows 10 SDK(10.0.15063.0) for Desktop C++ [x86 and x64]<\/strong><\/em><br \/>\nAfter we have installed the VS2015 toolset and Win10 SDK, we will need to update our project settings to use the VS2015 toolset instead of the VS2017 toolset.<br \/>\nRight click your project and go to <em>Properties<\/em>. Under the <em>General<\/em> tab, change the platform toolset to <em><strong>Visual Studio 2015(v140)<\/strong><\/em><br \/>\n<a href=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-204\" src=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs3.png\" alt=\"\" width=\"840\" height=\"595\" srcset=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs3.png 840w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs3-300x213.png 300w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs3-768x544.png 768w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs3-200x142.png 200w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/a>Now you may press Ctrl+F5 to run your project. And it should compile and run successfully.<br \/>\n<a href=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs4.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-205\" src=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs4.jpg\" alt=\"\" width=\"851\" height=\"137\" srcset=\"https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs4.jpg 851w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs4-300x48.jpg 300w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs4-768x124.jpg 768w, https:\/\/codestrian.com\/wp-content\/uploads\/2018\/04\/vs4-200x32.jpg 200w\" sizes=\"(max-width: 851px) 100vw, 851px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I was tasked to speed up an algorithm using the CUDA framework. And I ran into issues getting the CUDA project to compile in the VS2017. After spending all the time searching all over the internet for the solutions\/guides, I have decided to put up a guide myself so [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[29,30],"_links":{"self":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts\/197"}],"collection":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/comments?post=197"}],"version-history":[{"count":7,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts\/197\/revisions"}],"predecessor-version":[{"id":291,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/posts\/197\/revisions\/291"}],"wp:attachment":[{"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/media?parent=197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/categories?post=197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codestrian.com\/index.php\/wp-json\/wp\/v2\/tags?post=197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}