"Maximum variable size allowed on the device is exceeded." when using predict on GPU
이전 댓글 표시
Hello there,
I have a neural net and want to do a prediction using predict. When I do that I get the error
Error using dlnetwork/predict
Execution failed during layer(s) 'fc1'.
Caused by:
Error using parallel.internal.gpu.mtimesAdd
Maximum variable size allowed on the device is exceeded.
Afaik it's because on GPU Matlab only supports 2^32 elements in one array. Whats the best way to circumvent this?
I know I can disable the GPU completely by setting CUDA_VISIBLE_DEVICES to -1, but I still want to use it in other functions.
The data I pass into predict is a normal array and not a gpuarray.
Is there a way to force predict to use CPU?
Cheers
채택된 답변
추가 답변 (1개)
Shivam Lahoti
2024년 10월 30일
0 개 추천
Hi hanspeter,
I understand you are encountering a “Maximum variable size allowed on the device is exceeded" error when using predict on a GPU.
As you mentioned, the current maximum number of elements allowed in a gpuArray is intmax('int32'), or 2^31. This is because CUBLAS passes array lengths as int (int32_T). This is a known limitation and is mentioned in the documentation link below:
Moreover, none of the following can exceed intmax('int32'):
- The number of elements of a dense array.
- The number of nonzero elements of a sparse array.
- The size in any given dimension. For example, zeros(0,3e9,'gpuArray') is not allowed.
I hope this helps you understand the issue.
Regards,
Shivam
카테고리
도움말 센터 및 File Exchange에서 Parallel and Cloud에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!