简体   繁体   中英

Using MATLAB's function with CUDA GPU variables

After converting a 2D array from the CPU to the GPU's memory to run on the GPU I face multiple errors from Matlab's builtin functions such minmax(array) stating that my GPU variable is not an array or a cell:

??? Error using ==> minmax at 27 Data is not a matrix or cell array.

Though the passed variable is a converted 2D array, but the type is changed from <11x4096 double> to <11x4096 parallel.gpu.GPUArray> .

Anyone can help me make Matlab understand that the GPU variable is an array?

Thanks all.

Only a small subset of MATLAB commands are supported for arrays stored on the GPU (ie arrays of type GPUArray).

See this documentation page from Parallel Computing Toolbox for details of which functions are supported. You'll notice that the list contains exclusively functions from base MATLAB such as arithmetic, exponential, and trigonometric functions, linear algebra and Fourier transforms; nothing close to the higher-level toolbox functions such as minmax from Neural Network Toolbox.

Overloading a function for GPUArray input, so that it executes on the GPU rather than CPU, is a major job involving a reimplementation of the algorithm for the new and highly parallel architecture. In addition, only certain types of highly parallel algorithm will typically benefit from GPU parallelism. I therefore wouldn't expect MathWorks to provide GPUArray support in Neural Network Toolbox any time soon.

If you specifically need to parallelize minmax on the GPU, rather than neural networks in general, it wouldn't be that hard to do it yourself - probably just a couple of lines involving min , max and arrayfun .

Having said that, the error message could provide a lot more explanation of the problem. It looks like the developers know this as well: if you type edit nntype.data and look at line 93, which is where the error message comes from, you'll see the comment line % TODO - More detailed response . Nice!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM