Closed tnowotny closed 4 years ago
The reason why we are not replacing LINK_FLAGS
is that this makes it impossible to pass in any custom LINK_FLAGS
from Brian's side. I don't know whether there's much use for it, but I'd prefer to keep it if possible (to keep it consistent with compiler flags). What's strange is that we are not actually passing in any link flags by default, so maybe he had a LINK_FLAGS
environment variable set independently of Brian/Brian2GeNN? We could think of raising a warning in that case at least...
I haven't actually tested Brian2GeNN on Windows with a GPU (only without), but @thesamovar did at some point, not sure for the latest version, though. This problem should show up with each and every code, right?
Happy to test it on Windows if that would be useful. Any particular choices about versions of everything?
If I understood correctly, the participant used the GeNN version that comes with Brian2GeNN. That means to test you should install the brian2genn conda package (conda install -c brian-team brian2genn
) and run a simulation with it (to make sure it uses the pre-packaged GeNN, you can unset GENN_PATH
if it is set on your system).
Do I need a particular version of CUDA tools?
I don't think Brian2GeNN/GeNN depends on any particular version, but your Visual Studio version might restrict the compatible choices I think (at least that's the case for gcc on Linux).
Is there a standard test script?
The issue should appear with any example, but for the full test suite you can run scripts/run_brian_tests.py
OK, here is debug output from doing the following:
conda create -n testbrian2genn
activate brian2genn
conda install -c brian-team brian2genn
python simple_example.py
and all output:
INFO The following preferences have been changed for Brian2GeNN, reset them manually if you use a different device later in the same script: codegen.loop_invariant_optimisations, core.network.default_schedule [brian2.devices.genn]
INFO No numerical integration method specified for group 'neurongroup', using method 'exact' (took 0.05s). [brian2.stateupdaters.base.method_choice]
running brian code generation ...
building genn executable ...
cl /nologo /EHsc /DNVCC=\""D:/CUDA/bin/nvcc.exe"\" /DMODEL=\"C:\Users\dgoodman\Dropbox\Programming\testbrian2genn\simple_example\magicnetwork_model.cpp\" /FeC:\Users\dgoodman\Dropbox\Programming\testbrian2genn\simple_example\generateALL.exe C:\Anaconda\envs\testbrian2genn\opt\genn\lib\src\generate*.cc /I"C:\Anaconda\envs\testbrian2genn\opt\genn\lib\include" /I"D:\CUDA\include" "C:\Anaconda\envs\testbrian2genn\opt\genn\lib\lib\genn.lib" "D:\CUDA\lib\x64\cudart.lib" "D:\CUDA\lib\x64\cuda.lib"
generateALL.cc
generateCPU.cc
generateKernels.cc
generateRunner.cc
Generating Code...
genn.lib(standardGeneratedSections.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(neuronModels.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(postSynapseModels.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(synapseModels.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(utils.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(modelSpec.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(global.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(codeGenUtils.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(neuronGroup.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(synapseGroup.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(standardSubstitutions.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(newNeuronModels.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(newPostsynapticModels.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
genn.lib(newWeightUpdateModels.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1900' doesn't match value '1800' in generateALL.obj
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: __cdecl std::bad_cast::bad_cast(class std::bad_cast const &)" (??0bad_cast@std@@QEAA@AEBV01@@Z) already defined in genn.lib(standardGeneratedSections.obj)
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: __cdecl std::exception::exception(class std::exception const &)" (??0exception@std@@QEAA@AEBV01@@Z) already defined in genn.lib(standardGeneratedSections.obj)
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: virtual __cdecl std::bad_cast::~bad_cast(void)" (??1bad_cast@std@@UEAA@XZ) already defined in genn.lib(standardGeneratedSections.obj)
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: virtual __cdecl std::exception::~exception(void)" (??1exception@std@@UEAA@XZ) already defined in genn.lib(standardGeneratedSections.obj)
LIBCMT.lib(stdexcpt.obj) : error LNK2005: "public: virtual char const * __cdecl std::exception::what(void)const " (?what@exception@std@@UEBAPEBDXZ) already defined in genn.lib(standardGeneratedSections.obj)
LIBCMT.lib(vfprintf.obj) : error LNK2005: _vfprintf_l already defined in genn.lib(standardGeneratedSections.obj)
LIBCMT.lib(printf.obj) : error LNK2005: printf already defined in genn.lib(standardGeneratedSections.obj)
genn.lib(synapseGroup.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(newNeuronModels.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(newWeightUpdateModels.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(utils.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(neuronGroup.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(neuronModels.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(postSynapseModels.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(synapseModels.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *,unsigned __int64)" (??3@YAXPEAX_K@Z)
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol _Init_thread_header
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol _Init_thread_header
genn.lib(utils.obj) : error LNK2001: unresolved external symbol _Init_thread_header
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol _Init_thread_header
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol _Init_thread_header
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol _Init_thread_abort
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol _Init_thread_abort
genn.lib(utils.obj) : error LNK2001: unresolved external symbol _Init_thread_abort
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol _Init_thread_abort
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol _Init_thread_abort
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol _Init_thread_footer
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol _Init_thread_footer
genn.lib(utils.obj) : error LNK2001: unresolved external symbol _Init_thread_footer
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol _Init_thread_footer
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol _Init_thread_footer
genn.lib(standardGeneratedSections.obj) : error LNK2019: unresolved external symbol __acrt_iob_func referenced in function printf
genn.lib(standardGeneratedSections.obj) : error LNK2019: unresolved external symbol __stdio_common_vfprintf referenced in function _vfprintf_l
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf_s
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf_s
genn.lib(utils.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf_s
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf_s
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf_s
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol __std_exception_copy
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol __std_exception_copy
genn.lib(utils.obj) : error LNK2001: unresolved external symbol __std_exception_copy
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol __std_exception_copy
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol __std_exception_copy
genn.lib(standardSubstitutions.obj) :NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\x86_amd64\cl.EXE"' : return code '0x2'
Stop.
'".\generateALL.exe"' is not recognized as an internal or external command,
operable program or batch file.
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
The system cannot find the path specified.
NMAKE : fatal error U1077: 'cd' : return code '0x1'
Stop.
ERROR Brian 2 encountered an unexpected error. If you think this is bug in Brian 2, please report this issue either to the mailing list at <http://groups.google.com/group/brian-development/>, or to the issue tracker at <https://github.com/brian-team/brian2/issues>. Please include this file with debug information in your report: c:\users\dgoodman\appdata\local\temp\brian_debug_yzpgor.log Additionally, you can also include a copy of the script that was run, available at: c:\users\dgoodman\appdata\local\temp\brian_script_lr92kr.py You can also include a copy of the redirected std stream outputs, available at c:\users\dgoodman\appdata\local\temp\brian_stdout_9eziti.log and c:\users\dgoodman\appdata\local\temp\brian_stderr_ycaqyz.log Thanks! [brian2]
Traceback (most recent call last):
File "simple_example.py", line 14, in <module>
run(10*ms)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2\units\fundamentalunits.py", line 2360, in new_f
result = f(*args, **kwds)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2\core\magic.py", line 371, in run
namespace=namespace, profile=profile, level=2+level)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2\core\magic.py", line 231, in run
namespace=namespace, profile=profile, level=level+1)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2\core\base.py", line 276, in device_override_decorated_function
return getattr(curdev, name)(*args, **kwds)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2genn\device.py", line 1571, in network_run
level=level + 1)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2\devices\cpp_standalone\device.py", line 1286, in network_run
self.build(direct_call=False, **self.build_options)
File "C:\Anaconda\envs\testbrian2genn\lib\site-packages\brian2genn\device.py", line 753, in build
returncode=ex.returncode)
RuntimeError: Project compilation failed (Command "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64 && C:\Anaconda\envs\testbrian2genn\opt\genn\lib\bin\genn-buildmodel.bat magicnetwork_model.cpp && nmake /f WINmakefile clean && nmake /f WINmakefile failed with error code 2).
See the output above (if any) for more details.
error LNK2001: unresolved external symbol __std_exception_destroy
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol __std_exception_destroy
genn.lib(utils.obj) : error LNK2001: unresolved external symbol __std_exception_destroy
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol __std_exception_destroy
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol __std_exception_destroy
genn.lib(standardSubstitutions.obj) : error LNK2001: unresolved external symbol _Init_thread_epoch
genn.lib(standardGeneratedSections.obj) : error LNK2001: unresolved external symbol _Init_thread_epoch
genn.lib(utils.obj) : error LNK2001: unresolved external symbol _Init_thread_epoch
genn.lib(modelSpec.obj) : error LNK2001: unresolved external symbol _Init_thread_epoch
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol _Init_thread_epoch
genn.lib(utils.obj) : error LNK2019: unresolved external symbol _get_stream_buffer_pointers referenced in function "protected: void __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::_Init(struct _iobuf *,enum std::basic_filebuf<char,struct std::char_traits<char> >::_Initfl)" (?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z)
genn.lib(modelSpec.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf referenced in function _vscprintf_l
genn.lib(codeGenUtils.obj) : error LNK2001: unresolved external symbol __stdio_common_vsprintf
C:\Users\dgoodman\Dropbox\Programming\testbrian2genn\simple_example\generateALL.exe : fatal error LNK1120: 12 unresolved externals
model build complete
del main.exe *.obj *.ilk *.pdb 2>nul
cd magicnetwork_model_CODE && nmake clean /nologo
Shall we switch to gitter to do a debugging session?
This issue seems to be different from the one Thomas was reporting, it seems our package pre-compiled stuff with Visual Studio 2013 and you are using Visual Studio 2015... We'll need to do something about this in any case, at least display a warning telling users to install GeNN manually. We could create packages for various VS versions, but given that VS is not installed via anaconda, I don't know how we could provide these packages in a nice way.
I think VS is now installed via anaconda. Output of conda list
:
# packages in environment at C:\Anaconda\envs\testbrian2genn:
#
brian2 2.1.2 np113py27_0 brian-team
brian2genn 1.1.5 py27h45f29f9_0 brian-team
certifi 2018.4.16 py27_0
cython 0.28.2 py27h0c8e037_0
fastcache 1.0.2 py27h0c8e037_2
gsl 2.2.1 vc9_2 [vc9] brian-team
icc_rt 2017.0.4 h97af966_0
intel-openmp 2018.0.0 8
jinja2 2.10 py27hba1794b_0
markupsafe 1.0 py27h9d4480d_1
mkl 2018.0.2 1
mkl_fft 1.0.1 py27hc997a72_0
mpmath 1.0.0 py27h0d59bc2_2
numpy 1.13.3 py27h0bb1d87_4
pip 10.0.1 py27_0
py-cpuinfo 3.2.0 py27_0 brian-team
pyparsing 2.2.0 py27hc7d9fa6_1
python 2.7.15 he216670_0
scipy 1.1.0 py27ha6b90e7_0
setuptools 39.1.0 py27_0
sympy 1.1.1 py27hde44fae_0
vc 9 h7299396_1
vs2008_runtime 9.00.30729.1 hfaea7d5_1
vs2008_win-64 9.00.30729.1 hb7fc0b5_1
weave 0.15.0 py27_0 brian-team
wheel 0.31.0 py27_0
wincertstore 0.2 py27hf04cefb_0
I assume vs2008_win-64
is Visual Studio 2008? As well as this, I have VS 2008, VS 2010 and VS 2013 installed but not 2015 I think. But it should be using the environment variables for VS 2008.
If I pip install instead of conda install would that work do you think?
Oh, interesting, that's a fairly new addition to anaconda I think. We should try to redo our packaging with this in mind, it could also be useful for Brian 2 itself. The package description says it does "Activation and version verification", so I think it does not install the compiler itself. Unfortunately, there's no such package in Anaconda for VS 2013, the version we need :-/ Oh no wait, it seems to be the other way round (compiled with VS 2015, and it used VS 2013 on your machine). Can you see what happens if you conda install vs2015_win-64
(I guess that automatically removes vs2008_win-64
)?
If I pip install instead of conda install would that work do you think?
The pip package is only source, it does not come with GeNN.
Doing conda install vs2015_win-64
doesn't remove vs2008
, it works fine, but the same error on running simple_example.py
.
Hmm, I looked into this in a bit more detail and I don't yet know what the best solution is. I think all that vs2015_win-64
and equivalent packages do is to run vcvarsall.bat
(you need to deactivate and activate the environment to see this -- annoyingly, it closes the terminal window if an error occurs, e.g. it cannot find the compiler...). Now for brian2genn all this does not really matter, as we'll explicitly run vcvarsall.bat
ourselves after searching for the latest available version. Maybe we should make this optional? Or only do it when it hasn't been run already (I guess there's an environment variable we can check)?
In your case, just for testing whether it works at all or whether you get the error reported by Thomas, can you explicitly set the codegen.cpp.msvc_vars_location
preference in the simple_example
script to the path of your VS 2015 installation?
I don't have VS 2015 - will see if I can install it.
Oh, one more thing. I now realized that the vs..._win-64
packages that are required by our brian2genn
package are the ones that are required for building Python extensions. So when you install Brian2/Brian2GeNN this way with Python 2, you'll get the package for VS 2008... I guess this means we shouldn't use these kind of packages to determine/fix the compiler that is used for standalone/GeNN (you cannot use the latest CUDA version with VS 2008 for example).
Yes good point since we're not building Python extensions. So is the take-home message at the moment that the anaconda distribution depends on having VS 2015 installed because we have some precompiled binaries for that version? VS 2015 installing now so we'll see!
So is the take-home message at the moment that the anaconda distribution depends on having VS 2015 installed because we have some precompiled binaries for that version?
Yes, the reason that we need to pre-compile things in the first place is that during GeNN's code generation process, a few files are compiled within the GeNN source directory itself -- potentially the user is not allowed to compile files there (system-wide instead of user installation) and in general I think we are not supposed to add new files into Anaconda directories after installation (e.g. they would not be removed during an uninstall). I guess in the long run GeNN could be restructured in a way that the files are rather copied into the user project or something like that?
Still problems - apparently my version of CUDA toolkit is too old for MSVC 2015! Will update that tomorrow.
Hi guys ... just saw this has kicked off today ... it's a typical Windows build experience, isn't it (sorry, Dan). As for restructuring GeNN to not write into its own install location ... we need to think about this. In this context I can see it makes a lot of sense but the compilation of the GeNN library file in place makes a lot of sense in our GeNN context (I thought). What do you think @neworderofjamie?
Damn...a lot of Windows build issues definitely crawled out when we lifted that stone!
GeNN being checked out somewhere read only to the user (i.e. system site packages) is indeed not something that really makes sense when using it in a standalone way. However I don't think it would be that difficult to modify the build system to allow it. The Windows build system actually allows this already so, for instance, to build libgenn with the intermediate files and library being written to a random folder on your (/my) desktop you could do the following:
msbuild /p:Configuration=Release_CPU_ONLY /p:IntDir=c:\Users\newor\Desktop\test\obj\ /p:OutDir=c:\Users\newor\Desktop\test\lib\ lib_genn.vcxproj
The Linux/Mac build system would need a little more work and the genn-buildmodel
scripts etc would need updating to pass the output directory through but it would definitely be possible!
I think this has been resolved with the GeNN 4 changes and the corresponding brian2genn updates in #101
Hi @mstimberg, at Capocaccia we had a participant who wanted to try brian2genn on Windows and he was unable to compile because in makefile_common_win.mk from the included GeNN version,
LINK_FLAGS
were added to rather than replaced. As a result they contained a strange default of "-MD" and something else which I can't recall. The "-MD" forced cl to do some kind of dynamic linking while nvcc (by default) seems to do some static linking that is the equivalent of what cl would do with a "-MT" flag. Linking then failed with an error message that dynamically linked and statically linked object files can't be linked together. When we replacedLINK_FLAGS
rather than adding to it, everything seemed to work. I wonder whether we should make the effort to patch the GeNN version you packaged into brian2genn (or at this time update to something more recent) and repackage brian2genn and release to fix this problem? Relatedly, I am wondering whether you tested brian2genn on Windows with a GPU? Because I am not sure whether this is a problem with this guy's particular setup or whether it is a general problem (it wouldn't appear in the CPU_ONLY version as you wouldn't link cl compiled obj files and nvcc compiled ones).