Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"don't know what to do with' nvcc fatal error

I use the command lines in Ubuntu's terminal.

And I am trying to compile the three files presented in CUDA_Compiler_Driver_NVCC.pdf

When I do use the command line given by the documentation on these 3 files, I do get the following errors:

nvcc fatal : don't know what to do with'-dc'

If I erase -dc in the command line, I do get the following error too: nvcc fatal : don't know what to do with'-arch=sm=20'

Do anyone know how I could fix this issue ?

Thanks a lot in advance for your help

Gibo

Below, you will find the command line I entered in the terminal, and the files.

Command line used: nvcc –arch=sm_20 –dc a.cu b.cu nvcc –arch=sm_20 a.o b.o

Files code (just a copy paste of the documentation): (it seems the code police changes when pasted, sorry for this small issue)

******* b.h ***********
#define N 8

extern __device__ int g[N];
extern __device__ void bar(void);

******* b.cu***********
#include "b.h"
__device__ int g[N];
__device__ void bar (void)
{
g[threadIdx.x]++;
}

******* a.cu ***********
#include <stdio.h>

#include "b.h"

__global__ void foo (void) {
__shared__ int a[N];
a[threadIdx.x] = threadIdx.x;
__syncthreads();
g[threadIdx.x] = a[blockDim.x - threadIdx.x - 1];
}

bar();

int main (void) {
unsigned int i;
int *dg, hg[N];

int sum = 0;

foo<<<1, N>>>();

if(cudaGetSymbolAddress((void**)&dg, g)){
printf("couldn't get the symbol addr\n");
return 1;
}

if(cudaMemcpy(hg, dg, N * sizeof(int), cudaMemcpyDeviceToHost)){
printf("couldn't memcpy\n");
return 1;
}

for (i = 0; i < N; i++) {
sum += hg[i];
}

if (sum == 36) {
printf("PASSED\n");
} else {
printf("FAILED (%d)\n", sum);
}

return 0;
}
like image 365
Gibo Avatar asked Nov 02 '22 02:11

Gibo


1 Answers

Make sure you are using the right version of nvcc. I had a problem like that and it was because I was using NVCC 5.5 instead of 6.0.

Also make sure the dashes have the right symbol: use - (0x2D) and not – (0xD0).

like image 120
gbuzogany Avatar answered Nov 03 '22 15:11

gbuzogany