CUDA Visual Studio 2010 Express Build Error

I'm trying to get started with CUDA programming on Windows using Visual Studio 2010 Express on 64-bit Windows 7. I took some time to set up the environment, and I just wrote my first program helloWorld.cu :)

I am currently working with the following program:

#include <stdio.h> __global__ void add(int a, int b, int *c){ *c = a + b; } int main(void){ int c; int *dev_c; HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) ); add<<<1,1>>>(2, 7, dev_c); HANDLE_ERROR( cudaMemcpy( &c, dev_c, sizeof(int), cudaMemcpyDeviceToHost ) ); printf("2 + 7 = %d\n", c); cudaFree( dev_c ); return 0; } 

And here is the build result using the tools of the Windows7.1SDK platform:

 1> C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2>"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 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -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 "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu" 1>nvcc : fatal error : '-ccbin': expected a number 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,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 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -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 "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"" exited with code -1. 

However, with the v100 platform toolkit, I get this error:

 C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2>"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 "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -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 "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu" 1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\math.h(455): error : dllexport/dllimport requires external linkage 1>C:/Users/User/documents/visual studio 2010/Projects/CudaTest2/CudaTest2/hello.cu(12): error : identifier "HANDLE_ERROR" is undefined 1>c:\program files\nvidia gpu computing toolkit\cuda\v5.0\include\math_functions.h(2900): error : function "hypotf" was referenced but not defined 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,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 "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64" -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 "x64\Debug" -maxrregcount=0 --machine 64 --compile -g -Xcompiler "/EHsc /W1 /nologo /O2 /Zi /MD " -o "x64\Debug\hello.cu.obj" "C:\Users\User\documents\visual studio 2010\Projects\CudaTest2\CudaTest2\hello.cu"" exited with code 2. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

Can someone point me in the right direction? I read almost all messages about related problems, installed and uninstalled tools a couple of times and still can not get the correct assembly.

+4
source share
3 answers

The following worked for me. Edit the file * C: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ BuildCustomizations \ CUDA 5.0.prop * s. Locate PlatformToolset and add an entry for Windows7.1SDK. Set the value in 2010.

 <CudaClVersion Condition="'$(PlatformToolset)' == 'Windows7.1SDK'">2010</CudaClVersion> 
+2
source

The answer is twofold. The build error HANDLE_ERROR that you use with the v100 platform is related to the HANDLE_ERROR function defined in the additional headers for the book “Cuda By Example” - I recognize the example, so I assume that the code you are trying to compile did not include this file because it is not listed in book code lists ... a little supervision by the author (s), imho.

You can download the code examples and the additional title “book.h” that you need from the book page: https://developer.nvidia.com/content/cuda-example-introduction-general-purpose-gpu-programming-0

For reference, this is the HANDLE_ERROR code from book.h:

 static void HandleError( cudaError_t err, const char *file, int line ) { if (err != cudaSuccess) { printf( "%s in %s at line %d\n", cudaGetErrorString( err ), file, line ); exit( EXIT_FAILURE ); } } #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ )) 
0
source

This is due to the fact that the visual studio does not have access to the Temp folder.

go to C: \ Users \ userName \ AppData \ Local \ Temp and change the security rules of access for the current user (in this case, the username) to full control

0
source

Source: https://habr.com/ru/post/1446207/


All Articles