jakubMitura14 / HousdorffHDF5cMake

The Unlicense
0 stars 0 forks source link

Use in PyTorch #1

Open Chris-N-K opened 2 years ago

Chris-N-K commented 2 years ago

Hi, is there a not to hacky way of using your CUDA implementation of the Hausdorff algorithm in PyTorch?

Thanks for any reply in advance and nice work tuning the algorithm to this degree, Chris

jakubMitura14 commented 2 years ago

yes I implemented it as pytorch extension also https://github.com/jakubMitura14/Hausdorff_morphological.git

stillrunning pytorch extensions may be tricky so In repository there is also a dockerfile and devcontainer json so it can be run as a container in vs code (this last rather on ubuntu if you want CUDA acceleration)

in case you want to run it locally on Windows best to run from x64 native tools command prompt ov visual studio on windows 10 with cuda 11.3 installed and python 3.9

I am working on better documentations and examples but You can find example invocation code in check.py file

In case of problems do not hesitate to wite with futher questions, if you would not mind you can also leave some contact in case you would use it so I will ask for some feedback after some time :)

Chris-N-K commented 2 years ago

Thanks a lot for the reply. Will take a look :)

Chris-N-K commented 2 years ago

Good morning, sadly the link does not work, maybe broken or the git is private?

jakubMitura14 commented 2 years ago

yes it was private, check now :)

Chris-N-K commented 2 years ago

Thanks a lot @jakubMitura14, could take a look now. What would be your best guess to get it running on a debian10 environment running PyTorch 1.11.0? Simply cloning and installing with pip using the setup.py file did not workout well ^^' Get the FileNotFoundError for lltm_cuda.cpp when loading via torch.utils.cpp_extension.load.

jakubMitura14 commented 2 years ago

I cleared unnecessary files ; jit compilation work better like in check.py file, where did you put your file ? Docker is not an option? It would be the best and easy to set up in linux

Chris-N-K commented 2 years ago

I guess I was quite naive ^^ I have to put some files somewhere manually? Yes docker is no option.

jakubMitura14 commented 2 years ago

ok So maybe try to clone repository and inside in the same place as check py is located add code

from torch.utils.cpp_extension import load
lltm_cuda = load('lltm_cuda', ['lltm_cuda.cpp', 'lltm_cuda_kernel.cu'], verbose=True)

This should load and precompile my extension :)