필터 지우기
필터 지우기

How to use GPU with your matlab program?

조회 수: 3 (최근 30일)
Virtualkeeda
Virtualkeeda 2021년 5월 24일
댓글: Virtualkeeda 2021년 7월 7일
Recently I purchased a laptop (with GPU) so that my matlab programs can run faster. However, I am unaware of the process of utilizing GPU in a program? is that even a thing?
Do I need to used some special functions or acticate GPU in my program so that the GPU is utilized properly?

채택된 답변

KSSV
KSSV 2021년 5월 24일
편집: KSSV 2021년 5월 24일
To run your code in GPU, you need not to do much. It is very easy and straight forward. You need to place the variable/ data into GPU using the function gpuarray . Read here: https://in.mathworks.com/help/parallel-computing/gpuarray.html
If the variable is of class GPU, it will be placed in GPU and all the operations you do will be on GPU. Most of the functions support gpu calculations. Find it here: https://in.mathworks.com/help/referencelist.html?type=function&capability=gpucodegen
Example:
% Multiplication of matrices in GPU
A = rand(100) ;
B = rand(100) ;
C = A*B ; % runs on CPU
%
A_gpu = gpuarray(A) ;
B_gpu = gpuarray(B) ;
C_gpu = A*B ; % runs on GPU
Running on GPU is easy and straight forward. Read here: https://in.mathworks.com/help/parallel-computing/run-matlab-functions-on-a-gpu.html
  댓글 수: 2
Virtualkeeda
Virtualkeeda 2021년 5월 24일
oh ok. Thanks, I will update my program accordingly.
I more thing, So if I want to run the program on a server (cluster or a HPC), then again I just need to use this gpuArray and it will work??
Virtualkeeda
Virtualkeeda 2021년 7월 7일
Hello @KSSV,
I have computations on structs in my code with a label identifier and other numerical values. What I could understand is I can use gpuArray only for numerical computations but whenever it encounter a local operation, it doesnt work. Is there a way out of this problem?
Can you please help?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by