compilation .cu files with Dynamic Parallelism(CUDA) - cuda

I switched to a new GPU GeForce GTX 980 with cc 5.2, so it must support dynamic parallelism. However, I was not able to compile even a simple code (from programming guide). I will not provide it here (not necessary, just there is a global kernel calling another global kernel).
1) I use VS2013 for coding. In property pages -> CUDA C/C++ -> device, I changed code generation property to compute_35,sm_35, and here is the output:
1>------ Build started: Project: testCublas3, Configuration: Debug Win32 ------
1> Compiling CUDA source file kernel.cu...
1>
1> C:\programs\misha\cuda\Projects\test projects\testCublas3\testCublas3>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe" -gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj "C:\programs\misha\cuda\Projects\test projects\testCublas3\testCublas3\kernel.cu"
1>C:/programs/misha/cuda/Projects/test projects/testCublas3/testCublas3/kernel.cu(13): error : kernel launch from __device__ or __global__ functions requires separate compilation mode
1> kernel.cu
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 6.5.targets(593,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe" -gencode=arch=compute_35,code=\"sm_35,compute_35\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj "C:\programs\misha\cuda\Projects\test projects\testCublas3\testCublas3\kernel.cu"" exited with code 2.
I guess, that I need another option for this compilation: -rdc=true, but I didn't find where I can set it in VS2013.
2) When I set code generationproperty to compute_52,sm_52, there is a error: Unsupported gpu architecture 'compute_52'. But my cc is 5.2. So I can compile codes for 3.5 cc maximum?
Thanks

Regarding item 1, cuda dynamic parallelism requires separate compilation and linking (-rdc=true), as well as linking in of the device cudart libraries (-lcudadevrt). Dynamic parallelism that also uses CUBLAS will also require linking in the device CUBLAS library (-lcublas_device). Possibly the simplest way to define where all these should go in a visual studio project is to start by looking at a visual studio project for the device cublas sample.
Regarding item 2, the reason your GTX 980 compute capability 5.2 is not being recognized is that you need the latest update for the cuda 6.5 toolkit, which is available here.
(Note that the cublas_device capability has been removed from recent versions of CUDA.)

Related

How can I edit command line -ccbin option for CUDA C/C++ in VS2019?

