[HDK] Create a NanoVDB grid using a Cuda Device Buffer ?

   1114   9   3
User Avatar
Member
29 posts
Joined: 4月 2017
Offline
Hey folks, I'm struggling with some linker issues when trying to initialize a NanoVDB Grid or even convert a OpenVDB Grid to NanoVDB using a
nanovdb::CudaDeviceBuffer
instead of a
nanovdb::HostBuffer
My project is Open Source if anyone has time to dive in : https://github.com/ZephirFXEC/HNanoSolver [github.com]

Otherwise, here's some more details :
I'm following this example : https://github.com/AcademySoftwareFoundation/openvdb/tree/master/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda [github.com]

There's my code to first convert a regular GridCPtr to a const openvdb::FloatGrid then to a NanoVDB grid :
const auto densityFloatGrid = openvdb::gridConstPtrCast<openvdb::FloatGrid>(density);
// Converts the OpenVDB to NanoVDB and returns a GridHandle that uses CUDA for memory management.
auto handle = nanovdb::createNanoGrid<openvdb::FloatGrid, float, nanovdb::CudaDeviceBuffer>(*densityFloatGrid); 

Where this line to convert throws this linking error :
error LNK2019: unresolved external symbol "public: __cdecl nanovdb::GridHandle<class nanovdb::CudaDeviceBuffer>::GridHandle<class nanovdb::CudaDeviceBuffer><class nanovdb::CudaDeviceBuffer,0>(class nanovdb::CudaDeviceBuffer &&)" (??$?0VCudaDeviceBuffer@nanovdb@@$0A@@?$GridHandle@VCudaDeviceBuffer@nanovdb@@@nanovdb@@QEAA@$$QEAVCudaDeviceBuffer@1@@Z) referenced in function "private: class nanovdb::GridHandle<class nanovdb::CudaDeviceBuffer> __cdecl nanovdb::CreateNanoGrid<class openvdb::v11_0_sesi::Grid<class openvdb::v11_0_sesi::tree::Tree<class openvdb::v11_0_sesi::tree::RootNode<class openvdb::v11_0_sesi::tree::InternalNode<class openvdb::v11_0_sesi::tree::InternalNode<class openvdb::v11_0_sesi::tree::LeafNode<float,3>,4>,5> > > > >::initHandle<float,class nanovdb::CudaDeviceBuffer>(class nanovdb::CudaDeviceBuffer const &)" (??$initHandle@MVCudaDeviceBuffer@nanovdb@@@?$CreateNanoGrid@V?$Grid@V?$Tree@V?$RootNode@V?$InternalNode@V?$InternalNode@V?$LeafNode@M$02@tree@v11_0_sesi@openvdb@@$03@tree@v11_0_sesi@openvdb@@$04@tree@v11_0_sesi@openvdb@@@tree@v11_0_sesi@openvdb@@@tree@v11_0_sesi@openvdb@@@v11_0_sesi@openvdb@@@nanovdb@@AEAA?AV?$GridHandle@VCudaDeviceBuffer@nanovdb@@@1@AEBVCudaDeviceBuffer@1@@Z)
The same code works when using a nanovdb::HostBuffer.

I tried linking with every Cuda & Houdini Lib without success. I hope someone can help !

Thanks
Edited by ZephirFX - 2024年8月2日 15:47:01
Enzo C.
https://www.linkedin.com/in/enzocrema/ [www.linkedin.com]
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Does that example work by itself on Windows? That error doesn't seem related to the HDK.
User Avatar
Member
29 posts
Joined: 4月 2017
Offline
Hey,
So I just tried and managed to compile OpenVDB / NanoVDB and the example in question :
3>------ Build started: Project: ex_openvdb_to_nanovdb_cuda, Configuration: Debug x64 ------
3>Building Custom Rule C:/Users/zphrfx/Desktop/hdk/openvdb/nanovdb/nanovdb/examples/CMakeLists.txt
3>Compiling CUDA source file ..\..\..\..\nanovdb\nanovdb\examples\ex_openvdb_to_nanovdb_cuda\openvdb_to_nanovdb_cuda_kernel.cu...
3>openvdb_to_nanovdb_cuda_kernel.cu
3>tmpxft_0000356c_00000000-7_openvdb_to_nanovdb_cuda_kernel.cudafe1.cpp
3>openvdb_to_nanovdb_cuda.cc
3>   Creating library C:/Users/zphrfx/Desktop/hdk/openvdb/build/nanovdb/nanovdb/examples/Debug/ex_openvdb_to_nanovdb_cuda.lib and object C:/Users/zphrfx/Desktop/hdk/openvdb/build/nanovdb/nanovdb/examples/Debug/ex_openvdb_to_nanovdb_cuda.exp
3>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
3>ex_openvdb_to_nanovdb_cuda.vcxproj -> C:\Users\zphrfx\Desktop\hdk\openvdb\build\nanovdb\nanovdb\examples\Debug\ex_openvdb_to_nanovdb_cuda.exe
3>Done building project "ex_openvdb_to_nanovdb_cuda.vcxproj".
========== Build: 3 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 10:26 and took 02:10.260 minutes ==========

