Hanjun-Dai / GLN

Implementation of Retrosynthesis Prediction with Conditional Graph Logic Network
MIT License
118 stars 25 forks source link

Installation issue: unrecognized command line option ‘-std=c++14’ #11

Open linminhtoo opened 3 years ago

linminhtoo commented 3 years ago

Hi Hanjun and team,

First of all, awesome work on GLN. I am trying to pip install -e . but I keep running into this error: c++: error: unrecognized command line option ‘-std=c++14’ (full log below) Please note that I am on an HPC cluster without root access. I think the problem might be due to the GCC version (4.8.5) being too low. I am new to Linux but I think I cannot upgrade GCC without root access. Do you happen to know any other work around for this?

Any help would be greatly appreciated. Thanks in advance and happy new year!

Note: I prepare environment this way:

TORCH_VER=1.6.0
CUDA_VER=10.1
CUDA_CODE=cu101

source /cm/shared/engaging/anaconda/2018.12/etc/profile.d/conda.sh
conda create -y -n openretro python=3.6 tqdm
conda activate openretro

conda install -y pytorch=${TORCH_VER} torchvision torchaudio cudatoolkit=${CUDA_VER} -c pytorch
conda install -y rdkit -c rdkit

# install PTG
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH_VER}+${CUDA_CODE}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH_VER}+${CUDA_CODE}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH_VER}+${CUDA_CODE}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH_VER}+${CUDA_CODE}.html
pip install torch-geometric

# GLN installation, make sure to install on a machine with cuda
cd ./models/gln_model
pip install -e .
cd ../..

   [1/1] c++ -MMD -MF /home/linmin001/openretro/models/gln_model/build/temp.linux-x86_64-3.6/gln/mods/torchext/src/extlib.o.d -pthread -B /home/linmin001/.conda/envs/openretro/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include/TH -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include/THC -I/home/linmin001/.conda/envs/openretro/include/python3.6m -c -c /home/linmin001/openretro/models/gln_model/gln/mods/torchext/src/extlib.cpp -o /home/linmin001/openretro/models/gln_model/build/temp.linux-x86_64-3.6/gln/mods/torchext/src/extlib.o -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=extlib -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    FAILED: /home/linmin001/openretro/models/gln_model/build/temp.linux-x86_64-3.6/gln/mods/torchext/src/extlib.o
    c++ -MMD -MF /home/linmin001/openretro/models/gln_model/build/temp.linux-x86_64-3.6/gln/mods/torchext/src/extlib.o.d -pthread -B /home/linmin001/.conda/envs/openretro/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include/TH -I/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/include/THC -I/home/linmin001/.conda/envs/openretro/include/python3.6m -c -c /home/linmin001/openretro/models/gln_model/gln/mods/torchext/src/extlib.cpp -o /home/linmin001/openretro/models/gln_model/build/temp.linux-x86_64-3.6/gln/mods/torchext/src/extlib.o -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=extlib -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    c++: error: unrecognized command line option ‘-std=c++14’
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1515, in _run_ninja_build
        env=env)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/subprocess.py", line 438, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/linmin001/openretro/models/gln_model/setup.py", line 55, in <module>
        'build_ext': BuildExtension,
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/linmin001/openretro/models/gln_model/setup.py", line 45, in run
        super().run()
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/setuptools/command/develop.py", line 34, in run
        self.install_for_development()
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/setuptools/command/develop.py", line 136, in install_for_development
        self.run_command('build_ext')
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
        _build_ext.run(self)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 649, in build_extensions
        build_ext.build_extensions(self)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
        self._build_extensions_serial()
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
        self.build_extension(ext)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 196, in build_extension
        _build_ext.build_extension(self, ext)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
        depends=ext.depends)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 478, in unix_wrap_ninja_compile
        with_cuda=with_cuda)
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1233, in _write_ninja_file_and_compile_objects
        error_prefix='Error compiling objects for extension')
      File "/home/linmin001/.conda/envs/openretro/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1529, in _run_ninja_build
        raise RuntimeError(message)
    RuntimeError: Error compiling objects for extension
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/linmin001/.conda/envs/openretro/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/linmin001/openretro/models/gln_model/setup.py'"'"'; __file__='"'"'/home/linmin001/openretro/models/gln_model/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.
Hanjun-Dai commented 3 years ago

Hi,

You should be able to install gcc to your local folder without ROOT (also remember to change the environment variables). Maybe the best way is to check with your HPC admin for best practice.

vthost commented 2 years ago

Hi! I used the above script (with same torch and cuda version) and could fix the above error so that everything seems to build fine. However, when I run the code, I get the following exception. Do you maybe have any clue where this might come from?

Installing collected packages: gln
  Running setup.py develop for gln
Successfully installed gln-0.0.0
(gln3) [vthost@cccxc536 GLN]$ cd ../
(gln3) [vthost@cccxc536 ...]$ python xyz/myglnuser.py 
Traceback (most recent call last):
  File "xyz/myglnuser.py", line 48, in <module>
    import GLN.gln.mods.mol_gnn.mg_clib.mg_lib as mg_lib
  File "/u/vthost/.../GLN/gln/mods/mol_gnn/mg_clib/__init__.py", line 1, in <module>
    from .mg_lib import MGLIB
  File "/u/vthost/.../GLN/gln/mods/mol_gnn/mg_clib/mg_lib.py", line 106, in <module>
    MGLIB = _mg_lib(sys.argv)
  File "/u/vthost/.../GLN/gln/mods/mol_gnn/mg_clib/mg_lib.py", line 14, in __init__
    self.lib = ctypes.CDLL('%s/build/dll/libmolgnn.so' % dir_path)
  File "/.../anaconda3/envs/gln3/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /u/vthost/.../GLN/gln/mods/mol_gnn/mg_clib/build/dll/libmolgnn.so: undefined symbol: _ZN3cfg14num_atom_typesE
Hanjun-Dai commented 2 years ago

It seems the dll is not build correctly. Can you double check it by navigating to gln/gln/mods/mol_gnn/mg_clib/ and manually do make?