2013-02-09 12 views
7

ja otrzymuję ten błądCUDA i gcc kompatybilność problem

/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

W host_config.h one zapewnić kompatybilność do 4,6

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

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

mam zarówno 4.6 i 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

Szukając w Internecie, sugerują, aby dodać link do gcc-4.6 w katalogu bin cuda.

Więc zrobiłem

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

i dostaję kolejny błąd

**** 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 **** 

googlowania znów nie przyniósł mi na jakichś jasnych sytuacjach (GCC obniżenia, etc)

więc jestem z pytaniem, jaki jest teraz problem, ponieważ CUDA ma być kompatybilna z gcc-4.6 ...

Mój system:

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

Jest to kod poradnik Próbuję skompilować w momencie

/** 
* 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

Czy oprócz CUDA macie do czynienia z czystym C-Code? A może to C++? – Bart

+0

@bart: nvcc wymaga działającego wspieranego kompilatora C++ – talonmies

+0

@Bart W tej chwili czysty C (dodałem jakiś dodatkowy kod) – elect

Odpowiedz

5

Problem wynika z tego, że toolchain CUDA nie może znaleźć poprawnego kompilatora C++. nvcc jest tylko sterownikiem kompilatora, wymaga kompilatora C++ do kompilowania dowolnego kodu.

Najbardziej poprawny sposób na to [zauważ, że używasz nieobsługiwanej wersji Linuksa, więc skorzystaj z tej porady na własne ryzyko], jest utworzenie lokalnego katalogu zawierającego linki do obsługiwanego zestawu kompilatorów (to oznacza dopasowanie, obsługiwane wersje gcc i g ++) i przekazują argument --compiler-bindir do nvcc podczas kompilacji. Na przykład:

$ 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 

Tutaj mam zestaw linków do obsługiwanego kompilatora. I wtedy można skompilować tak:

$ 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] 

Prawdopodobnie jest to najbezpieczniejsza i najmniej inwazyjny sposób na wykorzystanie alternatywnych kompilatory gdzie kompilator system nie jest obsługiwany.

+0

Ok, ale jeśli mówi, że gcc-4.6 jest kompatybilny i już mam gcc-4.6, czy brakuje mi tylko g ++ - 4.6, nie? – elect

+0

Tak, działa, brakowało mi linku do g ++ - 4.6, zainstalowałem go i utworzyłem łącze w /cuda-5.0/bin/g++ do /usr/bin/g++-4.6. Dzięki, talonmies – elect

+0

Btw, czy możesz mi tylko potwierdzić, jeśli oryginalne linki g ++ i gcc wskazywały odpowiednio na/usr/bin/g ++ i/usr/bin/gcc? – elect

2

Jak znaleźć gdzie indziej:

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

pracował dla mnie. Kompiluję CudaMiner.

Powiązane problemy