GitHub - teddykoker/torchsort: Fast, differentiable sorting and ranking in PyTorch
torchsort · PyPI
当前安装版本 - 最新版本 - 0.1.9
- 安装nvcc
torchsort安装时,会检查cuda_toolkit_available。实质是检查nvcc代码是否能运行。所以需要安装nvcc,不然cuda的数据无法排序。
#!/usr/bin/env python3
import os
import sys
from functools import lru_cache
from subprocess import DEVNULL, call
import torch
from setuptools import setup
from torch.utils import cpp_extension
@lru_cache(None)
def cuda_toolkit_available():
# https://github.com/idiap/fast-transformers/blob/master/setup.py
try:
call(["nvcc"], stdout=DEVNULL, stderr=DEVNULL)
return True
except FileNotFoundError:
return False
- conda安装torchsort
# 官网说是9.4但是这个版本已经用不了,gcc++的版本需要nvcc兼容。我不加版本时默认安装的版本是14,结果提示不支持13之后的版本。所以改为了13。
# Install g++ with conda
conda install -c conda-forge gxx_linux-64=13
# 如果没有设置环境路径则是/path/to/miniconda3/bin/x86_64-conda_cos6-linux-gnu-g++
export CXX=/path/to/miniconda3/envs/env_name/bin/x86_64-conda_cos6-linux-gnu-g++
# 如果没有设置环境路径则是/path/to/miniconda3/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/miniconda3/lib
pip install --force-reinstall --no-cache-dir --no-deps torchsort
- whl包安装torchsort
# torchsort version, supports >= 0.1.9
export TORCHSORT=0.1.9
# PyTorch version, supports pt21, pt20, and pt113 for versions 2.1, 2.0, and 1.13 respectively
export TORCH=pt21
# CUDA version, supports cpu, cu113, cu117, cu118, and cu121 for CPU-only, CUDA 11.3, CUDA 11.7,
# CUDA 11.8 and CUDA 12.1 respectively
export CUDA=cu121
# Python version, supports cp310 and cp311 for versions 3.10 and 3.11 respectively
export PYTHON=cp310
pip install https://github.com/teddykoker/torchsort/releases/download/v${TORCHSORT}/torchsort-${TORCHSORT}+${TORCH}${CUDA}-${PYTHON}-${PYTHON}-linux_x86_64.whl
- torchsort==0.1.9下载列表
- torchsort-0.1.9+pt113cpu-cp310-cp310-linux_x86_64.whl
- torchsort-0.1.9+pt113cpu-cp311-cp311-linux_x86_64.whl
- torchsort-0.1.9+pt113cu117-cp310-cp310-linux_x86_64.whl
- torchsort-0.1.9+pt113cu117-cp311-cp311-linux_x86_64.whl
- torchsort-0.1.9+pt20cpu-cp310-cp310-linux_x86_64.whl
- torchsort-0.1.9+pt20cpu-cp311-cp311-linux_x86_64.whl
- torchsort-0.1.9+pt20cu117-cp310-cp310-linux_x86_64.whl
- torchsort-0.1.9+pt20cu117-cp311-cp311-linux_x86_64.whl
- torchsort-0.1.9+pt20cu118-cp310-cp310-linux_x86_64.whl
- torchsort-0.1.9+pt20cu118-cp311-cp311-linux_x86_64.whl