CUDA 3.2 and Visual Studio 2010

Software:
Visual Studio 2010
Windows 6.1 SDK (because at the moment CUDA toolkit doesn’t support directly Visual Studio 2010 and at compile time it’s required VC 9.0 compiler to compile cu file -.-")
Nsight 1.5 Standard (include CUDA toolkit 3.2)
NVIDIA Driver 260.99
Windows Server 2008 R2

This is very boring… I cannot build CUDA samples or my simple CUDA kernel, these are steps that I have followed:

  • Create new C++ blank project;
  • Add cpp file with main function;
  • Add cu file (copied form samples or wrote from scratch);
  • Change platform toolset from V100 to V90;
  • Set Item Type of cu file to CUDA C/C++;
  • Build and this is error: Error 1 error MSB3721: The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe” -gencode=arch=compute_10,code="sm_10,compute_10" --use-local-env --cl-version 2008 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include” -G0 --keep-dir “Debug\” -maxrregcount=32 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler “/EHsc /nologo /Od /Zi /MDd " -o “Debug\Test.obj” “C:\Users\Paolo\documents\visual studio 2010\Projects\TestCUDA\TestCUDA\Test.cu”” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.2.targets 272 4 TestCUDA2

What is wrong??

Other questions:

  1. Why did not NVIDIA developers compile CUDA 3.2 with VC10.0 instead of VC9.0 -.-"??
  2. Nsight is great tool, but why did not Nsight developers (or NVIDIA developers) develop a simple template to add cu file with IntelliSense support in Visual Studio -.-" -.-"?? IntelliSense does not work well in Visual Studio with cu file (global is not recognized etc.)

Best practices in software installation: install everything with few clicks without to bore poor developer with useless configuration software steps. My first impression about CUDA development environment… it is negative. -.-"

Software:
Visual Studio 2010
Windows 6.1 SDK (because at the moment CUDA toolkit doesn’t support directly Visual Studio 2010 and at compile time it’s required VC 9.0 compiler to compile cu file -.-")
Nsight 1.5 Standard (include CUDA toolkit 3.2)
NVIDIA Driver 260.99
Windows Server 2008 R2

This is very boring… I cannot build CUDA samples or my simple CUDA kernel, these are steps that I have followed:

  • Create new C++ blank project;
  • Add cpp file with main function;
  • Add cu file (copied form samples or wrote from scratch);
  • Change platform toolset from V100 to V90;
  • Set Item Type of cu file to CUDA C/C++;
  • Build and this is error: Error 1 error MSB3721: The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe” -gencode=arch=compute_10,code="sm_10,compute_10" --use-local-env --cl-version 2008 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include” -G0 --keep-dir “Debug\” -maxrregcount=32 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler “/EHsc /nologo /Od /Zi /MDd " -o “Debug\Test.obj” “C:\Users\Paolo\documents\visual studio 2010\Projects\TestCUDA\TestCUDA\Test.cu”” exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.2.targets 272 4 TestCUDA2

What is wrong??

Other questions:

  1. Why did not NVIDIA developers compile CUDA 3.2 with VC10.0 instead of VC9.0 -.-"??
  2. Nsight is great tool, but why did not Nsight developers (or NVIDIA developers) develop a simple template to add cu file with IntelliSense support in Visual Studio -.-" -.-"?? IntelliSense does not work well in Visual Studio with cu file (global is not recognized etc.)

Best practices in software installation: install everything with few clicks without to bore poor developer with useless configuration software steps. My first impression about CUDA development environment… it is negative. -.-"

Solution:

  • install Visual Studio 2008 Express SP1 (I don’t understand why Windows 6.1 SDK doesn’t accomplish task of Visual Studio 2008 compiler);

  • install gpucomputingsdk 32 bit and leave Visual Studio 2010 for other tasks looooooooooool.

Thanks for help -.-"

Solution:

  • install Visual Studio 2008 Express SP1 (I don’t understand why Windows 6.1 SDK doesn’t accomplish task of Visual Studio 2008 compiler);

  • install gpucomputingsdk 32 bit and leave Visual Studio 2010 for other tasks looooooooooool.

Thanks for help -.-"

Change V100 to V90. Great. In other words change back to visual C++ 2008.
I find it very misleading and deceitful for anyone to claim cuda supports visual studio 2010.

(If I speak in ignorance, please prove me wrong!!)

My workaround: Use the driver api with vs2010 and use nvcc with 2008 to create the .ptx files.
Better than dealing with the rest of this mess.

Change V100 to V90. Great. In other words change back to visual C++ 2008.
I find it very misleading and deceitful for anyone to claim cuda supports visual studio 2010.

(If I speak in ignorance, please prove me wrong!!)

My workaround: Use the driver api with vs2010 and use nvcc with 2008 to create the .ptx files.
Better than dealing with the rest of this mess.

If I uderstood well, to compile cuda application with VC++ 2010, there’s VC++ 2008 compiler needed.
I’ve to implement 64-bit application (this is strong requirement) and I have VC++ 2010 Professional license.
I could use VC++ 2008 Express compiler to compile my application but it doesn’t support 64-bit compilation.
Therefore I had to use VC++ 2008 Professional but as I mentioned earlier I’ve got VC++ 2010 Professional license only.
Do you have any suggestion how to solve this problem?

If I uderstood well, to compile cuda application with VC++ 2010, there’s VC++ 2008 compiler needed.
I’ve to implement 64-bit application (this is strong requirement) and I have VC++ 2010 Professional license.
I could use VC++ 2008 Express compiler to compile my application but it doesn’t support 64-bit compilation.
Therefore I had to use VC++ 2008 Professional but as I mentioned earlier I’ve got VC++ 2010 Professional license only.
Do you have any suggestion how to solve this problem?

I had that same error (MSB3721), which I resolved by the following steps:

  • rename your *.cpp to *.cu
  • set both files to CUDA C/C++
  • exclude your kernel.cu from the build
  • edit Project Properties and add ‘cudart.lib’ to the Additional Dependencies in Configuration Properties → Linker → Input
  • build

Tell me if it works.

I had that same error (MSB3721), which I resolved by the following steps:

  • rename your *.cpp to *.cu
  • set both files to CUDA C/C++
  • exclude your kernel.cu from the build
  • edit Project Properties and add ‘cudart.lib’ to the Additional Dependencies in Configuration Properties → Linker → Input
  • build

Tell me if it works.

Yap it is!! You can use your Visual Studio 2010 to develop CUDA Kernel but on your machine you should install Visual Studio 2008 or compiler VC9.0 with Windows 6.1 SDK… and change platform toolset from V100 to V90; my advice is to use Visual Studio 2008 to develop CUDA application (or CUDA kernel) because IntelliSense works (in Visual Studio 2010 is not way to have full IntelliSense!! read below ;-) how to enable partial IntelliSense support in Visual Sutdio 2010)

Yap it is!! You can use your Visual Studio 2010 to develop CUDA Kernel but on your machine you should install Visual Studio 2008 or compiler VC9.0 with Windows 6.1 SDK… and change platform toolset from V100 to V90; my advice is to use Visual Studio 2008 to develop CUDA application (or CUDA kernel) because IntelliSense works (in Visual Studio 2010 is not way to have full IntelliSense!! read below ;-) how to enable partial IntelliSense support in Visual Sutdio 2010)

