pwollstadt / IDTxl

The Information Dynamics Toolkit xl (IDTxl) is a comprehensive software package for efficient inference of networks and their node dynamics from multivariate time series data using information theory.
http://pwollstadt.github.io/IDTxl/
GNU General Public License v3.0
249 stars 76 forks source link

Upated Install instructions out of data for Debian Jessie #12

Closed russelljjarvis closed 6 years ago

russelljjarvis commented 6 years ago

The following instructions were not sufficient to build in a Docker container for: "Debian GNU/Linux 8 (jessie)"

FROM russelljarvis/neuronunit
ENV QT_QPA_PLATFORM offscreen
USER jovyan
#RUN sudo apt-get install --fix-missing
RUN sudo apt-get -y autoremove
RUN sudo apt -y update
RUN sudo apt -y upgrade 
RUN pip uninstall -y neo #older version of neo is buncum.
RUN /opt/conda/bin/pip3 install neo dask psutil natsort pyspike pyNN lazyarray neo matplotlib pyopencl

RUN /opt/conda/bin/pip3 install dask psutil natsort pyspike pyNN lazyarray neo matplotlib pyopencl

WORKDIR /opt/conda/lib/python3.5/site-packages/pyNN/neuron/nmodl
RUN nrnivmodl

RUN sudo apt-get install -y g++ python3-dev python3-numpy python3-scipy python3-cffi python3-h5py python3-networkx python3-pyopencl aptitude
RUN sudo aptitude install -y python3-pyopencl pyopencl
## Uncomment these lines to generate a build error relating to unwanted but difficult to install ## pyopencl
#RUN sudo /opt/conda/bin/pip3 install git+https://github.com/inducer/pyopencl.git
#RUN /opt/conda/bin/pip3 install --upgrade pip
#RUN python3 -c "import pyopencl as cl"
##
RUN git clone https://github.com/jlizier/jidt
WORKDIR jidt
RUN sudo ant build
RUN sudo apt-get install python-jpype && sudo /opt/conda/bin/pip install JPype1 && sudo /opt/conda/bin/pip install git+https://github.com/pwollstadt/IDTxl.git
RUN python3 -c "from idtxl.multivariate_te import MultivariateTE; network_analysis = MultivariateTE()"
WORKDIR $HOME/QIASCOLI
RUN sudo chown -R jovyan $HOME
USER jovyan

This line is necessary to to test for successful instalation, because IDTxl.git installer gives indication of succeeding otherwise, but TE() objects cannot be instantiated properly due to failed python3-pyopencl installation.

RUN python3 -c "from idtxl.multivariate_te import MultivariateTE; network_analysis = MultivariateTE()"

Removing intermediate container b2b1a9f32c8e ---> df5260ec8370 Step 5/20 : RUN /opt/conda/bin/pip3 install dask psutil natsort pyspike pyNN lazyarray neo matplotlib pyopencl ---> Running in fec6bf15a424 Requirement already satisfied: dask in /opt/conda/lib/python3.5/site-packages Requirement already satisfied: psutil in /opt/conda/lib/python3.5/site-packages Collecting natsort Downloading https://files.pythonhosted.org/packages/c9/5d/64d443b303fc213bf7abe2512232d2b47acbc3e6f8e01ad19a9bf7d313cb/natsort-5.3.0-py2.py3-none-any.whl Collecting pyspike Downloading https://files.pythonhosted.org/packages/a2/bb/38f54ab8490ec342337a270dea8ef6e8300ddd5e56e58ab0c3fa52a7d74e/pyspike-0.5.3.tar.gz (1.4MB) Collecting pyNN Downloading https://files.pythonhosted.org/packages/da/e4/ab620b4730de4c08d0df6346b181eb5b9a9ffdab8aefed811452e547d1c9/PyNN-0.9.2.tar.gz (358kB) Collecting lazyarray Downloading https://files.pythonhosted.org/packages/a0/c5/4cac8d8749bea1e675aa97232e7eaa1e340b5bd56a041268eb48c8dc523c/lazyarray-0.3.2.tar.gz Collecting neo Downloading https://files.pythonhosted.org/packages/d2/8c/3a41152f82fd8b8ee2d1cbeb87872be1555f0beb47ddce9faebba02b9d9e/neo-0.6.1.tar.gz (1.5MB) Requirement already satisfied: matplotlib in /opt/conda/lib/python3.5/site-packages Collecting pyopencl Downloading https://files.pythonhosted.org/packages/d3/66/080ee1a9cc3f71f7491c7e3261b767c788be2aea0d694017cd25aa762b0e/pyopencl-2018.1.1.tar.gz (357kB) Complete output from command python setup.py egg_info: c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

