【问题标题】:cudaMalloc caused "unknown errors" in CUDAcudaMalloc 在 CUDA 中导致“未知错误”
【发布时间】: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


【解决方案1】:

一些想法可能是问题的根源:

【讨论】:

  • 非常感谢您提供此链接。使用 sudo 的解决方案奏效了!后来我得知我的帐户没有添加到视频组,因此没有足够的访问级别来使用 GPU。抱歉,我现在不能投票给你的答案,因为我是新手,我没有 15 分来投票。不过非常感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 2011-09-24
  • 1970-01-01
  • 2019-04-28
  • 2013-10-05
  • 1970-01-01
  • 1970-01-01
  • 2013-07-13
  • 2012-06-15
相关资源
最近更新 更多