<div dir="ltr"><div>Hi Simon, </div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>I'm not sure I understand but have you tried grafting the Image or CudaImage to an existing itk::Image (the Graft function)?<br></div><div></div></div></div></blockquote><div>I tried that but when I call <font face="courier new, monospace">itk.GetArrayFromImage(cuda_img)</font> on the grafted image (<font face="courier new, monospace">cpu_img.Graft(cuda_img)</font>) I get the error  <font face="courier new, monospace">```ValueError: PyMemoryView_FromBuffer(): info->buf must not be NULL``` </font><font face="arial, sans-serif">from within ITK (or its Python bindings).</font></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div></div><div>Again, I'm not sure I understand but you should be able to graft a CudaImage to another CudaImage.</div></div></div></blockquote><div> If anything I'd like to graft an Image into a CudaImage. When I try something like <span style="font-family:"courier new",monospace">`</span><font face="courier new, monospace">cuda_img.Graft(cpu_img)`</font> I get a TypeError. If this and the Graft'ing above would work (including the array view), that would be exactly my initial wish. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>You can always ask explicit transfers by calling the functions of the data manager (accessible via <span class="gmail-m_7394961722479210295gmail-pl-en">CudaImage::GetCudaDataManager</span>())</div><div></div></div></div></blockquote><div>I assume you mean <font face="courier new, monospace">manager.UpdateCPUBuffer()</font>? When I run that, the CPU image I used to create the GPU image (by <a href="https://github.com/SimonRit/RTK/blob/master/examples/FirstReconstruction/FirstCudaReconstruction.py#L64-L70">this</a>) is not updated. </div><div> </div><div>My scenario is this: I give a numpy array as a volume to be forward projected. I get a ImageView from that array, set origin and spacing of that image and transfer to GPU via <a href="https://github.com/SimonRit/RTK/blob/master/examples/FirstReconstruction/FirstCudaReconstruction.py#L64-L70">your method</a>. For the output projections, I use an ImageView from a numpy.zeros array with according shape, spacing and origin and transfer that to GPU the same way. I then use the CudaForwardProjection filter. Now I'd like to have the projection data on CPU. Unfortunately, none of the suggested methods worked for me other than using an <font face="courier new, monospace">itk.ImageDuplicator </font><font face="arial, sans-serif">on the CudaImage :(</font></div><div><br></div><div>Sorry for the lenghty mail. </div><div><br></div><div>Best</div><div>Clemens</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div><br></div><div>Best</div><div>Clemens</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mo., 8. Juli 2019 um 16:20 Uhr schrieb Simon Rit <<a href="mailto:simon.rit@creatis.insa-lyon.fr" target="_blank">simon.rit@creatis.insa-lyon.fr</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div>Conversion from Image to CudaImage is not optimal. The way I'm doing it now is shown in an example in <a href="https://github.com/SimonRit/RTK/blob/master/examples/FirstReconstruction/FirstCudaReconstruction.py#L64-L70" target="_blank">these few lines</a>. I am aware of the problem and discussed it on the <a href="https://discourse.itk.org/t/shadowed-functions-in-gpuimage-or-cudaimage/1614" target="_blank">ITK forum</a> but I don't have a better solution yet.</div><div>I'm not sure what you mean by explicitely transferring data from/to GPU but I guess you can always work with itk::Image and do your own CUDA computations in the GenerateData of the ImageFilter if you don't like the CudaImage mechanism.</div><div>I hope this helps,</div><div>Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 8, 2019 at 10:06 PM C S <<a href="mailto:clem.schmid@gmail.com" target="_blank">clem.schmid@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear RTK users,<div><br></div><div>I'm looking for a way to use exisiting ITK Images (either on GPU or in RAM) when transfering data from/to GPU. That is, not only re-using the Image object, but writing into the memory where its buffer is. </div><div><br></div><div>Why: As I'm using the Python bindings, I guess this ties in with ITK wrapping the CudaImage type. In <a href="https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32" target="_blank">https://github.com/SimonRit/RTK/blob/master/utilities/ITKCudaCommon/include/itkCudaImage.h#L32</a> I read that the memory management is done implicitly and the CudaImage can be used with CPU filters. However when using the bindings, only rtk.BackProjectionImageFilter can be used with CudaImages. The other filters complain about not being wrapped for that type. </div><div><br></div><div>That is why I want to explicitely transfer the data from/to GPU, but preferably using the exisiting Images and buffers. I can't rely on RTK managing GPU memory implicitly.</div><div><br></div><div><br></div><div>Thank you very much for your help!</div><div>Clemens</div><div><br></div><div><br></div></div>
_______________________________________________<br>
Rtk-users mailing list<br>
<a href="mailto:Rtk-users@public.kitware.com" target="_blank">Rtk-users@public.kitware.com</a><br>
<a href="https://public.kitware.com/mailman/listinfo/rtk-users" rel="noreferrer" target="_blank">https://public.kitware.com/mailman/listinfo/rtk-users</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div></div>