Error using gpuArray/subsasgn
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Tiki Tiki
 el 13 de Jun. de 2019
  
    
    
    
    
    Comentada: Edric Ellis
    
      
 el 17 de Jun. de 2019
            Hi everyone
I am working on GPU. I have a problem with it. I try to assign to a gpu Array. but i get this error. 
it is working on CPU, however GPU is not.
"Error using gpuArray/subsasgn
When assigning into a GPUArray, the subscripts must contain unique values. Subscript 1 contained repeated values."
can you tell me how to solve this error? 
Thanks
0 comentarios
Respuesta aceptada
  Edric Ellis
    
      
 el 14 de Jun. de 2019
        You can avoid this error by ensuring that your subscript contains only unique values, using the MATLAB function unique. For example:
gvec = gpuArray(1:100);
% Indexes to assign - contains repeated indices
idxs = [1 1 2 3];
% Values to assign
vals = rand(1, 4);
% This would get an error - the assignment happens in parallel on the GPU, 
% so which value should gvec(1) get - vals(1) or vals(2)?
%gvec(idxs) = vals;
% Use UNIQUE on idxs
[uniqueIdxs, locOfUniqueIdxs] = unique(idxs);
% Assign using only the unique indices, and the corresponding values
gvec(uniqueIdxs) = vals(locOfUniqueIdxs);
2 comentarios
  Guangyi Zhang
 el 14 de Jun. de 2019
				my problem is "Error, gpuArray/subsasgn
Sparse gpuArrays are not supported for this function."
how to solve that?
  Edric Ellis
    
      
 el 17 de Jun. de 2019
				You cannot modify sparse gpuArray data once you have put it on the GPU - you should set up the data as you want it to be, then send it to the GPU.
Más respuestas (0)
Ver también
Categorías
				Más información sobre GPU Computing in MATLAB en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!