[vtk-developers] Hi, can I compile a code using CUDA C and VTK?

Robert Maynard robert.maynard at kitware.com
Tue Apr 30 10:03:29 EDT 2013


Here is an example CMakeLists.txt that combines VTK file reading and cuda.

project(Example)

#you should only need a couple vtk libraries
find_package(VTK 6.0
  COMPONENTS
  vtkCommonCore
  vtkCommonDataModel
  vtkCommonExecutionModel
  vtkIOLegacy
  REQUIRED)

find_package(CUDA REQUIRED)

#since we don't have any vtk factories this will work.
include(${VTK_USE_FILE})

#list your cuda and c++ source files
set(sources
  main.cpp
  cuda_example.cu
  )

cuda_add_executable(example ${sources})
target_link_libraries(example
  vtkCommonCore
  vtkCommonDataModel
  vtkCommonExecutionModel
  vtkIOLegacy)

On Tue, Apr 30, 2013 at 9:51 AM, Joachim Pouderoux
<joachim.pouderoux at kitware.com> wrote:
> Mingcheng,
>
> I guess you will have a lot of difficulties to compile VTK with CUDA.
> You should better isolate your cuda code (no vtk dependency/header) in a
> cuda library that you will link together with VTK library against your C++
> code.
>
> Joachim Pouderoux
>
> PhD, R&D Engineer
> Kitware SAS
>
>
>
> 2013/4/30 Mingcheng Chen <linyufly at gmail.com>
>>
>> Hi Jean-Christophe,
>>
>> Thank you!
>>
>> I use VTK 6.0 and CUDA 5.0. I just need vtkUnstructuredGridReader to read
>> something in main.cpp and then everything is CUDA.
>>
>> Thanks again!
>>
>> Best regards,
>> Mingcheng Chen
>> April 29th, 2013
>>
>>
>> On Mon, Apr 29, 2013 at 6:54 PM, Jean-Christophe Fillion-Robin
>> <jchris.fillionr at kitware.com> wrote:
>>>
>>> Hi Mingcheng,
>>>
>>> To help identify the issue, could you specify which version of VTK you
>>> are building against. Providing a small example using either gist or github
>>> would be helpful.
>>>
>>> Hth
>>> Jc
>>>
>>>
>>> On Mon, Apr 29, 2013 at 6:16 PM, Mingcheng Chen <linyufly at gmail.com>
>>> wrote:
>>>>
>>>> Hi everyone,
>>>>
>>>> My code contains a main.cpp and several *.cu files. The main.cpp uses
>>>> some VTK functions.
>>>>
>>>> How can I make it compiled in ubuntu? In Windows I can use Visual
>>>> Studio.
>>>>
>>>> Is cmake able to do that? I failed...
>>>>
>>>> Thanks!
>>>>
>>>> Best regards,
>>>> Mingcheng Chen
>>>> April 29th, 2013
>>>>
>>>> --
>>>> Research Assistant in Graphics Group
>>>> University of Illinois at Urbana-Champaign
>>>> http://mingchengchen.org
>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> +1 919 869 8849
>>
>>
>>
>>
>> --
>> Research Assistant in Graphics Group
>> University of Illinois at Urbana-Champaign
>> http://mingchengchen.org
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>



More information about the vtk-developers mailing list