2009-10-21 4 views
1

난 (대략 70메가바이트 임)는 다음과 같이 부동 소수점 숫자의 17,338,896 요소를 할당하려고. 이것은 컴퓨터에서 사용할 수있는 비디오 카드 메모리의 양 (광산에서 128MB)과 관련이 있거나 이것이 cublasAlloc() 함수를 사용하여 할당 할 수있는 메모리 양의 한계가 될 수 있습니까? 컴퓨터에서 사용할 수있는 메모리 용량)? 나는 cudaMalloc() 함수를 사용하여 시도하고 같은 문제가 실행되고있다. 이것을 조사해 주셔서 미리 감사드립니다.CUBLAS 메모리 할당 에러

-------------- 오류 복제 추가 ----------------------------- ---------

#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; 
} 
+0

이것은 프로그램의 첫 번째 VRAM 할당입니까? cudaMalloc()을 사용하여 문제없이 메모리 블록을 할당했습니다. 최소한의 재현 만 제공 할 수 있을까요? – Gabriel

+0

예, 그렇습니다. 최소 재생산을 위해 무엇을보고 싶습니까? – stanigator

+0

최소 재생산은 오류를 생성하는 가장 작은 완전한 프로그램입니다. 필요한 것 이상으로, C 파일로 복사/붙여 넣기, 컴파일, 링크 및 실행할 수있는 것이 이상적입니다. 귀하의 설명을 감안할 때, 그것은 C의 몇 라인 이상이어야합니다. – Gabriel

답변

5

메모리가 조각화 될 수 있습니다. 즉, 여러 개의 작은 블록을 할당 할 수 있지만 하나의 큰 블록을 할당 할 수는 없습니다. 귀하의 비디오 카드는 분명히 정상적인 2D 작업을 위해 약간의 메모리가 필요할 것입니다. 그로 인해 128MB를 거의 64MB의 2 블록으로 나눈다면 이런 종류의 실패를 볼 수 있습니다.

+0

귀하의 설명이 이치에 맞습니다. 적은 양의 메모리를 할당하고이 문제가 발생하지 않았습니다. 나는 이것이 더 큰지 여부를 확인하기 위해 더 많은 비디오 카드 메모리를 가진 다른 컴퓨터에서이를 테스트 할 것입니다. – stanigator