Error: identifier "atomicAdd" is undefined under visual studio 2010 & cuda 4.2 with Fermi GPU

I tried to compile some CUDA codes in visual studio 2010 with CUDA 4.2 (I created this CUDA project using Parallel Nsight 2.2), but I ran into the atomic problem "error: identifier" atomicAdd is undefined ", which I cannot solve after checking multiple forums.

So, I tried to get some information from the CUDA SDK Samples. First, I ran a simpleAtomicIntrinsics sample in the CUDA SDK, which passed the test. Then I copied all the files in this example to a new CUDA 4.2 project in visual studio 2010 and compiled them. Here is the result.

1> E:\CUDA exercise Codes\CUDA_EXERCISES\CUDA_EXERCISES\CUDA_EXERCISES>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -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" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\simpleAtomicIntrinsics.cu.obj" "E:\CUDA exercise Codes\CUDA_EXERCISES\CUDA_EXERCISES\CUDA_EXERCISES\simpleAtomicIntrinsics.cu" 1> simpleAtomicIntrinsics.cu 1> tmpxft_00007220_00000000-3_simpleAtomicIntrinsics.compute_20.cudafe1.gpu 1> tmpxft_00007220_00000000-7_simpleAtomicIntrinsics.compute_20.cudafe2.gpu 1> simpleAtomicIntrinsics.cu 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(33): error : identifier "atomicAdd" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(36): error : identifier "atomicSub" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(39): error : identifier "atomicExch" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(42): error : identifier "atomicMax" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(45): error : identifier "atomicMin" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(48): error : identifier "atomicInc" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(51): error : identifier "atomicDec" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(54): error : identifier "atomicCAS" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(59): error : identifier "atomicAnd" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(62): error : identifier "atomicOr" is undefined 1> 1>e:\cuda exercise codes\cuda_exercises\cuda_exercises\cuda_exercises\simpleAtomicIntrinsics_kernel.cu(65): error : identifier "atomicXor" is undefined 1> 1> 11 errors detected in the compilation of "C:/Users/NIEXIA~1/AppData/Local/Temp/tmpxft_00007220_00000000-9_simpleAtomicIntrinsics.compute_10.cpp1.ii". 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 4.2.targets(361,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -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" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\simpleAtomicIntrinsics.cu.obj" "E:\CUDA exercise Codes\CUDA_EXERCISES\CUDA_EXERCISES\CUDA_EXERCISES\simpleAtomicIntrinsics.cu"" exited with code 2. 1> 1>Build FAILED. 

By the way, I can run other patterns like clock, matrixMul, etc. as part of this project vs2010 CUDA. (This means that the enable path is set correctly)

I looked through it and found the following link. Some problem with Atomic add in the operation of the CUDA kernel . I changed the properties of both the project and the .cu file to suit it, but still cannot solve the problem.

Any suggestion?

+4
source share
3 answers

Atomics are not available in Computing Architecture 1.0, but you are still trying to compile it according to your build log. Try to remove references to compute_10 and sm_10 from your properties of the CUDA project and compile only for computing architecture 2.0 (GeForce 400 series and newer).

+4
source

Try compiling with the -arch sm_20 flag

+8
source

"Atomics are not available in Computing Architecture 1.0, but you are still trying to compile it according to your build log. Try removing the references to compute_10 and sm_10 from your CUDA project properties and compiling it only to calculate architecture 2.0 (GeForce 400 series and later)" . This is absolutely true, BTW, if you guys are compiling the source code of rodrigob_doppia (boosted_learning), you can simply add a line to your computer's configuration: set (CUDA_NVCC_FLAGS) -arch = sm_20 "CACHE STRING" nvcc flags "FORCE) In fact, it is configured to switch the arch flag to sm_20, just like the above.

0
source

All Articles