teddykoker / torchsort

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

Installing with custom g++ versions #39

Closed davidstutz closed 2 years ago

davidstutz commented 2 years ago

Hi,

while installing the package I ran into the problem that the CUDA version used to install my torch installation (CUDA 9.2) is not compatible with recent g++ versions (7 or higher). The error looks something like this:

/usr/lib/cuda-9.2/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 7 are not supported!

So I just wanted to leave a comment that adapting setup.py as follows (also see https://github.com/davidstutz/torchsort/blob/d97f30233dc7b463899a9072b6a77cb7abade5c7/setup.py#L22) allows to set custom gcc/g++ versions for building:

os.environ['CC'] = '/usr/bin/gcc-7'
os.environ['CXX'] = '/usr/bin/g++-7'
os.environ['CCP'] = '/usr/bin/g++-7'

@lru_cache(None)
def cuda_toolkit_available():
    # https://github.com/idiap/fast-transformers/blob/master/setup.py
    try:
        call(["CC=/usr/bin/gcc-7 CXX=/usr/bin/g++-7 CCP=/usr/bin/g++-7 nvcc"], stdout=DEVNULL, stderr=DEVNULL)
        return True
    except FileNotFoundError:
        return False

Thanks for the package! David

teddykoker commented 2 years ago

Hi David,

Thanks for reporting this and providing a fix! Could this be addressed by exporting the CC, CXX and CCP variables on the command line prior to installing? Or does subprocess.call not use the same environment?

Just wondering if there would be a fix that could remain flexible enough for all users.

teddykoker commented 2 years ago

Closing due to lack of activity