NVIDIAGameWorks / Falcor

Real-Time Rendering Framework
https://developer.nvidia.com/falcor
Other
2.54k stars 464 forks source link

Does Falcor support create a new Vulkan <-> CUDA shared buffer? #402

Open GensokyoLover opened 7 months ago

GensokyoLover commented 7 months ago

I have a training task running on linux,and need to get buffers from falcor. but when i tried to run the InteropBuffer::createInteropBuffer, it fails and i wonder if it only supports DX->CUDA?

skallweitNV commented 7 months ago

Yes, InteropBuffer is DX only as specified in the comment. It's also mostly just a deprecated/legacy class.

The better way is to use ExternalMemory defined in CudaUtils.h, or just use the new convenience API Buffer::getCudaMemory() directly. At least if you are working in C++. In Python code, you can access buffers as CUDA/pytorch tensors directly.

We don't have many Linux users yet, but I think we do run a few tests with shared buffers on internal Linux CI, so this should work.

GensokyoLover commented 7 months ago

Yes, InteropBuffer is DX only as specified in the comment. It's also mostly just a deprecated/legacy class.

The better way is to use ExternalMemory defined in CudaUtils.h, or just use the new convenience API Buffer::getCudaMemory() directly. At least if you are working in C++. In Python code, you can access buffers as CUDA/pytorch tensors directly.

We don't have many Linux users yet, but I think we do run a few tests with shared buffers on internal Linux CI, so this should work. really thanks for your reply,but i found codes below. maybe it can only run on windows&vulkan image

skallweitNV commented 7 months ago

true, that is windows only it seems

skallweitNV commented 7 months ago

can you try just adding this?

#if FALCOR_WINDOWS
    case Device::Type::Vulkan:
        desc.type = cudaExternalMemoryHandleTypeOpaqueWin32;
        break;
#elif FALCOR_LINUX
    case Device::Type::Vulkan:
        desc.type = cudaExternalMemoryHandleTypeOpaqueFd;
        break;
#endif

Edit: nope sorry, that won't work, you'd also need to set the handle on the correct field

GensokyoLover commented 7 months ago

can you try just adding this?

#if FALCOR_WINDOWS
    case Device::Type::Vulkan:
        desc.type = cudaExternalMemoryHandleTypeOpaqueWin32;
        break;
#elif FALCOR_LINUX
    case Device::Type::Vulkan:
        desc.type = cudaExternalMemoryHandleTypeOpaqueFd;
        break;
#endif

Edit: nope sorry, that won't work, you'd also need to set the handle on the correct field fine,i tried to use buffertonumpy and succeeded,cpu also meet my needs,thanks for your reply and advice