x=gmatrix(grnorm(100),10,10, type='d') #this makes an unneeded duplication
x=gmatrix(grnorm(100),10,10, dup=FALSE) #this avoids the duplication
#problematic code
x=grnorm(100)
y=as.gmatrix(x,10,10, dup=FALSE) #don't do this
y[1,1]=100 #this changes both y and x because both point to the same spot in GPU memory
x
Run the code above in your browser using DataLab