[Rtk-users] cast itk:::Image to itk::CudaImage

Chao Wu wuchao04 at gmail.com
Wed Jan 30 12:17:04 EST 2019


L.S.,

I encouter recently the "Cuda Error # 3" with a Quadro P4000 when running
rtkfdk, but I am not sure if the cause is the same as Tao's problem.
CUDA_CHECK() marks Driver API error with a "#" whereas Runtime API error
with a ":", so it is CUresult 3 (CUDA_ERROR_NOT_INITIALIZED).
Indeed when I add CUDA_CHECK to cuInit(0) in itkCudaContextManager.cxx I
already got an CUresult 100 (CUDA_ERROR_NO_DEVICE) here.
In the same itkCudaContextManager.cxx file, itk::CudaGetAvailableDevices
(which calls Runtime API) works well, so only Driver API doesn't work
properly.
The same build works fine with a Tesla P40.

I don't have time to investigate further but I found on my computer a
previous build based on commit 5717b6d02675ee10f03200038566f06dfcc2ad19 in
May 2018 doesn't have this issue with the Quadro card.
So I guess it shouldn't be the problem of the card or the driver, but a
problem induced by a later commit.

Best regards,
Chao

Andreas Andersen <andreasga22 at gmail.com> 于2019年1月30日周三 下午5:33写道:

