Coder Social home page Coder Social logo

uci-carl / carlsim4 Goto Github PK

View Code? Open in Web Editor NEW
82.0 28.0 84.0 91.38 MB

CARLsim is an efficient, easy-to-use, GPU-accelerated software framework for simulating large-scale spiking neural network (SNN) models with a high degree of biological detail.

Home Page: http://www.socsci.uci.edu/~jkrichma/CARLsim

License: MIT License

Makefile 2.53% C++ 63.52% Shell 0.03% C 2.71% Cuda 6.76% MATLAB 10.21% CMake 0.35% Java 13.70% HTML 0.18%
cuda spiking-neural-networks gpu simulation-framework

carlsim4's Introduction

CARLsim 4

Build Status Coverage Status Docs Google group

CARLsim is an efficient, easy-to-use, GPU-accelerated library for simulating large-scale spiking neural network (SNN) models with a high degree of biological detail. CARLsim allows execution of networks of Izhikevich spiking neurons with realistic synaptic dynamics on both generic x86 CPUs and standard off-the-shelf GPUs. The simulator provides a PyNN-like programming interface in C/C++, which allows for details and parameters to be specified at the synapse, neuron, and network level.

New features in CARLsim 4 include:

  • Multi-GPU support
  • Hybrid CPU/GPU mode
  • Multi-compartment and LIF point neurons

If you use CARLsim 4 in your research, please cite this paper.

Chou*, T.-S., Kashyap*, H.J., Xing, J., Listopad, S., Rounds, E.L., Beyeler, M., Dutt, N., and Krichmar, J.L. (2018). "CARLsim 4: An Open Source Library for Large Scale, Biologically Detailed Spiking Neural Network Simulation using Heterogeneous Clusters." In Proceedings of IEEE International Joint Conference on Neural Networks (IJCNN), pp. 1158-1165.

Installation

Detailed instructions for installing the latest stable release of CARLsim on Mac OS X / Linux / Windows can be found in our User Guide.

Linux/MacOS

For Beginner

  1. Download CARLsim 4 zip file by clicking on the Clone or download box in the top-right corner.

  2. Unzip the source code.

  3. Go into CARLsim4 folder

    $ cd CARLsim4
    
  4. Make and install

    $ make
    $ make install
    
  5. Verify installation

    $ cd ~
    $ ls
    

    You will see CARL folder

  6. Go back to CARLsim4 folder and start your own project! The "Hello World" project is a goot starting point for this. Make sure it runs:

    $ cd CARLsim4
    $ cd projects/hello_world
    $ make
    $ ./hello_world
    

For Advanced User and Developer

  1. Fork CARLsim 4 by clicking on the Fork box in the top-right corner.

  2. Clone the repo, where YourUsername is your actual GitHub user name:

    $ git clone --recursive https://github.com/UCI-CARL/CARLsim4.git
    $ cd CARLsim4
    

    Note the --recursive option: It will make sure Google Test gets installed.

  3. Choose between stable release and latest development version:

  4. Choose the installation directory: By default, the CARLsim library lives in ~/CARL/lib, and CARLsim include files live in ~/CARL/include. You can overwrite these by exporting an evironment variable called CARLSIM4_INSTALL_DIR:

    $ export CARLSIM4_INSTALL_DIR=/path/to/your/preferred/dir
    

    or

    $ export CARLSIM4_INSTALL_DIR=/usr/local
    

    if you want to install CARLsim library for all users.

    Also set the following evironment variable:

    $ export CUDA_PATH=/path/to/CUDA
    

    By default CUDA is installed to /usr/local/cuda in Linux systems.

  5. Make and install:

    $ make -j4
    $ sudo -E make install
    

    Note the -E flag, which will cause sudo to remember the CARLSIM4_INSTALL_DIR.

  6. In order to make sure the installation was successful, you can run the regression suite:

    $ make test
    $ ./carlsim/test/carlsim_tests
    
  7. Start your own project! The "Hello World" project is a goot starting point for this. Make sure it runs:

    $ cd projects/hello_world
    $ make
    $ ./hello_world
    

    You can easily create your own project based on this template using the init.sh script:

    $ cd projects
    $ ./init.sh project_name
    

    where project_name is the name of your new project. The script will copy all files from hello_world/ to project_name/, make all required file changes to compile the new project, and add all new files to git.