include

                 ^
compilation terminated.
Traceback (most recent call last):
  File "/opt/conda/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/opt/conda/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/opt/conda/lib/python3.5/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/opt/conda/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/opt/conda/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/opt/conda/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/bdist_egg.py", line 161, in run
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/bdist_egg.py", line 147, in call_command
  File "/opt/conda/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/opt/conda/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/install_lib.py", line 11, in run
  File "/opt/conda/lib/python3.5/distutils/command/install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "/opt/conda/lib/python3.5/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/opt/conda/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/build_ext.py", line 77, in run
  File "/opt/conda/lib/python3.5/site-packages/Cython/Distutils/build_ext.py", line 164, in run
    _build_ext.build_ext.run(self)
  File "/opt/conda/lib/python3.5/distutils/command/build_ext.py", line 338, in run
    self.build_extensions()
  File "/opt/conda/lib/python3.5/site-packages/Cython/Distutils/build_ext.py", line 172, in build_extensions
    self.build_extension(ext)
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/build_ext.py", line 198, in build_extension
  File "/opt/conda/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
    depends=ext.depends)
  File "/opt/conda/lib/python3.5/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/opt/conda/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 156, in save_modules
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 246, in run_setup
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 276, in run
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 245, in runner
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 47, in _execfile
  File "/tmp/easy_install-kx1jraxq/cffi-1.11.5/setup.py", line 240, in <module>
    "pytools>=2017.6",
  File "/opt/conda/lib/python3.5/distutils/core.py", line 163, in setup
    raise SystemExit("error: " + str(msg))
SystemExit: error: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1100, in run_setup
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 249, in run_setup
  File "/opt/conda/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
  File "/opt/conda/lib/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 168, in save_modules
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 143, in resume
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/_vendor/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 156, in save_modules
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 197, in setup_context
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 246, in run_setup
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 276, in run
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 245, in runner
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/sandbox.py", line 47, in _execfile
  File "/tmp/easy_install-kx1jraxq/cffi-1.11.5/setup.py", line 240, in <module>
    "pytools>=2017.6",
  File "/opt/conda/lib/python3.5/distutils/core.py", line 163, in setup
    raise SystemExit("error: " + str(msg))
SystemExit: error: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-9we4w_vo/pyopencl/setup.py", line 265, in <module>
    main()
  File "/tmp/pip-build-9we4w_vo/pyopencl/setup.py", line 261, in main
    zip_safe=False)
  File "/tmp/pip-build-9we4w_vo/pyopencl/aksetup_helper.py", line 21, in setup
    setup(*args, **kwargs)
  File "/opt/conda/lib/python3.5/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 315, in __init__
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 361, in fetch_build_eggs
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 851, in resolve
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 1123, in best_match
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/__init__.py", line 1135, in obtain
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/dist.py", line 428, in fetch_build_egg
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 664, in easy_install
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 694, in install_item
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 875, in install_eggs
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1114, in build_and_install
  File "/opt/conda/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/setuptools/command/easy_install.py", line 1102, in run_setup
distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1
---------------------------------------------------------------------------
Sorry, your build failed. Try rerunning configure.py with different options.
---------------------------------------------------------------------------

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9we4w_vo/pyopencl/ You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. The command '/bin/sh -c /opt/conda/bin/pip3 install dask psutil natsort pyspik

pwollstadt commented 6 years ago

Thanks for sharing @russelljjarvis. I will add this to the wiki if you don't mind.

You only need pyopencl if you intend to use the GPU/OpenCL estimators. That's why IDTxl can be installed even if pyopencl is not present on your system. You can use the JIDT/JAVA estimators for TE estimation. It will complain though when you try to use the OpenCL estimators.

russelljjarvis commented 6 years ago

I have been reading your wiki a lot, actually I will need to revise the Dockerbuild instructions a bit. Since the docker build above still breaks, but during later instructions.

I have been trying to do multivariate TE estimates in binned binary spike train data (from neo and elephant data types), that come a PyNN network simulation.

