2013-02-09 11 views
7

mi è stato sempre questo erroreCUDA e la compatibilità gcc problema

/usr/local/cuda-5.0/bin/../include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.7 and up are not supported! make: * [src/Throughput.o] Error 1

Nel host_config.h assicurano la compatibilità fino al 4,6

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6) 

#error -- unsupported GNU version! gcc 4.7 and up are not supported! 

Ho sia 4.6 e 4,7

[email protected]:/usr/local/cuda-5.0/bin$ gcc gcc
gcc-4.7 gcc-nm-4.7 gcc-4.6 gcc-ar-4.7
gcc-ranlib-4.7

Guardando su Internet suggeriscono di aggiungere un collegamento a gcc-4.6 nella directory cuda bin.

così ho fatto

[email protected]:/usr/local/cuda-5.0/bin$ sudo ln -s /usr/bin/gcc-4.6 gcc

e ottengo un altro errore

**** Build of configuration Debug for project Throughput **** 

make all 
Building file: ../src/Throughput.cu 
Invoking: NVCC Compiler 
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "src/Throughput.d"  "../src/Throughput.cu" 
gcc: error trying to exec 'cc1plus': execvp: No such file or directory 
make: *** [src/Throughput.o] Error 1 

**** Build Finished **** 

Googling ancora una volta non mi ha portato su alcune situazioni chiare (gcc declassamento, ecc)

, quindi sono chiedendo qui quale è ora il problema dal momento che CUDA dovrebbe essere compatibile con gcc-4.6 ...

Il mio sistema:

  • Ubuntu 12.10 64b
  • cuda_5.0.35_linux_64_ubuntu11.10-1

Questo è il codice tutorial che sto cercando di compilare al momento

/** 
* Copyright 1993-2012 NVIDIA Corporation. All rights reserved. 
* 
* Please refer to the NVIDIA end user license agreement (EULA) associated 
* with this source code for terms and conditions that govern your use of 
* this software. Any use, reproduction, disclosure, or distribution of 
* this software and related documentation outside the terms of the EULA 
* is strictly prohibited. 
*/ 
#include <stdio.h> 
#include <stdlib.h> 

static const int WORK_SIZE = 256; 

/** 
* This macro checks return value of the CUDA runtime call and exits 
* the application if the call failed. 
*/ 
#define CUDA_CHECK_RETURN(value) {           \ 
    cudaError_t _m_cudaStat = value;          \ 
    if (_m_cudaStat != cudaSuccess) {          \ 
     fprintf(stderr, "Error %s at line %d in file %s\n",     \ 
       cudaGetErrorString(_m_cudaStat), __LINE__, __FILE__);  \ 
     exit(1);               \ 
    } } 

__device__ unsigned int bitreverse(unsigned int number) { 
    number = ((0xf0f0f0f0 & number) >> 4) | ((0x0f0f0f0f & number) << 4); 
    number = ((0xcccccccc & number) >> 2) | ((0x33333333 & number) << 2); 
    number = ((0xaaaaaaaa & number) >> 1) | ((0x55555555 & number) << 1); 
    return number; 
} 

/** 
* CUDA kernel function that reverses the order of bits in each element of the array. 
*/ 
__global__ void bitreverse(void *data) { 
    unsigned int *idata = (unsigned int*) data; 
    idata[threadIdx.x] = bitreverse(idata[threadIdx.x]); 
} 

/** 
* Host function that prepares data array and passes it to the CUDA kernel. 
*/ 
int main(void) { 
    void *d = NULL; 
    int i; 
    unsigned int idata[WORK_SIZE], odata[WORK_SIZE]; 

    for (i = 0; i < WORK_SIZE; i++) 
     idata[i] = (unsigned int) i; 

    CUDA_CHECK_RETURN(cudaMalloc((void**) &d, sizeof(int) * WORK_SIZE)); 

    CUDA_CHECK_RETURN(cudaMemcpy(d, idata, sizeof(int) * WORK_SIZE, cudaMemcpyHostToDevice)); 

    bitreverse<<<1, WORK_SIZE, WORK_SIZE * sizeof(int)>>>(d); 

    CUDA_CHECK_RETURN(cudaThreadSynchronize()); 
    // Wait for the GPU launched work to complete 
    CUDA_CHECK_RETURN(cudaGetLastError()); 
    CUDA_CHECK_RETURN(cudaMemcpy(odata, d, sizeof(int) * WORK_SIZE, cudaMemcpyDeviceToHost)); 

    for (i = 0; i < WORK_SIZE; i++) 
     printf("Input value: %u, device output: %u\n", idata[i], odata[i]); 

    CUDA_CHECK_RETURN(cudaFree((void*) d)); 
    CUDA_CHECK_RETURN(cudaDeviceReset()); 

    return 0; 
} 
+0

Oltre al CUDA, hai a che fare con il codice C puro? O è forse C++? – Bart

+0

@bart: nvcc richiede un compilatore C++ supportato funzionante – talonmies

+0

@Bart Al momento puro C (ho aggiunto qualche codice aggiuntivo) – elect

risposta

5

Il problema deriva dal fatto che la toolchain CUDA non è in grado di trovare un compilatore C++ valido. nvcc è solo un compilatore, richiede un compilatore C++ funzionante per compilare qualsiasi codice.

il modo più corretto per fare questo [Nota si sta utilizzando una versione non supportata di Linux, in modo da utilizzare questo consiglio a proprio rischio], è quello di creare una directory locale in possesso di collegamenti ad una suite compilatore supportato (questo abbinamento media, versioni supportate di gcc e g ++) e passare l'argomento --compiler-bindir a nvcc durante la compilazione. Ad esempio:

$ ls -l $HOME/cuda/bin 
total 16 
lrwxr-xr-x 1 talonmies koti 16 Feb 9 12:41 g++ -> /usr/bin/g++-4.2 
lrwxr-xr-x 1 talonmies koti 16 Feb 9 12:41 gcc -> /usr/bin/gcc-4.2 

Qui ho una serie di collegamenti a un compilatore supportato. Ho poi possono compilare in questo modo:

$ nvcc --compiler-bindir=$HOME/cuda/bin -c -arch=sm_12 -Xptxas="-v" nanobench.cu 
ptxas info : 0 bytes gmem 
ptxas info : Compiling entry function '_Z5benchIfLi128000EEvPjPT_i' for 'sm_12' 
ptxas info : Used 5 registers, 28 bytes smem, 12 bytes cmem[1] 

Questo è probabilmente il modo più sicuro e meno invasivo per utilizzare i compilatori alternativi in ​​cui il compilatore sistema non è supportato.

+0

Ok, ma se si dice che gcc-4.6 è compatibile e ho già gcc-4.6, mi manca solo g ++ - 4.6, no? – elect

+0

Sì, funzionante, mi mancava il collegamento a g ++ - 4.6, l'ho installato e ho creato un collegamento in /cuda-5.0/bin/g++ in /usr/bin/g++-4.6. Grazie talonmie – elect

+0

Btw, puoi solo confermarmi se i link g ++ e gcc originali puntassero rispettivamente a/usr/bin/g ++ e/usr/bin/gcc? – elect

2

Come trovate altrove:

su -c 'update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 10' 
sudo update-alternatives --config gcc 

lavorato per me. Comunque sto compilando CudaMiner.

Problemi correlati