Matlab gpuArray doesn't work with sparse arrays
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Bruno Luong
le 19 Fév 2023
@Walter Roberson "someone from Mathworks say that Update 4 had been restored"
Not seeing anything showed up on my side.
Réponses (1)
Animesh
le 12 Mai 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!