Thanks for the reply. I have been having all kinds of problems with Cuda code which lends me to agree with you that the cuda compiler might be the problem.
Here is how I am using thrust:
thrust::device_vector<Vertex> d_vertices = m_singleFrameImages[i]->getImageVertices();
// copy the image pixels to a device vector, use the constructor do not copy
thrust::device_vector<uchar> d_pixels(m_denoisedImagesPixels[i].get(), m_denoisedImagesPixels[i].get() + (imagesWidth * imagesHeight));
// Create a fancy iterator that points to the 'color' members of d_vertices
thrust::transform_iterator<get_color_ref, thrust::device_vector<Vertex>::iterator> x_iter(d_vertices.begin(), get_color_ref());
// Copy the values from d_pixels into the 'color' members using thrust::copy
thrust::copy(d_pixels.begin(), d_pixels.end(), x_iter);
I am setting a value in a vector of structs from another vector by using a function (get_color_vector) to do the copying.
I am using Visual studio so I am not compiling on the command line. Here is the command from the log file:
HostCommandLineTemplate = -Xcompiler “/EHsc [Warning] /nologo [Optimization] /FS [DebugInformationFormat] [RuntimeChecks] [Runtime] [TypeInfo]” -Xcompiler “/Fd[ProgramDataBaseFileName]”
SplitCompile = Default
CodeGeneration = compute_86,sm_86;compute_89,sm_89;compute_120,sm_120
AdditionalCompilerOptions =
EnableVirtualArchInFatbin = true
RuntimeApiCommandLineTemplate = -ccbin “C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64” -x cu [GenerateRelocatableDeviceCode] [ExtensibleWholeProgramCompilation] [Include] [RequiredIncludes] [InterleaveSourceInPTX] [GPUDebugInfo] [GenerateLineInfo] [Keep] [KeepDir] [FastMath] [MaxRegCount] [PtxAsOptionV] [SplitCompile] [FastCompile] [TargetMachinePlatform] [NvccCompilation] [CudaRuntime] [AdditionalOptions] [HostDebugInfo] [Emulation] [Defines] -Xcompiler “/EHsc [Warning] /nologo [Optimization] /FS [DebugInformationFormat] [RuntimeChecks] [Runtime] [TypeInfo]” -Xcompiler “/Fd[ProgramDataBaseFileName]” [CompileOut] “%(FullPath)”
BuildCommandLineTemplate = --use-local-env
GenerateRelocatableDeviceCode = true
UseHostDefines = true
GPUDebugInfo = true
Xcompiler=“/EHsc -Zi -Ob0”
Defines = ;_WINDOWS;CMAKE_INTDIR=“Debug”;Zc:preprocessor
CudaRuntime = Static
NvccCompilation = compile
PropsCacheOutputFile = %(Filename)%(Extension).cache
TargetMachinePlatform = 64
CommandLineTemplate =
# Driver API (NVCC Compilation Type is .cubin, .gpu, or .ptx)
set CUDAFE_FLAGS=--sdk_dir "C:\Program Files (x86)\Windows Kits\10\"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.1\bin\nvcc.exe" --use-local-env -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64" -x cu [GenerateRelocatableDeviceCode] [ExtensibleWholeProgramCompilation] [Include] [RequiredIncludes] [InterleaveSourceInPTX] [GPUDebugInfo] [GenerateLineInfo] [Keep] [KeepDir] [FastMath] [MaxRegCount] [PtxAsOptionV] [SplitCompile] [FastCompile] [TargetMachinePlatform] [NvccCompilation] [CudaRuntime] [AdditionalOptions] [Defines] [CompileOut] "%(FullPath)"
# Runtime API (NVCC Compilation Type is hybrid object or .c file)
set CUDAFE_FLAGS=--sdk_dir "C:\Program Files (x86)\Windows Kits\10\"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.1\bin\nvcc.exe" --use-local-env -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64" -x cu [GenerateRelocatableDeviceCode] [ExtensibleWholeProgramCompilation] [Include] [RequiredIncludes] [InterleaveSourceInPTX] [GPUDebugInfo] [GenerateLineInfo] [Keep] [KeepDir] [FastMath] [MaxRegCount] [PtxAsOptionV] [SplitCompile] [FastCompile] [TargetMachinePlatform] [NvccCompilation] [CudaRuntime] [AdditionalOptions] [HostDebugInfo] [Emulation] [Defines] -Xcompiler "/EHsc [Warning] /nologo [Optimization] /FS [DebugInformationFormat] [RuntimeChecks] [Runtime] [TypeInfo]" -Xcompiler "/Fd[ProgramDataBaseFileName]" [CompileOut] "%(FullPath)"
Here is the command line from the linker page:
“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.1\bin\nvcc.exe” -dlink --dlink-time-opt -o MRIViewer\x64\Debug\MRIViewer.device-link.obj -Xcompiler “/EHsc /nologo /Zi " -Xcompiler “/Fd[ProgramDataBaseFileName]” -L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.1\bin\x64/crt” -L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.1\lib\x64" -G
If I compile each file in the project separately I do not get any errors, but when I compile the project it generates the unresolved external error.
does that help show if the problems are coming from the cuda compiler?
Thanks