CUBLAS Speicherzuordnungsfehler
-
05-07-2019 - |
Frage
ich versuchte 17338896 Elemente Gleitkommazahlen zuzuteilen wie folgt (die in etwa 70 mb ist):
state = cublasAlloc(theSim->Ndim*theSim->Ndim,
sizeof(*(theSim->K0)),
(void**)&K0cuda);
if(state != CUBLAS_STATUS_SUCCESS) {
printf("Error allocation video memory.\n");
return -1;
}
Allerdings Ich erhalte Fehlermeldung von CUBLAS_STATUS_ALLOC_FAILED
für den variablen Zustand. Wäre das etwas mit der Menge der Grafikkarte verfügbaren Speicher auf der Maschine (128 mb auf Mine) oder wäre dies eine Grenze für die Menge an Speicher zu tun, die ich vergeben kann cublasAlloc () Funktion (dh nicht relevant für die Menge mit Speicher auf der Maschine verfügbar)? Ich habe versucht, mit cudaMalloc () Funktion und ich in das gleiche Problem leite. Vielen Dank im Voraus für die in diesen suchen.
-------------- Addition von Fehlern Reproduktion ----------------------------- --------
#include <cuda.h>
#include <stdio.h>
int main (int argc, char *argv[]) {
// CUDA setup
cublasStatus state;
if(cublasInit() == CUBLAS_STATUS_NOT_INITIALIZED) {
printf("CUBLAS init error.\n");
return -1;
}
// Instantiate video memory pointers
float *K0cuda;
// Allocate video memory needed
state = cublasAlloc(20000000,
sizeof(float),
(void**)&K0cuda);
if(state != CUBLAS_STATUS_SUCCESS) {
printf("Error allocation video memory.\n");
return -1;
}
// Copy K0 from CPU memory to GPU memory
// Note: before so, decide whether to integrate as a part of InsertionSim or
// CUDA content as a separate class
//state = cublasSetMatrix(theSim->Ndim, theSim->Ndim, sizeof(*theSim->K0),
// theSim->K0, theSim->Ndim, K0cuda, theSim->Ndim);
//if(state != CUBLAS_STATUS_SUCCESS) {
// printf("Error copy to video memory.\n");
// return -1;
//}
// Free memory
if(cublasFree(K0cuda) != CUBLAS_STATUS_SUCCESS) {
printf("Error freeing video memory.\n");
return -1;
}
// CUDA shutdown
if(cublasShutdown() != CUBLAS_STATUS_SUCCESS) {
printf("CUBLAS shutdown error.\n");
return -1;
}
if(theSim != NULL) delete theSim;
return 0;
}
Lösung
kann Speicher fragmentieren, was bedeutet, dass Sie immer noch mehrere kleinere Blöcke zuordnen kann, aber nicht ein einziger großer Block. Ihre Grafikkarte muss offensichtlich etwas Speicher für seine normale 2D-Aufgabe. Wenn das die 128 MB in 2 Blöcke von fast 64 MB brechen geschieht, dann würde man diese Art von Fehlern sehen.