error when calling variables in GPU memory

조회 수: 10 (최근 30일)
Xiang Gao
Xiang Gao 2016년 11월 14일
편집: Joss Knight 2016년 11월 24일
When I try to call a variable stored in GPU after some calculations, the session seems to be no response.
a sample code looks like this:
a=gpuArray.rand(1e3)
for i=1:1e9
a.^3;
end
a
Then, Matlab has no response.
I am using Ubuntu 14.04 and three GeForce 680 cards. The GPU driver is at the version 370, and CUDA is 7.5. And Matlab can recongize these three GPUs by the function gpuDevice.

답변 (1개)

Joss Knight
Joss Knight 2016년 11월 17일
When you issue the command to display the variable a, MATLAB has to wait for all the one billion GPU kernel calls you have issued to finish. Did you intend to take the cube of a a billion times? or did you mean to cube each element of a, in which case you just need a = a.^3.
  댓글 수: 2
Xiang Gao
Xiang Gao 2016년 11월 21일
Thanks for your kind answers!
I am aware that it may take some time to display the variable a. But, in my case, it has taken for nearly one hour. So I think it might have some problem.
And the calculation about a is just an example. I did not intend to save the result.
Joss Knight
Joss Knight 2016년 11월 24일
편집: Joss Knight 2016년 11월 24일
On my K20 GPU gputimeit tells me it takes 0.6 milliseconds to compute the element-wise cube of a 1000x1000 matrix. To do this 1 billion times therefore will take 171 hours.
I believe you have a fundamental misunderstanding here. Do you understand that your code has asked your GPU to take the cube of a million billion (1000000000000000) numbers?

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

카테고리

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