Using nvidia docker

  1. Using CARLsim4 on an Nvidia-docker image follows the instructions above. Only important thing to keep in mind is to copy the $CUDA_PATH/samples directory to the docker, which does not come with the nvidia docker image. CARLsim4 uses "helper_functions.h" from the library.

Using CMake

  1. Obtatin CARLsim4's source code.

  2. Create a build directory (you can make it anywhere)

    $ mkdir .build
    
  3. Proceed into build directory and do configuration:

    $ cd .build
    $ cmake \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr/local/carlsim \
        -DCARLSIM_NO_CUDA=OFF \
        <path-to-carlsim>
    

    As you can see cmake accepts several options -D<name>=<value>: they define cmake variables. CMAKE_BUILD_TYPE=Release means that we are going to build release version of the library. If you need debug version then pass Debug. CMAKE_INSTALL_PREFIX specifies a directory which we are going to install the library into. CARLSIM_NO_CUDA switches on/off support of CUDA inside the library. <path-to-carlsim> must be replaced with the path to the CARLsim4's source directory.

  4. Build:

    make -j <jobs-num>
    

    Set <jobs-num> to the number of logical processors your computer has plus one, this will employ parallel building.

  5. Install:

    make install
    

Windows

Simply download the code. Open and build CARLsim.sln. Run the "Hello World" project file projects\hello_world\hello_world.vcxproj.

Prerequisites

CARLsim 4 comes with the following requirements:

  • (Windows) Microsoft Visual Studio 2015 or higher.
  • (optional) CMake 3.0 or higher in case you want to build it using CMake.
  • (optional) CUDA Toolkit 6.0 or higher. For platform-specific CUDA installation instructions, please navigate to the NVIDIA CUDA Zone. This is only required if you want to run CARLsim in GPU_MODE. Make sure to install the CUDA samples, too, as CARLsim relies on the file helper_cuda.h.
  • (optional) A GPU with compute capability 2.0 or higher. To find the compute capability of your device please refer to the CUDA article on Wikipedia. This is only required if you want to run CARLsim in GPU_MODE.
  • (optional) MATLAB R2014a or higher. This is only required if you want to use the Offline Analysis Toolbox (OAT).

As of CARLsim 3.1 it is no longer necessary to have the CUDA framework installed. However, CARLsim development will continue to focus on the GPU implementation.

The latest release was tested on the following platforms:

  • Ubuntu 16.04
  • Mac OS X 10.11 (El Capitan)
  • Windows 7/10 (Tested using VS 15 and cuda 8.0)

carlsim4's People

Contributors

eightdatabits avatar gitter-badger avatar hkashyap avatar jkrichma avatar josephdvl avatar karlxing avatar kexinchenn avatar kristoforcarlson avatar mbeyeler avatar mode89 avatar roundse avatar sigmax avatar staslist avatar tingshuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carlsim4's Issues

LIF neurons won't spike

I'm having a bit of a strange problem. I've run a test simulation with a single LIF neuron and different levels of input current (sim.setExternalCurrent(I)) where 1 < I < 1000 and I found that the neuron responds fairly normally (although the f-I curve has steps and is not linear as it should be for LIF). However, when I try to run a simulation with multiple groups of LIF neurons (3000 neurons in total), the simulation is not producing any spikes, even for excessively large input current values or input Poisson spike train rates. I will attach the project file here.
main_real_net.cpp.zip

Please let me know what other information I could provide to help resolve this. Thanks!

Update PTI code

I'm not sure the C++ code for the PTI interface builds anymore, and the build process should be simplified regardless. Can we integrate the PTI helper classes and tests into the main build, so it's not separate anymore?

Tutorial 4 Matlab OAT error

Running CARLsim4 with Matlab 2017b, I get the following error when trying to run the OAT with the smooth output:

Expected one output from a curly brace or dot indexing expression, but there were 0 results.

Error in NetworkMonitor/setGroupPlotType (line 609)
        obj.groupMonObj{gId}.setDefaultPlotType(plotType);

