otaheri / chamfer_distance Goto Github PK
View Code? Open in Web Editor NEWImplementation of the Chamfer Distance as a module for PyTorch
License: MIT License
Implementation of the Chamfer Distance as a module for PyTorch
License: MIT License
fp16 support?
I found that I need to call the method in a different way, first I needed to initialize the class and only then call it, so this works:
dist1, dist2, idx1, idx2 = chamfer_dist()(p1,p2)
while the example in the readme does not work and produces an error ... = chamfer_dist(p1,p2)
(without the class parenthesis)
Is it just me?
Thank you for this package in any case.
Hello, trying to use in an optimization procedure. Trying out the demo code
import torch
from chamfer_distance import ChamferDistance
import time
chamfer_dist = ChamferDistance()
p1 = torch.rand([10,25,3], requires_grad=True)
p2 = torch.rand([10,15,3], requires_grad=True)
dist1, dist2, idx1, idx2 = chamfer_dist(p1,p2)
loss = (torch.mean(dist1)) + (torch.mean(dist2))
then adding
loss.backwad()
I get : "TypeError: backward( takes 4 positional argument but 5 were given"
using torch version 1.9.1 on a linux system.
Eran
module = importlib.util.module_from_spec(spec)
ImportError: DLL load failed while importing cd: The specified module could not be found.
After fixing many previous bugs, I get a new bug....it is quite annoying~~~is it due to the difference of pytorch/python/cuda version?
I install pytorch and chamfer_distance, but when I run the Usage, the error is ' ImportError: No module named 'cd' ', my python is 3.6 and pytorch is 1.7 .
there is a problem when running with the pycharm in windows
Unfortunately I am not able to build the chamfer_distance.cuda on neither Windows 11 and Ubuntu 22.04 (same machine) when calling cd = load(name="cv" ...)
for the first time. Both report similar error messages.
I use Python 3.10, PyTorch 1.11.0 with CUDA toolkit 11.6 on both Windows and Ubuntu.
I run this in a conda virtual environment.
I already tried this but it did not help.
Here is the Traceback from Ubuntu:
Traceback (most recent call last):
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1740, in _run_ninja_build
subprocess.run(
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/sktis/dev/python/GrabNet/grabnet/tests/grab_new_objects.py", line 24, in <module>
from grabnet.tools.vis_tools import points_to_spheres
File "/home/sktis/dev/python/GrabNet/./grabnet/tools/vis_tools.py", line 21, in <module>
from grabnet.tools.train_tools import point2point_signed
File "/home/sktis/dev/python/GrabNet/./grabnet/tools/train_tools.py", line 18, in <module>
import chamfer_distance as chd
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/__init__.py", line 1, in <module>
from .chamfer_distance import ChamferDistance
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/chamfer_distance.py", line 8, in <module>
cd = load(name="cd",
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1144, in load
return _jit_compile(
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1357, in _jit_compile
_write_ninja_file_and_build_library(
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1469, in _write_ninja_file_and_build_library
_run_ninja_build(
File "/home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1756, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error building extension 'cd': [1/2] /usr/bin/nvcc -DTORCH_EXTENSION_NAME=cd -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/TH -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/THC -isystem /home/sktis/anaconda3/envs/GrabNet/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/chamfer_distance.cu -o chamfer_distance.cuda.o
FAILED: chamfer_distance.cuda.o
/usr/bin/nvcc -DTORCH_EXTENSION_NAME=cd -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/TH -isystem /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/torch/include/THC -isystem /home/sktis/anaconda3/envs/GrabNet/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/sktis/anaconda3/envs/GrabNet/lib/python3.10/site-packages/chamfer_distance/chamfer_distance.cu -o chamfer_distance.cuda.o
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
435 | function(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:435:145: note: ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
530 | operator=(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:530:146: note: ‘_ArgTypes’
ninja: build stopped: subcommand failed.
ImportError: cannot import name 'Volumes' from 'pytorch3d.structures' (/home/dennisushi/.local/lib/python3.8/site-packages/pytorch3d/structures/__init__.py)
When running
import torch
from chamfer_distance import ChamferDistance as chamfer_dist
import time
p1 = torch.rand([10,25,3])
p2 = torch.rand([10,15,3])
s = time.time()
chd = chamfer_dist()
dist1, dist2, idx1, idx2 = chd(p1,p2)
loss = (torch.mean(dist1)) + (torch.mean(dist2))
torch.cuda.synchronize()
print(f"Time: {time.time() - s} seconds")
print(f"Loss: {loss}")
Seems like the recommended version of pytorch3d might be too new. (0.7.2 from git+https://github.com/facebookresearch/pytorch3d.git@stable )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.