So there's a lib missing for Cuda somewhere in the HDK, or maybe the version of OpenVDB used for Houdini isn't available for the version of cuda i'm using ?

I'm currently using Cuda v12.5 and I just saw that Houdini uses Cuda v12.2 : https://www.sidefx.com/docs/houdini/licenses/index.html [www.sidefx.com]
Enzo C.
https://www.linkedin.com/in/enzocrema/ [www.linkedin.com]
User Avatar
Member
172 posts
Joined: 5月 2021
Offline
I am not sure that 12.5 support is widely adopted as it just released, but did you make sure that you are building against the Houdini OpenVDB lib and not just OpenVDB standalone from Github?

https://www.openvdb.org/documentation/doxygen/build.html [www.openvdb.org]
PHENOM(enological) DESIGN;
Experimental phenomenology (study of experience) is a category of philosophy evidencing intentional variations of subjective human experiencing where both the independent and dependent variable are phenomenological. Lundh 2020
User Avatar
Member
29 posts
Joined: 4月 2017
Offline
Yes i'm building against openvdb_sesi.lib

I'll try with Cuda 12.2 and see how it goes
Enzo C.
https://www.linkedin.com/in/enzocrema/ [www.linkedin.com]
User Avatar
Member
29 posts
Joined: 4月 2017
Offline
Same issue with Cuda 12.2...

Is there some sesi specific cuda libs ? I can only find some ONNX cuda runtime provider stuff.
Enzo C.
https://www.linkedin.com/in/enzocrema/ [www.linkedin.com]
User Avatar
Member
172 posts
Joined: 5月 2021
Offline
Sorry I cannot help any more than this as I am not building for CUDA hardware in my code base right now.

ZephirFX
Same issue with Cuda 12.2...
Is there some sesi specific cuda libs ?

I do see some CUDA stuff in the libs.

If I were to write CUDA Kernels, I would use the Warp Framework as the abstraction. It is a Differentiable JIT compilation python library to directly program CUDA kernels and I have used it in the past. You can Also compile CPP in it cause it is a compiler language but it should be as fast as you can get on your CUDA hardware. It also supports USD and NanoVDB:

https://christophercrouzet.com/blog/dev/nvidia-warp-houdini [christophercrouzet.com]

https://github.com/christophercrouzet/nvidia-warp-houdini [github.com]

https://nvidia.github.io/warp/ [nvidia.github.io]

https://developer.nvidia.com/blog/creating-differentiable-graphics-and-physics-simulation-in-python-with-nvidia-warp/ [developer.nvidia.com]

Another approach could be to use the InlineCPP to compile within Houdini, then grab that library afterward.
Edited by PHENOMDESIGN - 2024年8月4日 18:47:08
PHENOM(enological) DESIGN;
Experimental phenomenology (study of experience) is a category of philosophy evidencing intentional variations of subjective human experiencing where both the independent and dependent variable are phenomenological. Lundh 2020
User Avatar
Member
29 posts
Joined: 4月 2017
Offline
PHENOMDESIGN
Sorry I cannot help any more than this as I am not building for CUDA hardware in my code base right now.
Np

I cut a ticket to SESI, I'm waiting for them to answer since I'd rather find a solution than a workaround. But if I have no choices i'll look into those

Thanks
Enzo C.
https://www.linkedin.com/in/enzocrema/ [www.linkedin.com]
User Avatar
Member
1 posts
Joined: 12月 2024
Offline
Hello, have you solved it? I also encountered the same problem.
User Avatar
Member
29 posts
Joined: 4月 2017
Offline
w1755396536
Hello, have you solved it? I also encountered the same problem.
Hey, yes I solved it.
Make sure your CMakeLists.txt includes :
project(XXX LANGUAGES CXX CUDA)

# ------- Find CUDA -----------
find_package(CUDAToolkit REQUIRED)
string(APPEND CMAKE_CUDA_FLAGS " --extended-lambda")
set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
set(BUILD_SHARED_LIBS ON)

add_subdirectory(src/Cuda)
# ------- End CUDA -----------

Then in your .cpp / .cu file make sure you have :

#define NANOVDB_USE_OPENVDB
#include <NanoVDB.h> 
#include <nanovdb/util/CreateNanoGrids.h>

nanovdb::GridHandle<nanovdb::CudaDeviceBuffer> handle = nanovdb::CreateNanoGrid(*grid); //grid is a pointer to a openvdb grid
Enzo C.
https://www.linkedin.com/in/enzocrema/ [www.linkedin.com]
  • Quick Links