Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
lizhuangzi 0966d341b7 | 2 years ago | |
---|---|---|
knn_cuda | 2 years ago | |
tests | 2 years ago | |
.DS_Store | 2 years ago | |
.gitignore | 2 years ago | |
README.md | 2 years ago | |
makefile | 2 years ago | |
ninja | 2 years ago | |
requirements.txt | 2 years ago | |
setup.py | 2 years ago | |
test_knn_cuda.log | 2 years ago |
Loop | sklearn | CUDA | Memory |
---|---|---|---|
100 | 2.34 ms | 0.06 ms | 652/1024 |
1000 | 2.30 ms | 1.40 ms | 652/1024 |
git clone https://github.com/unlimblue/KNN_CUDA.git
cd KNN_CUDA
make && make install
pip install --upgrade https://github.com/unlimblue/KNN_CUDA/releases/download/0.2/KNN_CUDA-0.2-py3-none-any.whl
And then, make sure ninja
has been installed:
wget -P /usr/bin https://github.com/unlimblue/KNN_CUDA/raw/master/ninja
You should use branch windows
:
git clone --branch windows https://github.com/unlimblue/KNN_CUDA.git
cd C:\\PATH_TO_KNN_CUDA
make
make install
import torch
# Make sure your CUDA is available.
assert torch.cuda.is_available()
from knn_cuda import KNN
"""
if transpose_mode is True,
ref is Tensor [bs x nr x dim]
query is Tensor [bs x nq x dim]
return
dist is Tensor [bs x nq x k]
indx is Tensor [bs x nq x k]
else
ref is Tensor [bs x dim x nr]
query is Tensor [bs x dim x nq]
return
dist is Tensor [bs x k x nq]
indx is Tensor [bs x k x nq]
"""
knn = KNN(k=10, transpose_mode=True)
ref = torch.rand(32, 1000, 5).cuda()
query = torch.rand(32, 50, 5).cuda()
dist, indx = knn(ref, query) # 32 x 50 x 10
Pytorch of KNN_CUDA
Cuda Python C++ Makefile Text
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》