I found that I could wrangle the neo spike train into a idtxl.data object, but when I tried to run the code, I got errors about missing :

OpenCL.settings = {'cmi_estimator': 'JidtKraskovCMI',
            'max_lag_sources': 3,
            'max_lag_target': 3,
            'min_lag_sources': 1}

Do you think if I simply change n_procs from =2 to =1, the code will no longer depend on OpenCL, as it will no longer be regarded as parallel code?

Note about snippet below mdf1 is a neo segment object containing analog signals (membrane potentials) and spike trains. It's tempting to use the continuous membrane potentials as signals that are input into multivariate TE, as I suspect interactions between inhibitory to excitatory neurons could be better represented using the continuous membrane potential.

This code works:

    import numpy as np
    from idtxl.multivariate_te import MultivariateTE
    from idtxl.data import Data
    n_procs = 1
    settings = {
        'cmi_estimator': 'JidtDiscreteCMI',
        'n_perm_max_stat': 21,
        'max_lag_target': 5,
        'max_lag_sources': 5,
        'min_lag_sources': 4}

    binary_trains = []
    for spiketrain in mdf1.spiketrains:
        x = conv.BinnedSpikeTrain(spiketrain, binsize=5 * pq.ms, t_start=0 * pq.s)
        binary_trains.append(x.to_array())
    dat = Data(np.array(binary_trains), dim_order='spr')

This code breaks:

    dat.n_procs = n_procs

    mte = MultivariateTE()
    res_full = mte.analyse_network(settings=settings, data=dat)

Traceback

        0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
        0, 0, 0, 0]], dtype=int64)]
Adding data with properties: 1 processes, 122 samples, 400 replications
overwriting existing data
<idtxl.data.Data object at 0x7fc267b39a58>

####### analysing target with index 0 from list [0]
PyOpenCl is not available on this system. Install it using pip or the package manager to use OpenCL-powered CMI estimation.
  File "/opt/conda/lib/python3.5/site-packages/idtxl/estimators_opencl.py", line 7, in <module>
    import pyopencl as cl

Traceback (most recent call last):
  File "sa.py", line 112, in <module>
    te(mdfl)
  File "sa.py", line 77, in te
    res_full = mte.analyse_network(settings=settings, data=dat)
  File "/opt/conda/lib/python3.5/site-packages/idtxl/multivariate_te.py", line 163, in analyse_network
    sources[t])
  File "/opt/conda/lib/python3.5/site-packages/idtxl/multivariate_te.py", line 273, in analyse_single_target
    self._initialise(settings, data, sources, target)
  File "/opt/conda/lib/python3.5/site-packages/idtxl/network_inference.py", line 51, in _initialise
    self._cmi_estimator = EstimatorClass(settings)
TypeError: Can't instantiate abstract class JidtKraskov with abstract methods estimate
mwibral commented 6 years ago

Hi Russell,

I wonder where that opencl dependency creeps in. Sicne youi're using 'JIDTKraskovCMI' the code shouldn't need any oepncl. Could you post the full error message?

Best,

Michael Wibral

On 23.04.2018 05:22, Russell Jarvis wrote:

I have been reading your wiki a lot, actually I will need to revise the Dockerbuild instructions a bit.

I have been trying to do multivariate TE estimates in binned binary spike train data (from neo and elephant data types), that come a PyNN network simulation.

I found that I could wrangle the neo spike train into a |idtxl.data| object, but when I tried to run the code, I got errors about missing OpenCL.

Do you think if I simply change |n_procs| from |=2| to |=1|, the code will no longer depend on OpenCL, as it will no longer be regarded as parallel code?

Works:

 import  numpyas  np
 from  idtxl.multivariate_teimport  MultivariateTE
 from  idtxl.dataimport  Data
 n_procs=  1
 settings=  {
     'cmi_estimator':'JidtKraskovCMI',
     'n_perm_max_stat':21,
     'max_lag_target':5,
     'max_lag_sources':5,
     'min_lag_sources':4}
 settings['cmi_estimator']=  'JidtKraskovCMI'
 binary_trains=  []
 for  spiketrainin  mdf1.spiketrains:
     x=  conv.BinnedSpikeTrain(spiketrain,binsize=5  *  pq.ms,t_start=0  *  pq.s)
     binary_trains.append(x.to_array())
 dat=  Data(np.array(binary_trains),dim_order='spr')

