Note: CNS is designed to run on a GPU, but can also run without one (much more slowly). These instructions are written assuming you have a GPU. If you don't, skip any steps written in italics and also read this section.
Installation Menu
Requirements
- Linux, Windows, or Mac OS. (Note: CNS is not developed or tested on the Mac. Build scripts for Mac have been provided by users.)
- MATLAB 2009b or higher.
- CUDA 4.1 or 5.0.
- A C++ compiler compatible with all the above.
- Build scripts assume gcc for Linux or Mac and Visual Studio for Windows.
- (Linux or Mac only.) For CNS to control multiple GPUs from one instance of MATLAB, and to run models asynchronously, your compiler must have the <pthread.h> library.
- An NVIDIA GPU that supports the CUDA API.
Recently Tested Configurations
Linux:
- Ubuntu 10.04 64-bit
- MATLAB 2010b
- CUDA 4.1 or 5.0
- GCC 4.4.3
Windows:
- Windows 7 64-bit
- MATLAB 2010b
- CUDA 4.1
- Microsoft Visual C++ 2010
Preparing Your Computer
- Make sure MATLAB's "mex" command can find your C++ compiler. You can set this up in MATLAB with the command "mex -setup".
- Make sure the CUDA driver and CUDA toolkit (both version 4.1 or 5.0) are installed. If you need to install them, install the driver first. Note that CNS does not require the CUDA SDK.
- (Linux only.) Consider setting your GPU(s) to "exclusive access" mode to ensure that they will only allow one model at a time to run. Usually, trying to run multiple models on one GPU results in out-of-GPU-memory errors. Setting exclusive access avoids this. In multi-GPU systems, this setting also allows CNS to automatically select a GPU that isn't being used. Under other operating systems, GPU selection must currently be managed manually. See the NVIDIA documentation for how to specify exclusive access under Linux.
- (Linux or Mac only.) Make sure you have the C shell installed.
- Make sure that on operating system startup:
- the system path contains the path to the NVIDIA compiler (nvcc). On Linux this is by default "/usr/local/cuda/bin".
- the "mex" command works from the operating system command line. This may involve adding something to your system path.
- (Linux or Mac only.) Make sure that on operating system startup:
- the environment variable "LD_LIBRARY_PATH" contains the path to the NVIDIA libraries. In Linux this is by default "/usr/local/cuda/lib".
Installing Core CNS
- Unpack the archive file and move the "cns" directory to wherever you will be using it.
- Make sure the settings in one of these files (the one corresponding to your OS) are correct for your computer:
cns/scripts/linux/setup cns/scripts/win/setup.bat cns/scripts/mac/setup
- (Linux or Mac only.) Make sure the following permissions are set:
- all files under "cns/scripts" are executable.
- it is possible to create new files in "cns" or subdirectories.
- Make sure the "cns" directory and its subdirectories will be in your MATLAB path on startup. One way to do this is to call "cns/cns_path.m" from your "startup.m" file.
- (In MATLAB.) Create binaries by running:
cns_install
- (In MATLAB.) Compile the demo package using the command:
cns_build demopkg
- (In MATLAB.) Run the demo package by typing "demopkg_run". If everything is working, MATLAB should output the following messages:
Defining a network model.... Building the model (platform: GPU).... Reading a test image and loading it into the model.... Running the model and retrieving result.... Elapsed time is ??? seconds. Plotting result.... Releasing model resources....
and you should also see the following figure:
Installing Packages
Perform the following instructions for any packages you intend to use with CNS.
- Unpack the archive file and move the package directory to where you will be using it.
- (Linux or Mac only.) Make sure permissions are set so that it is possible to create new files in the package directory.
- Make sure the package directory and any subdirectories are in your MATLAB path.
- Compile the package using the command "cns_build package", where package is the package name. Normally this will be the same as the directory name. All file names in the package directory also start with the package name.
Note: if you change anything in a package directory, you must re-run the above cns_build command.
Running Without a GPU
If you need to run CNS without a GPU, do the following.
- Skip any installation steps written in italics above.
- Set CUDA = 0 in one of these files (the one corresponding to your OS):
cns/scripts/linux/setup cns/scripts/win/setup.bat cns/scripts/mac/setup
- In any script that calls cns('init'), you must use the 'cpu' (or 'debug') option. This includes the demopkg_run script mentioned above.