teddykoker / torchsort

Fast, differentiable sorting and ranking in PyTorch
https://pypi.org/project/torchsort/
Apache License 2.0
765 stars 33 forks source link

How to enable cuda for torchsort in linux mint/ubuntu? #75

Closed davips closed 11 months ago

davips commented 1 year ago

Hello, I tried the solutions from other issues to no avail. model.cuda() and cuda checking are ok:

In [1]: import torch; torch.cuda.is_available()
Out[1]: True

I tried many approaches, including poetry (my personal project need) and pip directly (as a last resource):

pip install --force-reinstall --no-cache-dir --no-deps git+https://github.com/teddykoker/torchsort.git

pip install --force-reinstall --no-cache-dir --no-deps torchsort

poetry source add torch https://download.pytorch.org/whl/cu118
poetry add --source torch torch

It works well on CPU.

teddykoker commented 1 year ago

Hi @davips, thank you for your patience! Do you have the CUDA toolchain installed? nvcc (the CUDA compiler) should be in your path so the extension can be compiled.

davips commented 11 months ago

Hi @teddykoker , cuda was working fine. I ended up trying to avoid needing soft_rank, so my algorithm would depend only on pytorch. Unfortunately, this only works for my unweighted algorithm. It is impossible to weight without ranking, as I will comment on the other issue. As a workaround I can still use torchsort on CPU.

teddykoker commented 11 months ago

Going to close this for now. Please let me know if you are still trying to get CUDA working. If so, a stack trace of the install would be helpful, as that is typically the issue with pytorch cuda extensions not working in some people's environments.