> I've encountered the "Cuda Error # 3" issue two times.
> As far as I remember, both were caused by the GPU being unreachable at
> runtime:
> * A missing or outdated (relative to CUDA version) nVidia driver
> * The code running within a non-native environment.
> The second point can also be triggered if the binary is located on remote
> storage.
>
> However, both of these cases were on Windows, and by the path
> "/home/tsun/bin/" I would guess you're on some Linux distro.
>
> /Andreas
>
> __________________________________
>
> Andreas Gravgaard Andersen
>
> Department of Oncology,
>
> Aarhus University Hospital
>
> Nørrebrogade 44,
>
> 8000, Aarhus C
>
> Mail:     agravgaard at protonmail.com
>
> Cell:      +45 3165 8140
>
>
> On Wed, 30 Jan 2019 at 17:29, Simon Rit <simon.rit at creatis.insa-lyon.fr>
> wrote:
>
>> Can you send the code if you want us to help?
>>
>> On Wed, Jan 30, 2019 at 5:21 PM tao sun <colddiesun at gmail.com> wrote:
>>
>>> No I am not using that. But the error was thrown before GRAFT() function
>>> was called. It happens when I initialized the backprojector:
>>>  bp = rtk::CudaRayCastBackProjectionImageFilter::New().
>>>
>>> Tao
>>>
>>> Simon Rit <simon.rit at creatis.insa-lyon.fr> 於 2019年1月30日 週三 上午11:13寫道:
>>>
>>>> Are you using the HEAD version of the git ? Because I recently
>>>> corrected a bug in the Graft function (commit
>>>> b2d73642ce171ba9890af2c107a1a31f923454b5).
>>>> Simon
>>>>
>>>> On Wed, Jan 30, 2019 at 5:05 PM tao sun <colddiesun at gmail.com> wrote:
>>>>
>>>>> Hi Simon,
>>>>>
>>>>> CUDA_HAVE_GPU is on. So is CUDA_FOUND. I can run examples like
>>>>> rtkfdk with gpu on without any problem though,
>>>>> By the way I am using CUDA 9.2.88.
>>>>>
>>>>> Tao
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Simon Rit <simon.rit at creatis.insa-lyon.fr> 於 2019年1月30日 週三 上午1:25寫道:
>>>>>
>>>>>> Hi,
>>>>>> No, not really. In my experience, this occurs mainly when you don't
>>>>>> have a GPU properly configured for CUDA. Can you check the value of
>>>>>> CUDA_HAVE_GPU in cmake ? If it's OFF, then this is indeed the problem.
>>>>>> Simon
>>>>>>
>>>>>> On Wed, Jan 30, 2019 at 1:23 AM tao sun <colddiesun at gmail.com> wrote:
>>>>>>
>>>>>>> Hi again,
>>>>>>>
>>>>>>> Finally I got time to work on this. I was able to compile the
>>>>>>> program this time using the Graft() function. However, there's a runtime
>>>>>>> error when I run the program:
>>>>>>>
>>>>>>>
>>>>>>> /home/tsun/bin/RTK-1.4.0/utilities/ITKCudaCommon/src/itkCudaDataManager.cxx:38
>>>>>>> @ unknown : Cuda Error #3
>>>>>>>     terminate called after throwing an instance of
>>>>>>> 'itk::ExceptionObject'
>>>>>>>     what():
>>>>>>> /home/tsun/bin/RTK-1.4.0/utilities/ITKCudaCommon/src/itkCudaDataManager.cxx:38:
>>>>>>>     Cuda Error # 3
>>>>>>>     Aborted
>>>>>>>
>>>>>>> It happens when a new gpu backprojector is created:
>>>>>>>     bp = rtk::CudaRayCastBackProjectionImageFilter::New();
>>>>>>>
>>>>>>> Any insights for this?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Tao
>>>>>>>
>>>>>>> tao sun <colddiesun at gmail.com> 於 2019年1月19日 週六 下午8:51寫道:
>>>>>>>
>>>>>>>> Thank you all! I will give a try using your solutions.
>>>>>>>> Tao
>>>>>>>>
>>>>>>>> Simon Rit <simon.rit at creatis.insa-lyon.fr> 於 2019年1月17日 週四
>>>>>>>> 上午12:26寫道:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>> That's one solution. Two other:
>>>>>>>>> - graft the output to a Cuda image
>>>>>>>>> itk::CudaImage<float, 3>::Pointer cuImg = itk::CudaImage<float,
>>>>>>>>> 3>::New();
>>>>>>>>> cuImg->Graft(projectionReader->GetOutput())
>>>>>>>>> - use the rtk::ImportImageFilter which is templated over image
>>>>>>>>> type to allow precisely this (I used it in Gate here
>>>>>>>>> <https://github.com/OpenGATE/Gate/blob/develop/source/digits_hits/src/GateFixedForcedDetectionActor.cc#L1583>
>>>>>>>>> ).
>>>>>>>>> Best regards,
>>>>>>>>> Simon
>>>>>>>>>
>>>>>>>>> On Wed, Jan 16, 2019 at 11:06 PM Andreas Andersen <
>>>>>>>>> andreasga22 at gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Tao,
>>>>>>>>>>
>>>>>>>>>> I think you want the CastImageFilter
>>>>>>>>>> <https://itk.org/Doxygen/html/classitk_1_1CastImageFilter.html>
>>>>>>>>>> from ITK.
>>>>>>>>>>
>>>>>>>>>> Something like this:
>>>>>>>>>> using castToImageType = itk::CastImageFilter<itk:::Image<float,3>
>>>>>>>>>> , itk::CudaImage<float,3>>;
>>>>>>>>>> typename castToImageType::Pointer castfilter =
>>>>>>>>>> castToImageType::New();
>>>>>>>>>> castfilter->SetInput(projectionReader->GetOutput());
>>>>>>>>>> castfilter->Update();
>>>>>>>>>> auto cuda_image = castfilter->GetOutput();
>>>>>>>>>>
>>>>>>>>>> Best regards Andreas
>>>>>>>>>>
>>>>>>>>>> __________________________________
>>>>>>>>>>
>>>>>>>>>> Andreas Gravgaard Andersen
>>>>>>>>>>
>>>>>>>>>> Department of Oncology,
>>>>>>>>>>
>>>>>>>>>> Aarhus University Hospital
>>>>>>>>>>
>>>>>>>>>> Nørrebrogade 44,
>>>>>>>>>>
>>>>>>>>>> 8000, Aarhus C
>>>>>>>>>>
>>>>>>>>>> Mail:     agravgaard at protonmail.com
>>>>>>>>>>
>>>>>>>>>> Cell:      +45 3165 8140
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Wed, 16 Jan 2019 at 22:59, tao sun <colddiesun at gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I have read in some image using  itk::ImportImageFilter.
>>>>>>>>>>>  ImportFilterType::Pointer projectionReader =
>>>>>>>>>>> ImportFilterType::New();
>>>>>>>>>>> ...
>>>>>>>>>>>  projectionReader->Update();
>>>>>>>>>>>
>>>>>>>>>>> The type of the image is itk:::Image<float,3>. I wonder if there
>>>>>>>>>>> is any way I can cast it to itk::CudaImage<float,3>?
>>>>>>>>>>> In rtkforwardprojections.cxx the imageReaderType is defined as
>>>>>>>>>>> CudaImageType so there is no such problem.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> Tao
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> Rtk-users mailing list
>>>>>>>>>>> Rtk-users at public.kitware.com
>>>>>>>>>>> https://public.kitware.com/mailman/listinfo/rtk-users
>>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Rtk-users mailing list
>>>>>>>>>> Rtk-users at public.kitware.com
>>>>>>>>>> https://public.kitware.com/mailman/listinfo/rtk-users
>>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>> Rtk-users mailing list
>>>>>>> Rtk-users at public.kitware.com
>>>>>>> https://public.kitware.com/mailman/listinfo/rtk-users
>>>>>>>
>>>>>> _______________________________________________
>> Rtk-users mailing list
>> Rtk-users at public.kitware.com
>> https://public.kitware.com/mailman/listinfo/rtk-users
>>
> _______________________________________________
> Rtk-users mailing list
> Rtk-users at public.kitware.com
> https://public.kitware.com/mailman/listinfo/rtk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/rtk-users/attachments/20190130/e6a175d2/attachment-0001.html>


More information about the Rtk-users mailing list