Matlab gpuArray doesn't work with sparse arrays
Show older comments
The Matlab gpuArray works perfectly for non-sparse matrices, e.g., x=gpuArray(eye(1)).
But when the input changed to sparse arrays, e.g., x=gpuArray(speye(1)), I got the following error message
Error using gpuArray
An unexpected error occurred on the device. The error code was: UNKNOWN_ERROR.
How can I fix it?
My gpu is RTX 4090 with nvidia game ready driver 528.29, cuda version 12.0,
My gpuDevice outputs the following results
CUDADevice with properties:
Name: 'NVIDIA GeForce RTX 4090'
Index: 1
ComputeCapability: '8.9'
SupportsDouble: 1
DriverVersion: 12
ToolkitVersion: 11.2000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152 (49.15 KB)
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 25756696576 (25.76 GB)
AvailableMemory: 23916261376 (23.92 GB)
MultiprocessorCount: 128
ClockRateKHz: 2535000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
7 Comments
Walter Roberson
on 19 Feb 2023
Have you installed Update 4 of R2022b?
Bruno Luong
on 19 Feb 2023
AFAIK the current update for R2022b is still Update 3.
It looks like the premature Update 4 had issue and they withdraw it.
Joss Knight
on 19 Feb 2023
This looks like a problem specific to Ada cards (compute capability 8.9). Can you please contact MathWorks support?
Walter Roberson
on 19 Feb 2023
Edited: Walter Roberson
on 19 Feb 2023
unfortunately I cannot verify from my phone, but the recent Question about that had someone from Mathworks say that Update 4 had been restored except for offline installation.
雨文
on 19 Feb 2023
Bruno Luong
on 19 Feb 2023
@Walter Roberson "someone from Mathworks say that Update 4 had been restored"
Not seeing anything showed up on my side.
雨文
on 19 Feb 2023
Answers (1)
Animesh
on 12 May 2023
Hi,
I understand that when you try to create sparse array/matrix on a GPU, it pops an error whereas when try for normal arrays/matrices on GPU it works fine.
This is a known issue with Ada Lovelace graphic cards and CUDA 11.2.
As a workaround the following steps can be helpful:
On Windows machine:
- Install the CUDA Toolkit version 11.3.
- Open MATLAB.
- Before executing any other command, execute the below two commands and ignore the warning message:
>> loadlibrary('E:\3rdparty\R2023a\9378850\win64\CUDA\bin\cusparse64_11.dll', 'E:\3rdparty\R2023a\9378850\win64\CUDA\include\cuComplex.h', 'addheader', 'E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusparse.h', 'addheader','E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusparse.h');
>> loadlibrary('E:\3rdparty\R2023a\9378850\win64\CUDA\bin\cusolver64_11.dll', 'E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusolver_common.h', 'addheader', 'E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusolverDn.h', 'addheader','E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusolverMg.h', 'addheader', 'E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusolverRf.h', 'addheader','E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusolverSp.h', 'addheader', 'E:\3rdparty\R2023a\9378850\win64\CUDA\include\cusolverSp_LOWLEVEL_PREVIEW.h');
4. Execute your code.
On Linux machine:
- Install the CUDA Toolkit version 11.3.
- Before opening MATLAB, open a terminal and set the environment variable ‘LD_PRELOAD’ to point to paths of cuSPARSE and cuSOLVER libraries of the CUDA version 11.3.
setenv LD_PRELOAD /usr/local/cuda-11.3/lib64/libcusolver.so.11.1.1.58:/usr/local/cuda-11.3/lib64/libcusolver.so:/usr/local/cuda-11.3/lib64/libcusolver.so.11:/usr/local/cuda-11.3/lib64/libcusparse.so:/usr/local/cuda-11.3/lib64/libcusparse.so.11:/usr/local/cuda-11.3/lib64/libcusparse.so.11.5.0.58
3. Open MATLAB and execute your code.
I hope this helps.
Categories
Find more on Parallel and Cloud in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!