Skip to content

Building scikit-learn with gcc 9.2 in a conda env fails #15129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rth opened this issue Oct 4, 2019 · 1 comment
Closed

Building scikit-learn with gcc 9.2 in a conda env fails #15129

rth opened this issue Oct 4, 2019 · 1 comment

Comments

@rth
Copy link
Member

rth commented Oct 4, 2019

When building scikit-learn in a clean conda environement,

conda create -n sklearn-dev scipy nomkl cython python=3.7

with gcc 9.2, I get the following error,

$ pip install -e .                                                              
Obtaining file:///home/rth/src/scikit-learn
Requirement already satisfied: numpy>=1.11.0 in /home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages (from scikit-learn==0.22.dev0) (1.17.2)
Requirement already satisfied: scipy>=0.17.0 in /home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages (from scikit-learn==0.22.dev0) (1.3.1)
Requirement already satisfied: joblib>=0.11 in /home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages (from scikit-learn==0.22.dev0) (0.14.0)
Installing collected packages: scikit-learn
  Running setup.py develop for scikit-learn
    ERROR: Command errored out with exit status 1:
     command: /home/rth/.miniconda3/envs/sklearn-dev/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/rth/src/scikit-learn/setup.py'"'"'; __file__='"'"'/home/rth/src/scikit-learn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps         
         cwd: /home/rth/src/scikit-learn/                                                                                              
    Complete output (56 lines):                                                                                                        
    C compiler: gcc -pthread -B /home/rth/.miniconda3/envs/sklearn-dev/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC                                                                                                 
                                                                                                                                       
    compile options: '-c'                                                                                                              
    extra options: '-fopenmp'                                                                                                          
    gcc: test_openmp.c                                                                                                                 
    gcc -pthread -B /home/rth/.miniconda3/envs/sklearn-dev/compiler_compat -Wl,--sysroot=/ objects/test_openmp.o -o test_openmp -fopenmp                                                                                                                                      
    /home/rth/.miniconda3/envs/sklearn-dev/compiler_compat/ld: objects/test_openmp.o: unable to initialize decompress status for section .debug_info                                                                                                                          
    /home/rth/.miniconda3/envs/sklearn-dev/compiler_compat/ld: objects/test_openmp.o: unable to initialize decompress status for section .debug_info                                                                                                                          
    /home/rth/.miniconda3/envs/sklearn-dev/compiler_compat/ld: objects/test_openmp.o: unable to initialize decompress status for section .debug_info                                                                                                                          
    /home/rth/.miniconda3/envs/sklearn-dev/compiler_compat/ld: objects/test_openmp.o: unable to initialize decompress status for section .debug_info                                                                                                                          
    objects/test_openmp.o: file not recognized: file format not recognized                                                             
    collect2: error: ld returned 1 exit status                                                                                         
    Partial import of sklearn during the build process.                                                                                
    Traceback (most recent call last):                                                                                                 
      File "<string>", line 1, in <module>                                                                                             
      File "/home/rth/src/scikit-learn/setup.py", line 290, in <module>                                                                
        setup_package()                                                                                                                
      File "/home/rth/src/scikit-learn/setup.py", line 286, in setup_package                                                           
        setup(**metadata)                                                                                                              
      File "/home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages/numpy/distutils/core.py", line 137, in setup            
        config = configuration()                                                                                                       
      File "/home/rth/src/scikit-learn/setup.py", line 174, in configuration                                                           
        config.add_subpackage('sklearn')                                                                                               
      File "/home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 1035, in add_subpackage                                                                                                                                    
        caller_level = 2)                                                                                                              
      File "/home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 1004, in get_subpackage                                                                                                                                    
        caller_level = caller_level + 1)                                                                                               
      File "/home/rth/.miniconda3/envs/sklearn-dev/lib/python3.7/site-packages/numpy/distutils/misc_util.py", line 941, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "sklearn/setup.py", line 78, in configuration
        maybe_cythonize_extensions(top_path, config)
      File "/home/rth/src/scikit-learn/sklearn/_build_utils/__init__.py", line 43, in maybe_cythonize_extensions
        with_openmp = check_openmp_support()
      File "/home/rth/src/scikit-learn/sklearn/_build_utils/openmp_helpers.py", line 140, in check_openmp_support
        raise CompileError(err_message)
    distutils.errors.CompileError:
                        ***
    
    It seems that scikit-learn cannot be built with OpenMP support.
    
    - Make sure you have followed the installation instructions:
    
        https://scikit-learn.org/dev/developers/advanced_installation.html
    
    - If your compiler supports OpenMP but the build still fails, please
      submit a bug report at:
    
        https://github.com/scikit-learn/scikit-learn/issues
    
    - If you want to build scikit-learn without OpenMP support, you can set
      the environment variable SKLEARN_NO_OPENMP and rerun the build
      command. Note however that some estimators will run in sequential
      mode and their `n_jobs` parameter will have no effect anymore.
    
                        ***
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/rth/.miniconda3/envs/sklearn-dev/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/rth/src/scikit-learn/setup.py'"'"'; __file__='"'"'/home/rth/src/scikit-learn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

with,

$ gcc --version                                                                 
gcc (Gentoo 9.2.0-r1 p2) 9.2.0

if I remember correctly, @tomMoral was getting the same error on Arch also with a recent gcc.

I would rather not install conda compilers as a workaround, build should work with recent system gcc..

The root cause is that conda ships its own ld that doesn't work with recent gcc ContinuumIO/anaconda-issues#11152
If anyone has constructive comments to add there that might also help.

Removing or renaming compiler_compat/ld in the conda folder is a hacky workaround.

Opening issue to raise attention to this, it's a problem for sprints in particular.

cc @jeremiedbb Currently the error message is confusing. Maybe we should fist check that gcc works, before checking if it works with OpenMP as otherwise users always get a message about OpenMP not being available which is a red herring.

Slightly related to #14968

@rth
Copy link
Member Author

rth commented Jun 3, 2020

Closing as likely outdated and related to openmp issues addressed since.

@rth rth closed this as completed Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant