jparkhill / TensorMol

Tensorflow + Molecules = TensorMol
http://blogs.nd.edu/parkhillgroup
GNU General Public License v3.0
271 stars 75 forks source link

Errors while compiling on windows. #26

Closed PaoloBenigni closed 6 years ago

PaoloBenigni commented 6 years ago

So I am trying to install this on windows, and I'm getting an odd error in SH.hpp that seems to be killing the installation. Here is the output code.

Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect Obtaining file:///C:/Users/hi/Desktop/git/tensormol Running setup.py (path:C:\Users\hi\Desktop\git\tensormol\setup.py) egg_info for package from file:///C:/Users/hi/Desktop/git/tensormol Running command python setup.py egg_info Numpy Include Dir: c:\python36\lib\site-packages\numpy\core\include running egg_info writing TensorMol.egg-info\PKG-INFO writing dependency_links to TensorMol.egg-info\dependency_links.txt writing top-level names to TensorMol.egg-info\top_level.txt reading manifest file 'TensorMol.egg-info\SOURCES.txt' writing manifest file 'TensorMol.egg-info\SOURCES.txt' Source in c:\users\hi\desktop\git\tensormol has version 0.2, which satisfies requirement TensorMol==0.2 from file:///C:/Users/hi/Desktop/git/tensormol Installing collected packages: TensorMol Running setup.py develop for TensorMol Running command c:\python36\python.exe -c "import setuptools, tokenize;file='C:\Users\hi\Desktop\git\tensormol\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 Numpy Include Dir: c:\python36\lib\site-packages\numpy\core\include running develop running egg_info writing TensorMol.egg-info\PKG-INFO writing dependency_links to TensorMol.egg-info\dependency_links.txt writing top-level names to TensorMol.egg-info\top_level.txt reading manifest file 'TensorMol.egg-info\SOURCES.txt' writing manifest file 'TensorMol.egg-info\SOURCES.txt' running build_ext building 'MolEmb' extension C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\python36\lib\site-packages\numpy\core\include -I./C_API/ -Ic:\python36\include -Ic:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" /EHsc /Tp./C_API/MolEmb.cpp /Fobuild\temp.win-amd64-3.6\Release./C_API/MolEmb.obj -g -openmp -w cl : Command line warning D9025 : overriding '/W3' with '/w' cl : Command line warning D9002 : ignoring unknown option '-g' MolEmb.cpp c:\python36\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(850): error C2131: expression did not evaluate to a constant c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(850): note: failure was caused by a read of a variable outside its lifetime c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(850): note: see usage of 'Prm' c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(851): error C2131: expression did not evaluate to a constant c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(851): note: failure was caused by a read of a variable outside its lifetime c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(851): note: see usage of 'Prm' c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(852): error C2131: expression did not evaluate to a constant c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(852): note: failure was caused by a read of a variable outside its lifetime c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(852): note: see usage of 'Prm' c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(853): error C2131: expression did not evaluate to a constant c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(853): note: failure was caused by a read of a variable outside its lifetime c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(853): note: see usage of 'Prm' error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\cl.exe' failed with exit status 2 Cleaning up... Command "c:\python36\python.exe -c "import setuptools, tokenize;file='C:\Users\hi\Desktop\git\tensormol\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" failed with error code 1 in C:\Users\hi\Desktop\git\tensormol\ Exception information: Traceback (most recent call last): File "c:\python36\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\python36\lib\site-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "c:\python36\lib\site-packages\pip\req\req_set.py", line 784, in install **kwargs File "c:\python36\lib\site-packages\pip\req\req_install.py", line 845, in install install_options, global_options, prefix=prefix) File "c:\python36\lib\site-packages\pip\req\req_install.py", line 1007, in install_editable show_stdout=False) File "c:\python36\lib\site-packages\pip\utils__init.py", line 707, in call_subprocess % (command_desc, proc.returncode, cwd)) pip.exceptions.InstallationError: Command "c:\python36\python.exe -c "import setuptools, tokenize;file='C:\Users\hi\Desktop\git\tensormol\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" failed with error code 1 in C:\Users\hi\Desktop\git\tensormol\

There are a few thing to change in the compiling arguments, but Im not quite sure why the error in SH.hpp comes out. Any thoughts?

jparkhill commented 6 years ago

In our experience the windows POSIX extensions are a semi-functional nightmare, and we have no plans to support Win... Actually even getting TF working on windows was awful the last time we tried. That said: these routines in SH.hpp aren't really used in the code you would be interested in using. Actually we've since re-written them in Tensorflow.

I think you should try basically commenting out the function bodies. I think that should work for your purposes.

PaoloBenigni commented 6 years ago