I've downloaded the NVIDIA sample for CUDA and it fails to work for bandwidthTest, because of the error "nvcc ..." in command line "exited error code 1". The complete command line is(my private info is neglected):
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_60,code=\"sm_60,compute_60\" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -gencode=arch=compute_70,code=\"sm_70,compute_70\" -gencode=arch=compute_75,code=\"sm_75,compute_75\" -gencode=arch=compute_80,code=\"sm_80,compute_80\" -gencode=arch=compute_86,code=\"sm_86,compute_86\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64" -x cu -I./ -I../../../Common -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\/include" -I../../../Common -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xcompiler "/wd 4819" --threads 0 -g -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Fdx64/Debug/vc142.pdb /FS /Zi /RTC1 /MTd " -o [private info]\bandwidthTest\x64\Debug\bandwidthTest.cu.obj "[private info]\bandwidthTest\bandwidthTest.cu"
Then I ran this code in cmd, which reported "nvcc fatal: Compiler 'cl.exe' in PATH different than the one specified with -ccbin". It seemed that the CUDA C/C++ command line went wrong. So I changed the HostX86\x64 to HostX64\x64, then it succeeded(at least no error was reported).
So, I tried to find where to edit this command line in VS2019. It's in Project->Properties->CUDA C/C++->Command Line.
Here -ccbin has a parameter string ending with "HostX86\x64". However, I have no idea about how to edit it, because it seems that there is no such option. (Maybe I left it out. All of the options can be checked at https://docs.nvidia.com/nsight-visual-studio-edition/3.2/Content/CUDA_Properties_Config.htm).
So is there any way to edit it? Or is there any other method to solve it?
All right, I've found this option in Project->Properties->Advanced->Preferred Build Tool Architecture. Change it to x64.

cannot build with compatibility above 20

I am using vs2010, cuda6.5. When I specify
compute_20,sm_20
in project Properties -> CUDA C/C++ ->Device, the code builds with no problem.
However, when I designate two more compatibility like following:
compute_20,sm_20
compute_35,sm_35
compute_52,sm_52
The build fails, and gives following error message:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 6.5.targets(593,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -IC:\FAWKESBASE\Release\INC -IC:\FAWKESBASE\Release\INC -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\include" --keep-dir x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -D_WINDLL -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MD " -o x64\Release\FilterSino.cu.obj "D:\SW_ImageChan_64Slice\RecCWinLibAxial64\FilterSino.cu"" exited with code 1.
1>
I tried 35 and 52, both failed. It seems as long as the compatibility is higher than 20, it fails. Anyone has a pointer? Thanks a lot.
UPDATE:
Looks like it says:
nvcc fatal : Unsupported gpu architecture 'compute_52'
So can I support 52 at this time? Is this a vs2010 problem or a cuda6.5 problem? I have a card that is compatible with 52, that is why I added this option in my build.
The first release of CUDA 6.5 doesn't support compute capability 5.2 or newer devices. NVIDIA released an updated version of 6.5 with support for the GT9xx family of GPUs (sm_52 architecture) which you could try, otherwise you need to install CUDA 7.0 or newer to compile for that architecture.

How to change compute_' ' and sm_' ' parameters in visual studio 2010?

My graphic card is EVGA GTX 550 Ti and Compute Capability is 2.1, I want set Code Generation to compute_20,sm_21in Configuration Properties in Visual studio for dynamic global memory allocation in device. I follow this link but after change compute_10,sm_10 to compute_20,sm_21, compiler still use previous parameters. message of output window is:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(498,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "E:\Programs\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -arch=sm_20 -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\kernel.cu.obj" "C:\Users\Mahdi\Documents\Visual Studio 2010\Projects\Paralllel SW Algorithm\Paralllel SW Algorithm\kernel.cu"" exited with code 2.
Specifications:
Microsoft visual studio 2010
Nsight Visual studio v3.0
CUDA Toolkit v5.0 64bit
If you added -arch=sm_20 in the "additional options" area, that won't work. You must change it in the relevant project properties area. Instead of following the "question", you should have followed the first (accepted) answer in that link
delete the addition you made in the "additional options" area.
with the project properties dialog open, on the left hand side, under "configuration properties", select "Device" under CUDA C/C++
now on the right hand pane, there is a drop down selection box for "Code Generation", select "compute_20, sm_21". Since you are building the debug version of the project, make sure to make this change for the debug version in the properties (listed at the top of the dialog box). You probably also want to make this change in the release version as well.
Instead of following the picture here you should follow the picture here

Intel C++ Composer and CUDA

I create a default CUDA project in VisualStudio2008. It works OK for the MS compiler. When I try the Intel C++ Composer, it fails as showed in the following:
1>------ Rebuild All started: Project: testCUDA, Configuration: Debug Win32 ------
1>Deleting intermediate files and output files for project 'testCUDA', configuration 'Debug|Win32'.
1>Compiling with CUDA Build Rule... (Microsoft VC++ Environment)
1>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\\bin\nvcc.exe" -G -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --machine 32 -ccbin "D:\Microsoft Visual Studio 9\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\\include" -maxrregcount=0 --compile -o "Debug/kernel.cu.obj" kernel.cu
1>nvcc : fatal error : A single input file is required for a non-link phase when an outputfile is specified
1>Project testCUDA : error: A tool returned an error code from "Compiling with CUDA Build Rule..."
1>Build log was saved at "file://C:\Users\JSC\Documents\Visual Studio 2008\Projects\testCUDA\testCUDA\Debug\BuildLog.htm"
1>testCUDA - 2 error(s), 0 warning(s), 0 remark(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
My platform is win7(32bit) with CUDA5.0. I use the Intel C++ compiler with version form 11.1 to Composer XE 2011 and even Composer XE 2013. All the versions of Intel C++ compiler will provide the error information.
Your help will be highly appreciated!
As explained in The CUDA 5.0 Release Notes, on Windows only Visual C++ 9.0/10.0 compilers are supported.
On Linux only GCC is supported (see the link above for specific versions).

GASS.CUDA.CUResult.ErrorInvalidImage error in CUDA.NET

I try to develop a form application using CUDA.NET in Visual Stuio C#. However I need to create cubin file, here is my problem:
I tried to create cubin file using Visual Studio. I changed the setting in Project Properties->Configuration Properties->Cuda Runtime API->GPU->NVCC Compilation Type to "Generate 64 bit .cubin file (-m64 -cubin)" from "Generate hybrid object file (--compile / -c)".
But I got this error "fatal error LNK1181: cannot open input file '.\Debug\histogram256.cu.obj'". It cannot find the object of some of my .cu files.
So I changed only those .cu files' "NVCC Compilation Type" setting to (-m64 -cubin) and compile them alone by right clicking on those files. However it did not create any .obj or .cubin file.
Then I tried to compile it from the command line. I copied the line in the .cu file's Property Page->Cuda Runtime API->Command Line which is
" "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --machine 32 -ccbin "c:\Program Files\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include" -maxrregcount=0 --compile -o "Debug/device.cubin" "device.cu""
device.cu is my cuda file.
It created the .cubin file, but I got this error from CUDA.NET: "GASS.CUDA.CUResult.ErrorInvalidImage."
Do you have any suggestions?
1: be sure that your viedecard support gencode-arch and code you specify.
2: You compile for 32 bit, be sure u are compiling and reference cuda.net for 32 bit also for .net.
3: Use managedcuda (codeplex) is much much better samples and documentation are provided.