Error in demoSmooth (line 27)
NM.setGroupPlotType(-1, 'heatmap')

I think that it could be fixed by updating demoSmooth.m with the following patch:

*** doc/source/tutorial/4_image_processing/scripts/demoSmooth.m.orig	2018-10-18 11:23:24.753124357 -0700
--- doc/source/tutorial/4_image_processing/scripts/demoSmooth.m	2018-10-18 11:23:28.205065731 -0700
*************** createStimFromImage('../input/carl.jpg',
*** 24,29 ****
  % Plot network activity
  clear NM
  NM = NetworkMonitor('../results/sim_smooth.dat')
! NM.setGroupPlotType(-1, 'heatmap')
  NM.plot
  
--- 24,29 ----
  % Plot network activity
  clear NM
  NM = NetworkMonitor('../results/sim_smooth.dat')
! NM.setGroupPlotType(NM.groupNames{end}, 'heatmap')
  NM.plot

However, I'm not sure if the root cause is the version of Matlab that I am using.

Missing carlsim.lib

Trying to build with VS 2019 Community on Windows 10.
Trying the hello_world but get a missing file:

'C:\CARLsim\x64\Release\carlsim.lib'

It isn't part of the GetHub download.

Can't Install CARLsim4 with latest CUDA and Latest VS

I get:
C:\CARLsim\doc\source\tutorial\8_compartments\tutorial_8_compartments.vcxproj : error : The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 8.0.props" was not found.

Using the latest CUDA install - cuda_10.1.168_425.25_win10.exe
Windows 10
Visual Studio Microsoft Visual Studio Community 2019
Version 16.0.0
VisualStudio.16.Release/16.0.0+28729.10
Microsoft .NET Framework
Version 4.7.03190

Assertion error when calling sim.setWeight on 2 different neuron groups

I am trying to use sim.setWeight to apply a normal distribution to the synaptic weights between 2 neuron groups. However, when I call sim.setWeight I get the following assertion error:

carlsim/kernel/src/snn_manager.cpp:1337: void SNN::setWeight(short int, int, int, float, bool): Assertion `managerRuntimeData.connIdsPreIdx[pos_ij] == connId' failed.

It seems like the wrong connection ID is being retrieved, however I cannot seem to figure out what the variable pos_ij is and therefore can't figure out why the error is occurring (I tried printing pos_ij from snn_manager.cpp but nothing would print).

I believe I am giving the setWeight method the correct inputs (connection ID and 0-indexed neuron numbers), so I am thinking this may be a bug. Also, when calling setWeight on a connection from one neuron group to itself there is no problem, only when it is called on 2 separate neuron groups.

README/Chapter 1: `make test` won't work before gtest is built

Imported from CARLsim3, applies to README/User Guide Chapter 1 of CARLsim4, too:

From @SigmaX :

Since we include gtest as a submodule, building tests is easy and convenient.

But the README suggest that building the tests is as simple as running make test after checkout. This won't work until gtest has been built—that that takes a few steps.

We should update the README to direct users to the gtest README, and to build the gtest library in the designated path.

Compartments CPU (release) vs GPU (release) Spike Times Deviation

The issue was revelead by Compartments spikeTimesCPUvsGPU test.
The issue occurs at some, but not all timesteps.

CPU + release, CPU + debug, and GPU + debug modes all produce the same spike times when running compartment models. The GPU + release mode, however, deviaties from the other three models.

Overview of the issue:
The GPU release mode seems to suffer from occassional calculation 'errors' that slowly snowball out of control. The cause of these calculation 'errors' has not been determined.

More in depth look:
The deviation is first evident in regard to voltage values then recovery & current variables.
The deviation slowly increases in size, eventually resulting in deviation between spike times.
The deviation in voltage values begins early on (within first 100ms).

The GPU release voltage values deviate from GPU debug voltage.
The CPU release voltage and CPU debug voltage do not deviate.

Print statements in GPU release mode seem to affect the reported values.
This is not the case in GPU debug mode.

Attempted:
Equating different optimization flags between debug & release modes for both C/C++ and CUDA C/C++.

https://devtalk.nvidia.com/default/topic/551571/different-results-when-using-gpu-debug-option-g-/?offset=6

https://www.researchgate.net/post/Debug_mode_VS_release_mode_in_visual_studio

https://devtalk.nvidia.com/default/topic/670121/release-and-debug-modes-on-cuda-5-0/

Disabling FMAD:
https://stackoverflow.com/questions/14552576/disabling-fused-multiply-add-in-cuda-under-visual-studio-2010

Potential Causes:

  1. Race condition?
  2. ???

make test fails from master

Hi there,

I have an issue while compiling 'make test' with carlsim4.
See the picture below, the error seems related to a new LIF neuron model that is not present in carlsim4...

error_carlsim4

any idea how to fix this?

thank you for your good work.
Federico

User Defined connection error

I exactly followed the customized synaptic connection codes (copy-paste) and saw the following error:
error: ‘MyConnection::MyConnection()’ is private within this context
MyConnection myConn;
^~~~~~
src/main_Project_1.cpp:28:6: note: declared private here
MyConnection() {}
^~~~~~~~~~~~
src/main_Project_1.cpp:81:15: error: ‘virtual MyConnection::~MyConnection()’ is private within this context
MyConnection myConn;
^~~~~~
src/main_Project_1.cpp:29:6: note: declared private here
~MyConnection() {}
^
src/main_Project_1.cpp:82:44: error: no matching function for call to ‘CARLsim::connect(int&, int&, MyConnection&, bool)’
sim.connect(gExc, gExc, myConn,SYN_PLASTIC);

Any help please?

`make debug` does not exist?

The docs and make help both speak of a make debug and make debug_nocuda target.

Not sure these still exist. I see them as listed as .PHONY targets in carlsim/carlsim.mk, but they don't seem to actually be implemented anywhere.

Took me a minute to figure out (as a newcomer) that make release_nocuda works just fine, and that it's specifically debug and debug_nocuda that don't work.

fix Tutorial 1 to fix reset spike rate

When setRates is called on a PSG obejct to reset input spike rates, setSpikeRate must be called again. This is documented in the user guide, however the Tutorial 1 does not have this and as a result the spike rates are not updated.

float inputRateHz = i*10.0f;
sim.setSpikeRate(gIn, &in);
in.setRates(inputRateHz);

Memory leaks in pthread_attr_setaffinity_np

Valgrind reports memory leaks in pthread_attr_setaffinity_np. I'm not exactly sure what the problem is. But, could this explain why the test suite "gets stuck", as repeated allocations/runs would make the simulation slower and slower? Your local machine probably has more memory than the average Travis node, so Travis should run into problems earlier.

Tested with the "Hello World" project with NO_CUDA:

$ valgrind --leak-check=full --log-file="log.out" ./hello_world

Here's an example and the summary of the report:

==21728== 1,280,000 bytes in 10,000 blocks are definitely lost in loss record 16 of 16
==21728==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21728==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21728==    by 0x5053855: pthread_attr_setaffinity_np@@GLIBC_2.3.4 (pthread_attr_setaffinity.c:47)
==21728==    by 0x427E13: SNN::clearExtFiringTable() (in /home/mbeyeler/source/CARLsim4/projects/hello_world/hello_world)
==21728==    by 0x43EBE0: SNN::runNetwork(int, int, bool) (in /home/mbeyeler/source/CARLsim4/projects/hello_world/hello_world)
==21728==    by 0x40899B: CARLsim::runNetwork(int, int, bool) (in /home/mbeyeler/source/CARLsim4/projects/hello_world/hello_world)
==21728==    by 0x40589E: main (in /home/mbeyeler/source/CARLsim4/projects/hello_world/hello_world)
==21728==
==21728== LEAK SUMMARY:
==21728==    definitely lost: 10,251,008 bytes in 80,024 blocks
==21728==    indirectly lost: 0 bytes in 0 blocks
==21728==      possibly lost: 0 bytes in 0 blocks
==21728==    still reachable: 72,736 bytes in 2 blocks
==21728==         suppressed: 0 bytes in 0 blocks

CARLsim4 on Ubuntu 20.04 LTS

I'm about to install Ubuntu on my new PC for running CARLsim4. Has CARLsim4 been tested on newer Ubuntu LTS releases like 18.04 or 20.04?

Visual Studio solution does not open or build without CUDA

I get the following error attempting to open (never mind compile/build) the CARLsim solution file in Visual Studio:

C:\Users\USERNAME\Documents\working\CARLsim4\carlsim\kernel\carlsim.vcxproj(74,5): The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 8.0.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

I tried on VS 2015 and 2017

MAX_CONN_PER_SNN assertion error

In a customized network, I saw that the SNN cannot run when we have more that 256 synapses totally in M groups. BTW, I am using "nocuda" version. I changed the assertion error in my computer to: `++numConnections_ <= MAX_CONN_PER_SNN +1000 ' to fix the error for now and continue running the SNN. Is there any way to change the value of this variable (MAX_CONN_PER_SNN) and also its type? Its type is short-int which is not enough to cover my large networks (syn>32765).

Update Tutorial 7 PTI

The Makefile of tutorial 7 is out of date. Update it to address makefile changes in CARLsim4

CARLsim windows installation

Hi there, I was trying to install CARLsim in my Windows OS. While building the carlsim solution file in Visual STUDIO 2015,i got total 36 errors and most of them were 'carlsim_datastructures.h': No such directory found.
Can anyone provide the step by step guidelines to install carlsim in windows ? Thankyou.

Best regards

glbNetworkConfig.maxDelay > 1 despite setting all delays to 1 or less

I wrote a class inheriting ConnectionGenerator to connect groups using normally distributed weights. in the connect method I explicitly set delay = 1. Despite using this custom connection to connect all groups, when trying to add STP I get the error:
[ERROR carlsim/kernel/src/snn_manager.cpp:4864] STP with delays > 1 ms is currently not supported.

This must mean that somewhere glbNetworkConfig.maxDelay must be being set to > 1 incorrectly.

Neuronmonitor declaration in CONFIG state -- fix message saying config or setup

In carlsim/interface/src/carlsim.cpp

UserErrors::assertTrue(carlsimState_ == CONFIG_STATE,
UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONFIG or SETUP.");
should be changed to:
UserErrors::assertTrue(carlsimState_ == CONFIG_STATE,
UserErrors::CAN_ONLY_BE_CALLED_IN_STATE, funcName, funcName, "CONIG.");

Move ECJ extensions into main ECJ codebase

When we first created the ECJ PTI, I was only loosely connected with the ECJ project and didn't have commit rights—so we added some Java code to CARLsim's source tree to make it easier to use ECJ to tune an arbitrary external binary.

These features can now be moved into the ECJ project itself as a general feature.

Reconsider which of our custom ECJ extensions are really necessary (Sean wondered why created a new problem form and evaluator, instead of just using GroupedProblemForm), and rewrite or move it into ECJ.

The result should be that CARLsim no longer has any extra Java code with a separate build procedure.

Tutorial 5 breaks

Tutorial 5 motion energy does not work. It might be the issue of changing Grid3D structure in CARLsim4.
CUDA error at cppME/src/motion_energy.cu:543 code=11(cudaErrorInvalidValue) "cudaMemcpy(d_stim,stim,nrC_*nrX_*nrY_,cudaMemcpyHostToDevice)"

CARLsim still segfaults when ./results doesn't exist

CARLsim still segfaults when ./results doesn't exist, no explanation given. Just learned this the hard way. It's a problem when running executables from subdirectories, such as ./carlsim/tests/carslim_tests.

At the very least, check if directory exists before attempting to create a file within it. Notify the user accordingly.

Even better, make it possible to set a different save directory before CARLsimInit gets called.

inconsistency between partitioning combinations

Jeffrey Kopsick from GMU reported inconsistent results on the 80-20 example, when different GPU partitioning setups were adopted using 3 GPUs vs. 4 GPUs. I could reproduce the same using CPUs as well.

Of the four groups, I get consistent output for 1, 2, and 4 CPUs. In case of three CPUs:

  1. exc1=>0, exc2=>0, exc3=>1, inh =>2 is consistent with 1,2, 4 CPUs
  2. When I let the inhibitory group share a CPU with an excitatory group, it becomes inconsistent. Which is not an expected behavior.

On a system with two GPUs, and a run with 2 CPUs and 2 GPUs was fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.