So it doesnt seem to be so straight forward. Other parts of MolEmb.cpp start falling apart. A few or to || conversions fixed some of it, but there are still other problems im trying to sort out.

 ./C_API/MolEmb.cpp(820): error C2131: expression did not evaluate to a constant
    ./C_API/MolEmb.cpp(820): note: failure was caused by a read of a variable outside its lifetime
    ./C_API/MolEmb.cpp(820): note: see usage of 'natom'
    ./C_API/MolEmb.cpp(832): error C3863: array type 'double [natom][3]' is not assignable
    ./C_API/MolEmb.cpp(833): error C3863: array type 'double [natom][3]' is not assignable
    ./C_API/MolEmb.cpp(834): error C3863: array type 'double [natom][3]' is not assignable
    ./C_API/MolEmb.cpp(1265): error C2131: expression did not evaluate to a constant
    ./C_API/MolEmb.cpp(1265): note: failure was caused by a read of a variable outside its lifetime
    ./C_API/MolEmb.cpp(1265): note: see usage of 'xyz'
    ./C_API/MolEmb.cpp(1309): error C2131: expression did not evaluate to a constant
    ./C_API/MolEmb.cpp(1265): note: failure was caused by a read of a variable outside its lifetime
    ./C_API/MolEmb.cpp(1265): note: see usage of 'xyz'
    ./C_API/MolEmb.cpp(1336): error C3863: array type 'int [nx]' is not assignable
    ./C_API/MolEmb.cpp(1414): error C2131: expression did not evaluate to a constant
    ./C_API/MolEmb.cpp(1414): note: failure was caused by a read of a variable outside its lifetime
    ./C_API/MolEmb.cpp(1414): note: see usage of 'dmat1'
    ./C_API/MolEmb.cpp(1417): error C2131: expression did not evaluate to a constant
    ./C_API/MolEmb.cpp(1414): note: failure was caused by a read of a variable outside its lifetime
    ./C_API/MolEmb.cpp(1414): note: see usage of 'dmat1'
    ./C_API/MolEmb.cpp(2063): error C2131: expression did not evaluate to a constant
    ./C_API/MolEmb.cpp(2063): note: failure was caused by a read of a variable outside its lifetime
    ./C_API/MolEmb.cpp(2063): note: see usage of 'dim_zeta'
    ./C_API/MolEmb.cpp(2089): error C3863: array type 'double [dim_zeta]' is not assignable
    ./C_API/MolEmb.cpp(2092): error C3863: array type 'double [dim_eta1]' is not assignable
    ./C_API/MolEmb.cpp(2094): error C3863: array type 'double [dim_eta2]' is not assignable
    ./C_API/MolEmb.cpp(2096): error C3863: array type 'double [dim_Rs]' is not assignable
jordangarside commented 6 years ago

@PaoloBenigni I recommend using Bash on Ubuntu on Windows if you really want to keep using windows. It's pretty easy to install and should make your life a lot easier.

Install directions

Someone even has a gist on installing Tensorflow to it (although I would just follow normal install directions).

PaoloBenigni commented 6 years ago

So actually tensorflow isnt too bad to get running on windows without doing too much. Im just confused as to why there are all these errors. It installs find on my debian subsystem, just not ideal for me.

I think there is some environment or compiler setting that is not quite correct, I'll keep poking around.

jeherr commented 6 years ago

@PaoloBenigni Going back to your original errors

c:\users\hi\desktop\git\tensormol\c_api\SH.hpp(850): error C2131: expression did not evaluate to a constant

It seems that that the problem is likely because they are Variable Length Arrays, something which GCC supports, but MSVC does not. See this stack overflow question here. As @jordangarside suggests, I would recommend using the Windows Subsystem for Linux if you must stick with Windows.

PaoloBenigni commented 6 years ago

So I was able to install TensorMol. The only code changes are adding sys imports as in this PR.

So I installed MINGW64 from here and added to path. For me this was C:\msys64\mingw64\bin

Then I had to change line 204 and 241 from _hypot to hypot in pyconfig.h. This is found in C:\Python36\include\

I had to add the folllowing lines to cygwincompiler.py in C:\Python36\Lib\distutils after line 84

        elif msc_ver == '1700':
            # Visual Studio 2012 / Visual C++ 11.0
            return ['msvcr110']
        elif msc_ver == '1800':
            # Visual Studio 2013 / Visual C++ 12.0
            return ['msvcr120']
        elif msc_ver == '1900':
            # Visual Studio 2015 / Visual C++ 14.0
            # "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspx
            return ['vcruntime140']

Then create distutils.cfg in python36\Lib\distutils\distutils.cfg

[build]
compiler=mingw32

[build_ext]
compiler=mingw32

And finally copy vcruntime140.dll into C:\Python36\libs. Hope this helps!

jparkhill commented 6 years ago

<== Impressed. Just to motivate your explorations, 0.2 is only a few weeks away, and features support for many more elements, new calculation types, faster evaluation, etc. Thanks for your useful comments.