CNS: Cortical Network Simulator Programming Guide - Troubleshooting

  1. Troubleshooting
    1. Common Problems and Solutions
      1. Build Errors
      2. Initialization Errors
      3. Run Errors
    2. Debugging

Common Problems and Solutions

Note: this section does not attempt to list every error you might encounter -- just some that are common and whose cause may not be obvious.

Build Errors

This section discusses problems running cns_build to compile a package.

Problem Remedy
Can't find the NVIDIA compiler, libraries, etc. Have you followed all the installation instructions?
Can't find the package you are trying to compile. cns_build locates a package by finding the directory containing the function package.m. This directory must be in the MATLAB path for that to occur.
Object file is locked. You may have a cns session open. Try:

cns done all

If that doesn't work, restart MATLAB.

Initialization Errors

This section discusses problems running cns('init') to initialize a network model on the GPU.

Problem Remedy
Can't load NVIDIA libraries. Have you followed all the installation instructions?
No device (GPU) available. There are several possibilities:

  • Does this computer even have a GPU? (If not, you can still run CNS -- slowly -- in CPU mode.)
  • All this computer's GPUs have been claimed by other users.
  • You may have other MATLAB process running with open cns sessions. Sometimes (especially on Linux) an instance of MATLAB may still be running even though you've closed the terminal.
  • Are you signed into your Windows computer using Remote Desktop? This doesn't work because Windows won't load the right display driver. Use VNC instead.
Not enough memory. The most likely cause is that your model is simply too big to fit into GPU memory. Try running cns('test') to see how much memory your model requires. This will give you an idea of how much smaller your model needs to be to work. Note that different GPUs have different amounts of memory.

If you've run cns('test') and it looks like your model should fit, maybe another process (yours or someone else's) is using the same card. Try configuring your card to allow only one process at a time.

Run Errors

This section discusses problems with cns('run') or cns('step').

Problem Remedy
Kernel launch errors. This happens when a kernel's block size -- the number of cells it tries to compute at once -- is too large. Try making it smaller.

The maximum block size you can use depends on two things:

  • The complexity of your kernel and the size of any local arrays it uses.
  • The quantity of registers and shared memory your particular GPU has.
Not enough memory for outputs. This typically happens when you're trying to use cns('run') to compute a large number of iterations and return a large quantity of data for each iteration. The default behavior is for CNS to collect the entire result in GPU memory and then transfer it back to the CPU all at once when all the iterations are complete. You can adjust this by using the buffer size parameter, or if you don't need data for every iteration, the sample rate parameter.


CNS provides two main tools for debugging.

  • You can use cns('get') to retrieve the contents of variables between iterations or steps.
  • You can embed PRINT or ERROR statements in your kernel code. Both of these only work in debug mode.