Something More for Research

Explorer of Research #HEMBAD

CUDA Installation On VS 2010

Posted by Hemprasad Y. Badgujar on October 12, 2012


CUDA in Visual Studio 2010

CUDA 4.0 and later versions work fine with Visual Studio 2010. The only noticeable change from Visual Studio 2008 is that Build Rules are replaced by Build Customizations in Visual Studio 2010.

Adding CUDA capability to any Visual Studio 2010 solution is easy:

1. Install the latest version of CUDA Toolkit.
2. Right-click the project name in Solution Explorer and choose Build Customizations.
3. The Visual C++ Build Customization Files dialog should display the one or more CUDA toolkits you have installed. Choose the one you want to use and click OK.
4. To change the CUDA compile options, in the project properties look for the section CUDA C/C++.

You should be able to build CUDA source files and run CUDA programs with these changes.

As Well As

Nine Easy Steps

Make sure CUDA 4.2 SDK is installed from here, fire up Visual Studio 2010 and…

1. Create a new Win32 Console Project

2. Choose ‘Empty Project’

Choose ‘Empty Project’ setting from new project window. We will add our source files later on.

3. Add your CU file

Add a new C++ file with the extension .cu. Files with cu extension are processed with nvcc.exe nvidia compiler driver and are sent to VS2008 C compiler after processing.

4. Check Build Customizations

CUDA SDK setup installs build customizations for VS2010. They are installed in program files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations. If the selected files are not there, you can download them from my blog: CUDA 3.2 Build Rules

5. Change Platform Toolset

Change Platform Toolset to v90. With CUDA SDK 3.2, VS2010 IDE is supported through custom build targets which in turn use the C/C++ compiler distributed with VS2008. When you are using VS2010 and compiling a CUDA project, using the .NET4 compiler is not supported (yet) by nVidia. So you need to have the C/C++ compiler distributed with VS2008.

Change toolset for the project from project property page.

6. Change CU File Type

Change Item Type of the added CU file to CUDA C/C++ from file property page.

7. Select Build Customization

Select build customization from Project menu. Check CUDA 3.2.

8. Add CUDA Libraries

Add libraries that are used with CUDA run-time. In Project Property Page, add cuda.lib and cudart.lib to
Linker->Input->Additional Dependencies.

9. Compile Your First CUDA Capable Program

Enter the following code in the cu file and then compile the project.

 Collapse | Copy Code
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
#include <cuda_runtime.h>
int main( int argc, char** argv )
{
        float* d_A;
        cudaMalloc( (void**) &d_A, 100 * sizeof(float) );
        cudaFree( d_A );
        return 0;
}

Points of Interest

There should be VS2010 project and item templates for CUDA 3.2 in the SDK. Maybe there will be in the future versions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Extracts from a Personal Diary

dedicated to the life of a silent girl who eventually learnt to open up

Num3ri v 2.0

I miei numeri - seconda versione

ThuyDX

Just another WordPress.com site

Algunos Intereses de Abraham Zamudio Chauca

Matematica, Linux , Programacion Serial , Programacion Paralela (CPU - GPU) , Cluster de Computadores , Software Cientifico

josephdung

thoughts...

Tech_Raj

A great WordPress.com site

Travel tips

Travel tips

Experience the real life.....!!!

Shurwaat achi honi chahiye ...

Ronzii's Blog

Just your average geek's blog

Karan Jitendra Thakkar

Everything I think. Everything I do. Right here.

VentureBeat

News About Tech, Money and Innovation

Chetan Solanki

Helpful to u, if u need it.....

ScreenCrush

Explorer of Research #HEMBAD

managedCUDA

Explorer of Research #HEMBAD

siddheshsathe

A great WordPress.com site

Ari's

This is My Space so Dont Mess With IT !!

%d bloggers like this: