VS程序崩溃在调试,但不是释放模式? [英] VS program crashes in debug but not release mode?
问题描述
我在VS 2012中运行以下程序来尝试Thrust函数find:
I am running the following program in VS 2012 to try out the Thrust function find:
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <thrust/find.h>
#include <thrust/device_vector.h>
#include <stdio.h>
int main() {
thrust::device_vector<char> input(4);
input[0] = 'a';
input[1] = 'b';
input[2] = 'c';
input[3] = 'd';
thrust::device_vector<char>::iterator iter;
iter = thrust::find(input.begin(), input.end(), 'a');
std::cout << "Index of a = " << iter - input.begin() << std::endl;
return 0;
}
这是一个代码示例的修改版本,取自 http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be
This is a modified version of a code example taken from http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be
当我在Debug模式下运行时,我的程序崩溃,我得到错误 Debug Error! ... R6010 - abort()已被调用
。但是,在发布模式下运行它只是得到我的预期输出 a = 0
的索引。
When I run this in Debug mode, my program crashes and I get the error Debug Error! ... R6010 - abort() has been called
. However, running this in Release mode I just get my expected output Index of a = 0
.
这可能会导致这种情况发生?
What might cause this to happen?
推荐答案
有几个类似的问题,例如此处
There are a few similar questions e.g. here
引用注释:Thrust已知在编译调试时无法正确编译和运行
To quote a comment : "Thrust is known to not compile and run correctly when built for debugging"
并且从 docs :nvcc不支持设备调试Thrust代码。编译的Thrust函数(例如,nvcc -G, nvcc --device-debug 0等)可能会崩溃。
And from the docs: "nvcc does not support device debugging Thrust code. Thrust functions compiled with (e.g., nvcc -G, nvcc --device-debug 0, etc.) will likely crash."
这篇关于VS程序崩溃在调试,但不是释放模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!