Cuda Net | Cuda Crash Course (v2): Visual Studio 2019 Setup


Subscribe Here





Cuda Crash Course (v2): Visual Studio 2019 Setup


Hey, everyone! I’m Nick and welcome to version Two of CUDA crash course, so in version, two of this series we’re going to be fixing up some of the stuff from Version 1 and introducing some new concepts, some more modern C++ style code, as well as switching over from stuff like Visual Studio 2017 to Visual Studio 2019 So specifically in this video, we’ll be showing the setup guide for Visual Studio 2019 So let’s go ahead and get started, so the first thing we need, of course, is Visual Studio. So if you Google around for Visual Studio 2019 you should find this page, so I just found it at Visual Studio Microsoft Comm Slash vs. And I’m gonna be using Visual Studio community 2000 I already have it downloaded, so if I go ahead and just look for a Visual Studio installer. It should pop up or it should be. Maybe in your downloads folder or wherever you downloaded it to, so in this case, it looks like this for me, but that’s because I’ve already installed it. If you’re installing it for the first time, it will probably look something more like this, right, so from here, right, it’ll ask you all the things you want to install along with. Visual Studio 2019 so if you want stuff for data storage and processing for Linux development of C++ for Python development, you’re free to download that. All I looked at, though, or selected was desktop development with C++, and then at the bottom, right, it says install while downloading. Alright so so I just clicked on that, but since I already have it installed, we’ll leave it there. So the next thing you’ll want. Of course, is the actual CUDA 10.1 toolkit, so lets. Go ahead and kind of reset this page here, so for us, so if you Google for that, it’s also at developer Batten video comm, such code, it downloads since we’re using Windows, we’ll select Windows x86 64 and I’m using version 10 I’m also using the local installer, so that’ll be the one that you’ll want to select most likely. And then all you have to do. Is these very simple instructions? Double click the executable and then follow the on-screen prompts, so there’ll be some restart, so you’ll have to do between the visual studio installation and the CUDA toolkit installation after you’ve installed Visual Studio. Just install the CUDA toolkit. The CUDA toolkit doesn’t just in solve, it could have toolkit, but it’ll also install everything you need inside of Visual Studio for CUDA development. So there isn’t one of those nice, you know, buttons to click as far as CUDA development goes on that on a Visual Studio installer that happens through the installation of the CUDA toolkit. Here, alright, so from there, let’s go ahead and open up visual studio, so I’ll open up visual studio 2019 and the first thing we’ll do is we’ll go to create a new project and at the very bottom or somewhere in here you’ll find could a 10.1 runtime, so let’s just click. Next, we’ll give it a name. It will just call this a sample and then project. Alright, so you can place a solution and the product in the same directory or you can give it the solution, a different name. You can also select exactly where you want this product to be stored. All right, then we select create, and this will actually give you a sample project to work with so it does a very simple thing. It just adds two arrays together it’s an array with one two, three, four five and an and an array with ten 20 30 40 50 right, and then it will accumulate the results in another array called C. Alright, so so if we can go ahead and build this project, So if I right, click sample project, and then I click build. It will build the project, so this building compiles a project for us and then we can go ahead and either click run right here, and you’ll see, it’ll prompt. Pull up something that shows a if you add 1 2 3 4 5 with 10 20 30 40 50 you get the expected 11 22 33 44 55 Okay, so that’s not terribly interesting, and also we don’t usually want all this code. We don’t want to have to go through and go in here and delete everything and start from scratch every single time. I’d have to do that to start from scratch. Usually we don’t want this this extra code in here. It’s just kind of distraction, so what, we’ll go ahead and do is well. Close this out, so we’ll close the solution and then we’ll create a new project clone or check out the code from someplace else In this case. We’ll, just look at creating a new project. It will be an empty project. Look like next and we’ll just call it empty project, right and then. I’ll press create so now we have a blank project, nothing in it, and there’s nothing, but nothing’s been specified yet. So the first thing we’ll want to do is we’ll go ahead and do build dependencies, so I’ll right-click on the project. I’ll go to build dependencies, build customizations, and then you should have something like could a ten-point one up here, so we’re doing a cuda project, so we want Coda 10.12 be a build dependency, and there’s a whole bunch of our and there’s a bunch of other stuff in here. We don’t need to worry about that. Just make sure you select the CUDA version. Then we’ll click, OK, and then the next thing we’ll want to do is edit the properties in here. So important thing to keep in mind is that you can change the properties for different ways that you’re going to be building your program, so there’s a release and debug or all configurations, and that corresponds with up here. You see, you’ve got, you know, Debug, and then you’ve got, you know, x86 or x64 so for the platform, so you need to make sure that if you’re changing your configurations for Debug, write and say x64 but over here, you have it set to say, maybe release the next 86 Right, you might have a mismatch there, so just make sure that if you meaning to change some properties in here, you’re matching it up with what you’re actually compiling with or what you have set in your editor. So in this case, we’ll just do release in x64 and then. I’ll go to CUDA C++. So the first thing I want to do is target machine platform. It’s not a 32-bit machine. It’s a 64-bit one, so I’ll want to change that, and I’ll click apply, then the next thing that I’ll want to do is I’ll go in here to the linker, and then I’ll go to general look at input rather and then input, it says additional dependencies, and so we’ll go into that a little bit later. What we need to change there, but first let’s go ahead and just make a source file, so we’ll go ahead and add new item, and in this case, we can go down to. Nvidia CUDA 10.1 Or whatever your CUDA version is and we can select code and either a file or a header. Let’s do a file, so we’ll just call this test and so add it and then let’s make a main function so INT main and we’ll have a very simple. CUDA program here. I’ll create an integer pointer a and then I will call CUDA malloc pass in the address of a and I’ll say I want a hundred bytes on the GPU, and then I’ll just free that memory right after I allocate it, so Ill free a as well in return zero, we’ll go more in depth into, you know. The basics of CUDA programs and later episodes, we’ll just show some of the common build problems that people run into so you may run into something like this, where you know you’ll get this red underline, saying, identify our. Cuda malloc is undefined, But this kind of makes sense because we haven’t defined a function called CUDA malloc. And we haven’t included any headers yet, So it just can’t figure out, you know? What is the interface for cudamalloc? So in order to get rid of these, this squiggly red line will need to include a header and this header is going to be cuda. Runtime DOT H now could have runtime DOT H. How has all of our runtime API calls it will you’ll be using so. CUDA Malik CUDA malloc managed CUDA free prefetching, API calls, etc. So in this case, it gets rid of the red, highlighting, so we’ll save it there, okay, so that’s the basics of getting rid of the intellisense warnings, so the next thing that we’ll want to do. Is you know what happens we build this? So let’s go ahead and build the project notice. The first thing we didn’t change. We have to make sure that we are. We make sure we match. Whatever our device properties were so our properties right to be set, so we set this for release in x64 So if we look down here, you know, you see, we have some problems, right, so let’s go ahead and just change this to release and then x64 because that’s where we changed it to be for a 64-bit machine. Let’s go ahead and rebuild this. So if we’ve rebuilt it, we see that we got rid of that one error, but now we have a whole bunch of different errors, right, we’ve made progress. We’ve got past at least one error so here, It says a bunch of these linked 2001 errors and then a link 1120 error, the Lake 1120 error just says how many linker problems did you have so said five unresolved externals and then these individual ones are are unresolved external symbols. So when you’re compiling some code, there’s actually a number of steps it goes on. There’s pre-processing, which is where we find. Say this file that we’re including. Then we paste it right there, right, wherever the include statement as then after that goes compilation, so we have a problem here. Their careers later on, which is during the linking step, so we’re using something called clear Malloc, but the actual implementation of CUDA malloc doesn’t exist inside of CUDA run times H. It actually occurs inside of the CUDA runtime library and so that’s what these unresolved external symbols are. So it’s basically saying, okay. I know what a function looks like as far as its interface, but I don’t actually have the implementation. The implementation is actually in a library so all these external symbol errors can be fixed if we go into properties, which I kind of hinted at earlier, so if under properties, so let’s go ahead and just kind of go so under configuration and then under linker over here and then under input, we’ll need an additional dependency here, so I’ll need to add the library where CUDA malloc is actually implemented, and CUDA free is actually implemented so well. Go ahead and click there. I’ll click Edit and I’ll add one thing, Which is food art Dot Lib. So the Ku dart just stands for cuda artis of cuda runtime, dot Lib. So that’s the library where they could have Runtime is actually implemented. And I’ll click, OK? I’ll click apply and then I’ll do OK again. And now if I rebuild the project, you see, there’s not going to be any errors, so I just need to make sure that I’m linking. It’s the crew to Runtime library this. This also goes if we’re using any of the other libraries for Courte with along with CUDA. So if we want to use something like who ran or KU DNN, so or coop loss. If you want those highly optimized libraries, we’ll need to also change on right-click properties and under this additional dependencies inside of our linker options, we would put something like two Rand or Ku DNN or Ku sparse in there, if were using those libraries. And then if we run this, it doesn’t do anything exciting. It just goes ahead and exits because it just allocates memory and then immediately freeze it. Alright, so that’s the basics of getting started with Visual Studio 2019 If you’re interested in any of the code for this series, it’ll be located at Github column. Such coffee before Arch. So that’s this page right here, and then we’ve got CUDA programming so will will have two branches here, so all the original code from version 1 of the series is located on the first one branch. All the new code will be located on the Master Branch. So if you just go to the site that will be the code for version 2 of the series. All right, so that’s gonna go ahead and do it for today. It’s always I’m Nick, and I hope you have a nice day.

0.3.0 | Wor Build 0.3.0 Installation Guide

Transcript: [MUSIC] Okay, so in this video? I want to take a look at the new windows on Raspberry Pi build 0.3.0 and this is the latest version. It's just been released today and this version you have to build by yourself. You have to get your own whim, and then you...

read more