【发布时间】:2015-04-21 09:10:27
【问题描述】:
我正在尝试遵循 CUDA By Example 一书,并且刚刚开始尝试他们的一些示例。
“hello world”程序运行没有问题。对于下面的程序,它编译得很好,但是当我执行时,我得到了消息:
simple_kernel_params.cu 第 26 行的未知错误
第 26 行是第一个 cudaMalloc 命令。
有经验的人能否提供一些提示我应该如何解决这个问题?非常感谢!
/*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and
* proprietary rights in and to this software and related documentation.
* Any use, reproduction, disclosure, or distribution of this software
* and related documentation without an express license agreement from
* NVIDIA Corporation is strictly prohibited.
*
* Please refer to the applicable NVIDIA end user license agreement (EULA)
* associated with this source code for terms and conditions that govern
* your use of this NVIDIA software.
*
*/
#include "../common/book.h"
__global__ void add( int a, int b, int *c ) {
*c = a + b;
}
int main( void ) {
int c;
int *dev_c;
HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) );
add<<<1,1>>>( 2, 7, dev_c );
HANDLE_ERROR( cudaMemcpy( &c, dev_c, sizeof(int),
cudaMemcpyDeviceToHost ) );
printf( "2 + 7 = %d\n", c );
HANDLE_ERROR( cudaFree( dev_c ) );
return 0;
}
【问题讨论】:
-
可能是您的机器配置有问题。 CUDA 未正确安装,并且无法正常工作。按照the getting started guide appropriate to your platform 中的说明正确安装 CUDA 并验证安装。
-
非常感谢您的回答。事实证明这是真的:我的帐户无法访问 GPU,更多详细信息请参阅下面的评论。再次感谢!
标签: cuda