Try to install Windows 6.1 SDK ;-)… but I do not know if SDK has 64 bit compiler version ;-) (remember, I have failed in my first attempt to use SDK compiler with visual Sutdio 2010 to compile CUDA Kernel ;-) good luck)

Try to install Windows 6.1 SDK ;-)… but I do not know if SDK has 64 bit compiler version ;-) (remember, I have failed in my first attempt to use SDK compiler with visual Sutdio 2010 to compile CUDA Kernel ;-) good luck)

Ok guys,
if you plane to use Visual Studio 2010 to develop CUDA Kernel you should follow these steps to have partial IntelliSense support (at the moment kernel invocation <<<,>>> is not recognize by IntelliSense ;-))

Install ParallelNSight (it is optional but it is great tool ;-))

Change platform toolset from V100 to V90 in Visual Studio options

Sets this for debug mode:
Link->Input cudart.lib;cutil32D.lib

Stes this for release mode:
Link->Input cudart.lib;cutil32.lib

Setes this for debug/release mode:
VC++ Project Settings->Extensions To Include .cu; .cuh

Adds this at the top of cu file (this enables IntelliSense to recognize cudaMalloc, cudaFree and so on):
#include <host_defines.h>
#include <builtin_types.h>
#include <common_functions.h>
#include <cublas.h>
#include <cuComplex.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cufft.h>
#include <curand_kernel.h>
#include <device_functions.h>
#include <device_launch_parameters.h>
#include <host_config.h>
#include <math_constants.h>
#include <math_functions.h>
#include <math_functions_dbl_ptx1.h>
#include <math_functions_dbl_ptx3.h>
#include <surface_functions.h>
#include <texture_fetch_functions.h>
#include <vector_functions.h>
#define CUDA_INTERNAL_COMPILATION

Sets environment variables (adjust path for your machine):
CUDA_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\
CUDA_INC_PATH = %CUDA_PATH%\include
CUDA_LIB_PATH = %CUDA_PATH%\lib\Win32 (for 32 bit… or x64 for 64 bit ;-))

In Visual Studio 2008 you should simply adjust environment variables and copy C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\doc\syntax_highlighting\visual_studio_8\usertype.dat to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE (adjust path for your machine ;-))

Ok guys,
if you plane to use Visual Studio 2010 to develop CUDA Kernel you should follow these steps to have partial IntelliSense support (at the moment kernel invocation <<<,>>> is not recognize by IntelliSense ;-))

Install ParallelNSight (it is optional but it is great tool ;-))

Change platform toolset from V100 to V90 in Visual Studio options

Sets this for debug mode:
Link->Input cudart.lib;cutil32D.lib

Stes this for release mode:
Link->Input cudart.lib;cutil32.lib

Setes this for debug/release mode:
VC++ Project Settings->Extensions To Include .cu; .cuh

Adds this at the top of cu file (this enables IntelliSense to recognize cudaMalloc, cudaFree and so on):
#include <host_defines.h>
#include <builtin_types.h>
#include <common_functions.h>
#include <cublas.h>
#include <cuComplex.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cufft.h>
#include <curand_kernel.h>
#include <device_functions.h>
#include <device_launch_parameters.h>
#include <host_config.h>
#include <math_constants.h>
#include <math_functions.h>
#include <math_functions_dbl_ptx1.h>
#include <math_functions_dbl_ptx3.h>
#include <surface_functions.h>
#include <texture_fetch_functions.h>
#include <vector_functions.h>
#define CUDA_INTERNAL_COMPILATION

Sets environment variables (adjust path for your machine):
CUDA_PATH = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\
CUDA_INC_PATH = %CUDA_PATH%\include
CUDA_LIB_PATH = %CUDA_PATH%\lib\Win32 (for 32 bit… or x64 for 64 bit ;-))

In Visual Studio 2008 you should simply adjust environment variables and copy C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\doc\syntax_highlighting\visual_studio_8\usertype.dat to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE (adjust path for your machine ;-))