torchsort 安装相关的坑

2024-10-30  本文已影响0人  slords

GitHub - teddykoker/torchsort: Fast, differentiable sorting and ranking in PyTorch
torchsort · PyPI
当前安装版本 - 最新版本 - 0.1.9

#!/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

# 官网说是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
# 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
上一篇 下一篇

猜你喜欢

热点阅读