J'essaie de résoudre un problème des moindres carrés via la fonction "magma_dgels_gpu()" de la bibliothèque MAGMA. Mon GPU est "Tesla C2050/C2075" et j'ai installé MAGMA.MAGMA: fonction "magma_dgels_gpu" -> erreur "magma_dans_t"
Je suis en train de compiler le code ci-dessous "testMagmaDGELS.cu", mais j'obtiens l'erreur:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <cublas.h>
#include "magma.h"
#define UTILS_MALLOC(__ptr, __type, __size) \
__ptr = (__type*)malloc((__size) * sizeof(__type)); \
if (__ptr == 0) { \
fprintf (stderr, "!!!! Malloc failed for: %s\n", #__ptr); \
exit(-1); \
}
#define UTILS_DEVALLOC(__ptr, __type, __size) \
if(cudaSuccess != cudaMalloc((void**)&__ptr, (__size)*sizeof(__type))){ \
fprintf (stderr, "!!!! cudaMalloc failed for: %s\n", #__ptr); \
exit(-1); \
}
int main(int argc, char** argv)
{
if(CUBLAS_STATUS_SUCCESS != cublasInit()) {
fprintf(stderr, "CUBLAS: Not initialized\n"); exit(-1);
}
double *devA, *devB, *pWork, lWorkQuery[1];
const int M = 5, N = 3;
int ret, info;
/* Allocate device memory for the matrix (column-major) */
int lda = M;
int ldda = ((M + 31)/32) * 32;
UTILS_DEVALLOC(devA, double, ldda * N);
UTILS_DEVALLOC(devB, double, M);
/* Initialize the matrix */
double A[N][M] = {{ 0.6, 5.0, 1.0, -1.0, -4.2 },
{ 1.2, 4.0, -4.0, -2.0, -8.4 },
{ 3.9, 2.5, -5.5, -6.5, -4.8 }};
cublasSetMatrix(M, N, sizeof(double), A, lda, devA, ldda);
double B[M] = {3.0, 4.0, -1.0, -5.0, -1.0};
cublasSetMatrix(M, 1, sizeof(double), B, M, devB, M);
/* Resolve the LLSP using MAGMA */
ret = magma_dgels_gpu('N', M, N, 1 /* nb of colums in the matrix B */,
devA, ldda, devB, M,
lWorkQuery, -1, // query the optimal work space
&info);
if (info < 0) {
printf("Argument %d of magma_dgels_gpu had an illegal value.\n", -info);
exit(1);
} else if (ret != MAGMA_SUCCESS) {
printf("magma_dgels_gpu failed (code %d).\n", ret);
exit(1);
}
int lwork = (int)lWorkQuery[0];
printf("Optimal work space %d\n", lwork);
UTILS_MALLOC(pWork, double, lwork);
ret = magma_dgels_gpu('N', M, N, 1 /* nb of colums in the matrix B */,
devA, ldda, devB, M,
pWork, lwork,
&info);
if (info < 0) {
printf("Argument %d of magma_dgels_gpu had an illegal value.\n", -info);
exit(1);
} else if (ret != MAGMA_SUCCESS) {
printf("magma_dgels_gpu failed (code %d).\n", ret);
exit(1);
} else {
printf("LLSP solved successfully\n");
}
cublasGetMatrix(M, 1, sizeof(double), devB, M, B, M);
/* Expected solution vector: 0.953333 -0.843333 0.906667 */
printf("Solution vector:\n");
for (int i = 0; i < N; i++) {
printf("\t%lf\n", B[i]);
}
/* Memory clean up */
free(pWork);
cudaFree(devA);
cudaFree(devB);
/* Shutdown */
cublasShutdown();
return 0;
}
Je fais compiler comme suit:
nvcc -arch = sm_20 testMagmaDGELS.cu -o testMagmaDGELS -lcublas -I/opt/magma/1.7.0/openblas/gcc/include
Et je reçois ces erreurs:
[email protected]:~$ nvcc -arch=sm_20 testMagmaDGELS.cu -o testMagmaDGELS -lcublas -I/opt/magma/1.7.0/openblas/gcc/include
testMagmaDGELS.cu(54): error: argument of type "char" is incompatible with parameter of type "magma_trans_t"
testMagmaDGELS.cu(70): error: argument of type "char" is incompatible with parameter of type "magma_trans_t"
2 errors detected in the compilation of "/tmp/tmpxft_00002d95_00000000-8_testMagmaDGELS.cpp1.ii".
Quelqu'un peut-il m'aider?
i get nouvelle erreur: tmpxft_00003662_00000000-3_testMagmaDGELS.cudafe1.cpp :(texte + 0x45e):. Undefined reference to 'magma_dgels_gpu » collect2: Erreur: ld retourné 1 état de sortie – wasilis
C'est une autre question. Cela signifie que vous n'êtes pas lié à la bibliothèque de magma nécessaire. Essayez d'ajouter '-L/opt/magma/1.7.0/lib -lmagma' à votre ligne de commande de compilation. –
Maintenant, je reçois:/usr/bin/ld: avertissement: libopenblas.so.0, requis par /opt/magma/1.7.0/openblas/gcc/lib/libmagma.so, pas trouvé (essayez d'utiliser -rpath ou - rpath-link) et ensuite beaucoup de références comme celle-ci: "/opt/magma/1.7.0/openblas/gcc/lib/libmagma.so: référence non définie à' dorgql_ '" – wasilis