- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我是 thrust 库的新手,并试图在我的项目中使用它。这是一个非常简单的代码示例。它可以毫无问题地编译。但是,当我尝试运行它时,它给了我一个错误:
terminate called after throwing an instance of 'thrust::system::detail::bad_alloc'
what(): std::bad_alloc: unknown error
连同警告:
nvlink warning : SM Arch ('sm_20') not found in ...
可以使用以下两个文件重现该项目。
测试.cpp
#include <thrust/device_vector.h>
int main(){
thrust::device_vector<int> x;
x.resize(10);
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.9)
project(test_project)
find_package(CUDA QUIET REQUIRED)
list(APPEND CUDA_NVCC_FLAGS "-std=c++11;-arch=compute_52")
set(CUDA_SEPARABLE_COMPILATION ON)
cuda_add_executable("cuda_test" "test.cu")
经过一些测试,很明显,如果删除“set(CUDA_SEPARABLE_COMPILATION ON)”这一行,程序运行没有问题。但我确实需要为我的项目激活可分离编译。
如有任何帮助或提示,我们将不胜感激。
更新:
应@RobertCrovella 的要求,这里有更多信息。
CUDA版本为7.5,新安装在GTX980的UBUNTU 14.04上。之后我没有更新 Thrust 库。
以下是cmake使用"make VERBOSE=1"生成的实际命令。
CMake script with separable compilation
CMake script without separable compilation
更新 2:
@merelyMark确认了同样的错误.由于代码和 CMakeLists 文件都非常简单,这是否可能是 Thrust/CUDA 中的错误? [编辑] 不。
更新 3:
@RobertCrovella 指出,推力库在适当的 cmake comands 下运行良好.现在的问题是:如何使用 CMakeLists 生成这些命令?
最佳答案
提前致歉,我没有足够的积分来添加评论,但我可以确认我的装备上的行为。这在我的机器上使用 E5-1650 v3 和带有 CUDA 7.5 和 Ubuntu 14.04.3 的 Quadro M4000 正确编译。我收到一个警告错误:
nvlink warning : SM Arch ('sm_20') not found in ...
我可以在运行时确认行为:
./cuda_test
terminate called after throwing an instance of 'thrust::system::detail::bad_alloc'
what(): std::bad_alloc: unknown error
Aborted (core dumped)
我同意@RobertCrovella 的观点,我不太确定您要在这里完成什么。
关于c++ - CMakeLists 问题:在 thrust::device_vector 上调用 resize() 时出现 bad_alloc 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37482446/
以下 CUDA Thrust 程序崩溃: #include #include int main(void) { thrust::device_vector vec; for (int i(
我使用 cuda 内核对推力 vector 执行 S 形激活: thrust::device_vector output = input; float * output_ptr = thrust::r
我一直在尝试实现一些需要在 thrust::complexes 上调用 reduce 的代码,编译器向我发出错误消息: cannot pass an argument with a user-prov
我是 CUDA 的新手,而且很吃力。当提供 counting_iterator 时,我似乎无法让 thrust::for_each 算法工作。这是我的简单仿函数: struct print_Funct
我实际上正在学习CUDA和thrust,我正在尝试用.cpp做一个项目,。 hpp 文件和 .cu, .cuh 文件。因此,我做了第一个小实现(见下面的代码),但是我有一个编译错误。这是 output
我想覆盖低级 CUDA 设备内存分配器(实现为 thrust::system::cuda::detail::malloc()),以便它使用自定义分配器而不是直接调用 cudaMalloc()在主机 (
当我在main函数中使用thrust::device_vector时,可以正确的传递给内核函数,代码如下: thrust::device_vector device_a(2); thrust::h
我在 CUDA 中使用这种 vector 方法的 vector 方法,因为我仍然习惯于 Matlab 和 Python 风格的编程环境。我能够从设备 vector 中的主机端提取数据,但现在我不确定如
我正在尝试使用 thrust::raw_pointer_cast 转换原始指针以捕获仿函数中的输出。我尝试了多种方法来将指针传递给 float ,但不断出现内存冲突和两个智能感知错误 thrust::
gather与scatter正好相反: scatter是顺序输入根据map确定撒点输出位置。 #include #include #include ... // mark even indice
我是 Thrust 的新手,有件事我不明白。 Thrust 是异步还是同步? 如果我编写以下代码,所花费的时间不是0。但在其他标签中,其他用户报告的结果为0。真相是什么? clock_t start,
我的编译器 (PGI) 不支持 #pragma once 但是我想包含的库(推力)使用它们。 这个问题有解决办法吗? 最佳答案 您可以使用guardonce将 #pragma Once 语句转换为标准
我的设备上有两个整数数组 dmap 和 dflag相同的长度我用推力设备指针 dmapt 和dflagt dmap 数组中有一些值为 -1 的元素。我想要删除这些 -1 和相应的值dflag 数组。
Thrust 能够对编码器隐藏各种细节,并且声称 Thrust 会根据系统规范在一定程度上设置参数。 Thrust 如何选择最佳参数化,以及如何处理不同机器上的各种代码? Thrust 实现这种通用库
我在当前项目中使用了 Thrust,所以我不必写 device_vector自己抽象或(分段)扫描内核。 到目前为止,我已经使用推力抽象完成了我的所有工作,但是对于简单的内核或不容易转换为 for_e
我想做这样的事情: BaseFunctor* f = new MyFunctor(); thrust::transform(it1,it2,MyFunctor); 目标是让用户能够传递不同的仿函数(具
当我尝试实现任何仿函数时,我得到了不好的结果。例如,我尝试了一个类似于 thrust::negate 的否定仿函数下面是一个示例代码,它使用内置的否定仿函数产生了良好的结果: int data[10]
我正在使用 OpenCV 加载一个 .png 文件,我想使用 thrust 库提取它的蓝色强度值。 我的代码是这样的: 使用 OpenCV IplImage 指针加载图像 将图像数据复制到thrust
我有一个奇怪的问题,我无法解决。它与 boost +推力代码相关联。 代码: #include #include #include #include #include #include #
是否可以使用 Thrust 创建一个 device_vectors 数组?我知道我不能创建一个 device_vector 的 device_vector,但是我将如何创建一个 device_vect
我是一名优秀的程序员,十分优秀!