breaks:

 dat.n_procs=  n_procs

 mte=  MultivariateTE()
 res_full=  mte.analyse_network(settings=settings,data=dat)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pwollstadt/IDTxl/issues/12#issuecomment-383443748, or mute the thread https://github.com/notifications/unsubscribe-auth/AIqYGtJN8XpRUyGsrE1veV1NovxKTLW5ks5trUkJgaJpZM4Td8as.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/pwollstadt/IDTxl","title":"pwollstadt/IDTxl","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/pwollstadt/IDTxl"}},"updates":{"snippets":[{"icon":"PERSON","message":"@russelljjarvis in #12: I have been reading your wiki a lot, actually I will need to revise the Dockerbuild instructions a bit.\r\n\r\nI have been trying to do multivariate TE estimates in binned binary spike train data (from neo and elephant data types), that come a PyNN network simulation.\r\n\r\nI found that I could wrangle the neo spike train into a idtxl.data object, but when I tried to run the code, I got errors about missing OpenCL.\r\n\r\nDo you think if I simply change n_procs from =2 to =1, the code will no longer depend on OpenCL, as it will no longer be regarded as parallel code?\r\n\r\nWorks:\r\npython\r\n import numpy as np\r\n from idtxl.multivariate_te import MultivariateTE\r\n from idtxl.data import Data\r\n n_procs = 1\r\n settings = {\r\n 'cmi_estimator': 'JidtKraskovCMI',\r\n 'n_perm_max_stat': 21,\r\n 'max_lag_target': 5,\r\n 'max_lag_sources': 5,\r\n 'min_lag_sources': 4}\r\n settings['cmi_estimator'] = 'JidtKraskovCMI'\r\n binary_trains = []\r\n for spiketrain in mdf1.spiketrains:\r\n x = conv.BinnedSpikeTrain(spiketrain, binsize=5 * pq.ms, t_start=0 * pq.s)\r\n binary_trains.append(x.to_array())\r\n dat = Data(np.array(binary_trains), dim_order='spr')\r\n\r\nbreaks:\r\npython\r\n dat.n_procs = n_procs\r\n\r\n mte = MultivariateTE()\r\n res_full = mte.analyse_network(settings=settings, data=dat)\r\n"}],"action":{"name":"View Issue","url":"https://github.com/pwollstadt/IDTxl/issues/12#issuecomment-383443748"}}}

--

Prof. Dr. rer. nat. Michael Wibral MEG Labor, Brain Imaging Center Goethe Universität

Heinrich Hoffmann Strasse 10 60528 Frankfurt am Main

Phone: +49 69 6301 83193 Fax: +49 69 6301 83231

russelljjarvis commented 6 years ago

Yes, that's why I am confused too. All of the work I am referencing resides in git repositories. I have done so in a seperate dedicated issue https://github.com/pwollstadt/IDTxl/issues/13

Russell.

pwollstadt commented 6 years ago

Hi Russel, I tried to replicate the issue about IDTxl unintentionally importing pyopencl even though your are using the JIDT estimator, but the below scripts runs fine (in a conda environment with JPype and without pyopencl). Could you run the script on your machine and tell me what happens?

import numpy as np
from idtxl.multivariate_te import MultivariateTE
from idtxl.data import Data

dat = Data(np.random.rand(10,100,3), dim_order='psr')
settings = {
    'cmi_estimator': 'JidtKraskovCMI',
    'n_perm_max_stat': 21,
    'max_lag_target': 5,
    'max_lag_sources': 5,
    'min_lag_sources': 4}
mte = MultivariateTE()
res_full = mte.analyse_network(settings=settings, data=dat, targets=[0])

Regarding the other issues: As i mentioned in #13, you don't need to set the number of processes, the Data() object gets this from the dimension of your data array. Also, the error TypeError: Can't instantiate abstract class JidtKraskov with abstract methods estimate could result from setting settings['cmi_estimator']='JidtKraskov' instead of settings['cmi_estimator']='JidtKraskovCMI'. Can you make sure, the estimator name is specified correctly?

Thanks!

russelljjarvis commented 6 years ago

I agree with you, it will probably run on my end as described. I will get back to this issue in the next week. Russell.

pwollstadt commented 6 years ago

Hi all, I am closing this issue because it has been inactive for a few months. Please reopen it if you have any news on installation instructions or think about moving this discussion to the google group.