Cuda - nvcc - 没有内核映像可在设备上执行。问题是什么?

问题描述 投票:1回答:2

我试图用最简单的例子使用nvcc,但它无法正常工作。我正在编译并执行https://devblogs.nvidia.com/easy-introduction-cuda-c-and-c/中的示例,但是我的服务器无法执行全局函数。我重写代码以获取一些错误消息,我收到以下消息:“没有内核映像可用于在设备上执行”

我的GPU是Quadro 6000,而cuda版本是9.0。

#include <stdio.h>
#include <cuda_runtime.h>

__global__ void saxpy(int n, float a, float *x, float *y)
{
  int i = blockIdx.x*blockDim.x + threadIdx.x;
  y[i] = 10.0; //a*x[i] + y[i];  
}

int main(int argc, char *argv[])
{
  int N = 120;
  int nDevices;
  float *x, *y, *d_x, *d_y;

  cudaError_t err = cudaGetDeviceCount(&nDevices);
  if (err != cudaSuccess) 
    printf("%s\n", cudaGetErrorString(err));
  else
    printf("Number of devices %d\n", nDevices);

  x = (float*)malloc(N*sizeof(float));
  y = (float*)malloc(N*sizeof(float));

  cudaMalloc(&d_x, N*sizeof(float)); 
  cudaMalloc(&d_y, N*sizeof(float));

  for (int i = 0; i < N; i++) {
    x[i] = 1.0f;
    y[i] = 2.0f;
  }

  cudaMemcpy(d_x, x, N*sizeof(float), cudaMemcpyHostToDevice);
  cudaMemcpy(d_y, y, N*sizeof(float), cudaMemcpyHostToDevice);

  // Perform SAXPY on 1M elements  
  saxpy<<<1, 1>>>(N, 2.0f, d_x, d_y);
  cudaDeviceSynchronize(); 

  err = cudaMemcpy(y, d_y, N*sizeof(float), cudaMemcpyDeviceToHost);  

  printf("%s\n",cudaGetErrorString(err));

  cudaError_t errSync  = cudaGetLastError();
  cudaError_t errAsync = cudaDeviceSynchronize();
  if (errSync != cudaSuccess) 
    printf("Sync kernel error: %s\n", cudaGetErrorString(errSync));
  if (errAsync != cudaSuccess)
    printf("Async kernel error: %s\n", cudaGetErrorString(errAsync)); 


  cudaFree(d_x);
  cudaFree(d_y);
  free(x);
  free(y);
}"

执行命令

bash-4.1$ nvcc  -o sapx simples_cuda.cu
bash-4.1$ ./sapx
Number of devices 1
no error
Sync kernel error: no kernel image is available for execution on the device
cuda nvcc
2个回答
2
投票

计算能力小于2.0的GPU仅受6.5及更早版本的CUDA工具包支持。

计算能力小于3.0(但大于或等于2.0)的GPU仅受8.0及更早版本的CUDA工具包支持。

您的Quadro 6000是一款计算能力2.0 GPU。这可以使用deviceQuery CUDA示例代码或通过google search以编程方式确定。 CUDA 9.0不支持它


-1
投票

添加到@ RobertCrovella的答案:

使用nvcc进行编译时,应始终设置适当的标志,以便为要运行的微体系结构/计算功能生成bianry内核映像。例如:-gencode arch=compute_${COMPUTE_CAPABILITY},code=compute_${COMPUTE_CAPABILITY},和COMPUTE_CAPABILITY=20说。并阅读nvcc --help获取更多信息(虽然这有点令人困惑)。

© www.soinside.com 2019 - 2024. All rights reserved.