Open DuncDennis opened 3 years ago
Unable to reproduce the bug so far. Please open a python interpreter and post your numpy configuration here, i.e. the output of the following two commands:
import numpy
numpy.show_config()
Here the output of :
import numpy
numpy.show_config()
(with activated rc_env
environment)
output:
blas_mkl_info:
libraries = ['mkl_rt']
library_dirs = ['C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\lib', 'C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\include']
blas_opt_info:
libraries = ['mkl_rt']
library_dirs = ['C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\lib', 'C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\include']
lapack_mkl_info:
libraries = ['mkl_rt']
library_dirs = ['C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\lib', 'C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\include']
lapack_opt_info:
libraries = ['mkl_rt']
library_dirs = ['C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\lib']
define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
include_dirs = ['C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\include', 'C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries_2019.0.117\\windows\\mkl\\lib', 'C:/Users/Dennis/anaconda3/envs/rc_env\\Library\\include']
The backend seems fine, so that's probably not it.
One possible solution could be that your python uses 32 instead of 64 bit floats for whatever reason. Please post the output of:
import sys
sys.float_info
Besides this, your numpy installation might just be bugged. Please run:
import numpy
numpy.test("full")
and post its output here.
The output of:
import sys
sys.float_info
yields:
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
The output of:
import numpy
numpy.test("full", verbose = 2)
yields:
After installing the package pytest
in the rc_env
via conda install -c anaconda pytest
the numpy test could be performed by running:
import numpy
numpy.test(label='full', verbose=2)
The result of the numpy test was:
Interestingly in the first line of the output it says platform win32 -- Python 3.7.5, pytest-6.1.1, py-1.9.0, pluggy-0.13.1
, hinting to a 32 bit platform.
On the other hand, if I run the python code (from https://docs.python.org/3/library/platform.html)
import sys
is_64bits = sys.maxsize > 2**32
print(is_64bits)
it prints True
, hinting at a 64 bit environment.
Furthermore the output to conda info
also shows a win-64 platform.
All the code was run within the active rc_env
environment. It seems like numpy "thinks" the platform is 32 bit, eventhough it is 64bit ?
In the last snipped it says the python version is 3.8.8, even though the numpy test uses 3.7.5 as we want it to be? With the conda environment active, please run a simple
python --version
Also please save the first 1000 rows of the sim_data you calculated here:
via numpy.save() and send them to me as well.
python --version
yields the correct version:
Apperently the python version stated within the output of the conda info
command is referring to the base python version, and thus is independent of the python version in the currently active environment. See: https://stackoverflow.com/questions/56848462/what-is-the-difference-between-the-python-version-stated-in-conda-info-and-that
Playing around with it a bit, the FFT may(?) indeed be the cause of the instability. This would make sense, as it's the only nontrivial operation happening in the entire simulation function. Also, at least on my machine, using the scipy, instead of the numpy FFT avoided a divergence for all python and scipy versions I tested against. (Although I don't actually now yet if the attractor behavior remains truly unaffected.)
@DuncDennis: Could you checkout the new branch ks_sim_fix and see if the scipy FFT works on your machine as well?
Use the following command:
pytest -v --tb=no --disable-warnings
You'll probably need to install pytest for this, as it's not a requirement for rescomp. The Output should look something like this:
With the scipy tests highlighted in red.
I checked out the branch ks_sim_fix. The two scipy lines in the pytest (which you marked in red) passed on my machine aswell for various scipy versions: scipy = 1.3.2 , 1.4.1 , 1.5.2 and 1.6.2. My numpy version was fixed at 1.17.4.
The pytest result was the same for all tested scipy versions so I only attach one of the outputs.
Very nice! I'll look into the differences between numpy and scipy FFT to figure out where the difference might come from.
In addition, we'll want to implement the Lyapunov calculation algorithm described in the SI of this Pathak paper: "Model-Free Prediction of Large Spatiotemporally Chaotic Systems from Data: A Reservoir Computing Approach"
Once we have that, we can compare Lyapunov Exponents, and if they agree with the literature and the non-diverging numpy simulations, we can just use the seemingly more stable scipy fft instead of the numpy for now.
(We'll still want a very simple KS simulation to compare the scipy results regardless though.)
When simulating the
"kuramoto_sivashinsky"
data in the example "higher_dim_example.ipynb", the values in the resulting numpy arraysim_data
are diverging (nan) for timesteps larger than ~ 620.Contents of environment .yml file in a .txt file, created via
conda env export > dunc_env.yml
(.yml files are not allowed here): dunc_env.txt