rtx5070ti laptop
lastest win11 msvc
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Fri_Feb_21_20:42:46_Pacific_Standard_Time_2025
Cuda compilation tools, release 12.8, V12.8.93
Build cuda_12.8.r12.8/compiler.35583870_0
NVIDIA-SMI 572.76 Driver Version: 572.76 CUDA Version: 12.8
How to Reproduce
/cuda_sort_project
│-- CMakeLists.txt
│-- main.cu
CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(SimpleCudaProject CUDA)
set(CMAKE_CUDA_STANDARD 17)
add_executable(SimpleCudaProject main.cu)
set_target_properties(SimpleCudaProject PROPERTIES CUDA_SEPARABLE_COMPILATION ON) # If comment this line, the program works fine
int main(int argc,char **argv){
thrust::host_vector<int> h_vec(1024 * 1024);
std::generate(h_vec.begin(), h_vec.end(), rand);
std::vector<int> vec(h_vec.size());
thrust::copy(h_vec.begin(), h_vec.end(), vec.begin());
thrust::device_vector<int> d_vec = h_vec;
thrust::sort(d_vec.begin(), d_vec.end());
return 0;
}
But the strange thing is: when i comment this line of code in CMakeLists.txt: set_target_properties(SimpleCudaProject PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
Everything works well and no exception is thrown.
Why?
Perhaps some issue with library versions?
you could try building a release project instead of a debug project. I’m not sure it will make any difference, but historically thrust used to have some issues with debug code.
I didn’t have any trouble running your posted code (compiling with or without -G) on CUDA 12.2 on a L4 GPU (cc8.9) on linux. I don’t think there are any issues with the code per-se.
You could also file a thrust issue.
release build still have error
I have found the answer by myself:
The reason is not compile the code for the architecture of the GPU I am using.
Solution: add the folloing line in CMakeLists.txt for RTX 5070ti:
set(CMAKE_CUDA_ARCHITECTURES 100)
Virtual Architecture Feature List can be found in: https://docs.nvidia.com/cuda/cu
But I have another two question:
1、Why we have to spcify the CMAKE_CUDA_ARCHITECTURES up-to-date for using thrust lib?
2、I compile my code to generate a lib for my customers all over the world to use. My customers have different gpus with different architectures. Is is right only to compile with CMAKE_CUDA_ARCHITECTURES 100? (Suppose the gpu of the compiling machine is also RTX 5070ti)
100 is not the correct architecture for RTX 5070ti
The correct architecture is 120
I’m not aware of reasons that it should be necessary to specify a specific architecture (although it is sometimes considered a good practice). To address the needs for multiple specific architectures, the general approach would be to specify a set of architectures in the fatbinary build process. The cuda sample code projects (i.e. Makefiles) give an example of this, although you would need to adapt that to your library build invocation (I don’t have a Cmake recipe for you). For the remainder, I suggest filing a thrust issue.
based on reading the linked github issue, it appears OP’s issue was resolved after upgrading from an R570 driver to an R575 driver.
1 Like