Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 7 additions & 66 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ for(b = 0; b < builderNodes.size(); b++) {
${env.PYTHON} -m venv ${WORKSPACE}/venv
. ${WORKSPACE}/venv/bin/activate
pip install -U pip
pip install numpy scipy pybind11 pytest flaky pytest-cov wheel flake8 bitarray psutil ${cupy}
pip install numpy scipy pybind11 pytest flaky pytest-cov wheel flake8 bitarray psutil build pkgconfig ${cupy}
""";
}

Expand Down Expand Up @@ -263,77 +263,18 @@ for(b = 0; b < builderNodes.size(); b++) {

buildStep("Building Python wheels (${NODE_NAME})") {
dir("genn") {
if(isUnix()) {
// Create virtualenv, install numpy and pybind11; and make Python wheel
echo "Creating Python wheels";
script = """
script = """
. ${WORKSPACE}/venv/bin/activate

python setup.py clean --all 1>> "${outputFilename}" 2>&1
python setup.py bdist_wheel -d . 1>> "${outputFilename}" 2>&1
"""

def wheelStatusCode = sh script:script, returnStatus:true
if(wheelStatusCode != 0) {
setBuildStatus("Building Python wheels (" + env.NODE_NAME + ")", "FAILURE");
}
}
else {
// Build set of dynamic libraries for single-threaded CPU backend
echo "Creating dynamic libraries";
msbuildCommand = """
CALL %VC_VARS_BAT%
msbuild genn.sln /m /verbosity:quiet /p:Configuration=Release_DLL /t:single_threaded_cpu_backend >> "${outputFilename}" 2>&1
""";

// If node has suitable CUDA, also build CUDA backend
if("cuda10" in nodeLabel || "cuda11" in nodeLabel || "cuda12" in nodeLabel) {
msbuildCommand += """
msbuild genn.sln /m /verbosity:quiet /p:Configuration=Release_DLL /t:cuda_backend >> "${outputFilename}" 2>&1
""";
}
// If this node has OpenCL, also build OpenCL backend
if(nodeLabel.contains("opencl")) {
msbuildCommand += """
msbuild genn.sln /m /verbosity:quiet /p:Configuration=Release_DLL /t:opencl_backend >> "${outputFilename}" 2>&1
""";
}

def msbuildStatusCode = bat script:msbuildCommand, returnStatus:true
if(msbuildStatusCode != 0) {
setBuildStatus("Building Python wheels (" + env.NODE_NAME + ")", "FAILURE");
}

// Remove existing virtualenv
bat script:"rmdir /S /Q virtualenv", returnStatus:true;

echo "Creating Python wheels";
script = """
CALL %VC_VARS_BAT%
CALL %ANACONDA_ACTIVATE_BAT%

${env.PYTHON} -m venv virtualenv
pushd virtualenv\\Scripts
call activate
popd

pip install --upgrade pip
pip install wheel "numpy>=1.17" pybind11

copy /Y lib\\genn*Release_DLL.* pygenn

python setup.py clean --all
python setup.py bdist_wheel -d . >> "${outputFilename}" 2>&1
python -m build --wheel . 1>> "${outputFilename}" 2>&1
"""

def wheelStatusCode = bat script:script, returnStatus:true
if(wheelStatusCode != 0) {
setBuildStatus("Building Python wheels (" + env.NODE_NAME + ")", "FAILURE");
}
def wheelStatusCode = sh script:script, returnStatus:true;
if(wheelStatusCode != 0) {
setBuildStatus("Building Python wheels (" + env.NODE_NAME + ")", "FAILURE");
}

// Archive wheel itself
archive "*.whl"
archive "dist/*.whl"
}
}

Expand Down
90 changes: 35 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,11 @@

# GPU-enhanced Neuronal Networks (GeNN)

GeNN is a GPU-enhanced Neuronal Network simulation environment based on code generation for Nvidia CUDA.
GeNN is a GPU-enhanced Neuronal Network simulation environment based on code generation for NVIDIA CUDA and AMD HIP.

## Installation

You can download GeNN either as a zip file of a stable release, checkout the development
version using the Git version control system or use our Docker container.

### Downloading a release
Point your browser to https://github.com/genn-team/genn/releases
and download a release from the list by clicking the relevant source
code button. After downloading continue to install GeNN as described in the [GitHub installing section](#installing-genn) below.

### Obtaining a Git snapshot

If it is not yet installed on your system, download and install Git
(http://git-scm.com/). Then clone the GeNN repository from Github
```bash
git clone https://github.com/genn-team/genn.git
```
The github url of GeNN in the command above can be copied from the
HTTPS clone URL displayed on the GeNN Github page (https://github.com/genn-team/genn).

This will clone the entire repository, including all open branches.
By default git will check out the master branch which contains the
source version upon which the next release will be based. There are other
branches in the repository that are used for specific development
purposes and are opened and closed without warning.

### Installing GeNN

In future we plan on providing binary builds of GeNN via conda. However, for now, GeNN
needs to be installed from source.

#### Pre-installation
### Pre-installation

1. Install the C++ compiler on the machine, if not already present.
For Windows, Visual Studio 2019 or above is required. The Microsoft Visual Studio
Expand All @@ -53,38 +24,47 @@ needs to be installed from source.
https://developer.nvidia.com/cuda-downloads
Be sure to pick CUDA and C++ compiler versions which are compatible
with each other. The latest C++ compiler need not necessarily be
compatible with the latest CUDA toolkit.
compatible with the latest CUDA toolkit. Similarly, if your machine
has an AMD GPU and you haven't installed HIP yet, follow the instructions at
https://rocm.docs.amd.com/projects/HIP/en/latest/install/install.html.
3. GeNN uses the ``CUDA_PATH`` environment variable to determine which
version of CUDA to build against. On Windows, this is set automatically when
installing CUDA. However, if you choose, you can verify which version is
selected by running ``echo $CUDA_PATH`` in a command prompt.
selected by running ``echo %CUDA_PATH%`` in a command prompt.
However, on Linux, you need to set ``CUDA_PATH`` manually with:
``export CUDA_PATH=/usr/local/cuda``
assuming CUDA is installed in /usr/local/cuda (the standard location
on Ubuntu Linux). Again, to make this change persistent, this can
be added to your login script (e.g. ``.profile`` or ``.bashrc``)
4. Either download the latest release of GeNN and extract into your
home directory or clone using git from https://github.com/genn-team/genn
5. On Linux, install the development version of libffi. For example, on Ubuntu you can do this
on Ubuntu Linux). Similarly, if you are using HIP, you need to set the
``HIP_PATH`` variable manually and also specify your platform with either
``export HIP_PLATFORM='nvidia'`` if you wish to use HIP with an NVIDIA GPU
or ``export HIP_PLATFORM='amd'`` if you wish to use an AMD GPU.
To make any of these changes persistent, these commands should be added to your login
script (e.g. ``.profile`` or ``.bashrc``).
4. On Linux, install the development version of libffi. For example, on Ubuntu you can do this
by running ``sudo apt-get install libffi-dev``.
6. Install the pybind11, psutil and numpy packages with pip i.e. ``pip install pybind11 psutil numpy``.


#### Building with setup.py
From the GeNN directory, the GeNN libraries and python package can be built
with ``python setup.py install``. If you wish to create an editable install
(most useful if you are intending to modify GeNN yourself) you can also used
``python setup.py develop``. On Linux (or Windows if you have a debug version
of the python libraries installed) you can build a debug version of GeNN with
``python setup.py build_ext --debug develop``.

#### Building with pip
From the GeNN directory, the GeNN libraries and python package can be built
with ``pip install .``. If you wish to create an editable install
(most useful if you are intending to modify GeNN yourself) you can also used
``pip install --editable .``.

### Docker
### Installation using pip
The easiest way to install GeNN is directly from github using pip.
First of all make sure pip is up to date using :
``pip install -U pip``
Then, to install the latest development version you can use:
``pip install https://github.com/genn-team/genn/archive/refs/heads/master.zip`` or, to install the 5.3.0 release, you can use:
``pip install https://github.com/genn-team/genn/archive/refs/tags/5.3.0.zip``.

### Creating an editable install with pip
If you want to develop GeNN yourself or run userprojects from the GeNN repository, it is helpful to create an 'editable' install.
The easiest way to do this to first 'clone' GeNN from github using ``git clone https://github.com/genn-team/genn.git``.
Then, navigate to the GeNN directory and install using ``pip install -e .``. If you wish to install the additional dependencies needed
to run the userprojects, you can do so using ``pip install -e .[userproject]``.

### Building with setup.py (LEGACY)
Although it is not recommended, in order to build special development versions you sometimes need to install the old fashioned way!
1. Manually install PyGeNN's build dependencies using pip i.e. ``pip install pybind11 psutil pkgconfig setuptools>=61``.
2. Clone GeNN using git i.e. using ``git clone https://github.com/genn-team/genn.git``
3. From the GeNN directory, build PyGeNN using ``python setup.py develop``.
You can build a debug version of GeNN with ``python setup.py build_ext --debug develop``.

## Docker
You can also use GeNN through our CUDA-enabled docker container which comes with GeNN pre-installed.
To work with such CUDA-enabled containers, you need to first install CUDA on your host system as described above and then install docker and the NVIDIA Container Toolkit as described in https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker.
You can then build the GeNN container yourself or download it from Dockerhub.
Expand Down
57 changes: 35 additions & 22 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,49 @@ Pre-installation
https://developer.nvidia.com/cuda-downloads.
Be sure to pick CUDA and C++ compiler versions which are compatible
with each other. The latest C++ compiler need not necessarily be
compatible with the latest CUDA toolkit.
compatible with the latest CUDA toolkit. Similarly, if your machine
has an AMD GPU and you haven't installed HIP yet, follow the instructions at
https://rocm.docs.amd.com/projects/HIP/en/latest/install/install.html.
3. GeNN uses the ``CUDA_PATH`` environment variable to determine which
version of CUDA to build against. On Windows, this is set automatically when
installing CUDA. However, if you choose, you can verify which version is
selected by running ``echo %CUDA_PATH%`` in a command prompt.
However, on Linux, you need to set ``CUDA_PATH`` manually with:
``export CUDA_PATH=/usr/local/cuda``
assuming CUDA is installed in /usr/local/cuda (the standard location
on Ubuntu Linux). Again, to make this change persistent, this can
be added to your login script (e.g. ``.profile``, ``.bash_profile`` or ``.bashrc``)
4. Either download the latest release of GeNN and extract it into your
home directory or clone using git from https://github.com/genn-team/genn
5. On Linux, install the development version of libffi. For example, on Ubuntu you can do this
on Ubuntu Linux). Similarly, if you are using HIP, you need to set the
``HIP_PATH`` variable manually and also specify your platform with either
``export HIP_PLATFORM='nvidia'`` if you wish to use HIP with an NVIDIA GPU
or ``export HIP_PLATFORM='amd'`` if you wish to use an AMD GPU.
To make any of these changes persistent, these commands should be added to your login
script (e.g. ``.profile`` or ``.bashrc``).
4. On Linux, install the development version of libffi. For example, on Ubuntu you can do this
by running ``sudo apt-get install libffi-dev``.
6. Install the pybind11, psutil and numpy packages with pip, i.e. ``pip install pybind11 psutil numpy``.

----------------------
Building with setup.py
Installation using pip
----------------------
From the GeNN directory, the GeNN libraries and python package can be built
with ``python setup.py install``. If you wish to create an editable install
(most useful if you are intending to modify GeNN yourself) you can also use
``python setup.py develop``. On Linux (or Windows if you have a debug version
of the python libraries installed) you can build a debug version of GeNN with
``python setup.py build_ext --debug develop``.

-----------------
Building with pip
-----------------
From the GeNN directory, the GeNN libraries and python package can be built
with ``pip install .``. If you wish to create an editable install
(most useful if you are intending to modify GeNN yourself) you can also use
``pip install --editable .``.
The easiest way to install GeNN is directly from github using pip.
First of all make sure pip is up to date using :
``pip install -U pip``
Then, to install the latest development version you can use:
``pip install https://github.com/genn-team/genn/archive/refs/heads/master.zip`` or, to install the 5.3.0 release, you can use:
``pip install https://github.com/genn-team/genn/archive/refs/tags/5.3.0.zip``.

-------------------------------------
Creating an editable install with pip
-------------------------------------
If you want to develop GeNN yourself or run userprojects from the GeNN repository, it is helpful to create an 'editable' install.
The easiest way to do this to first 'clone' GeNN from github using ``git clone https://github.com/genn-team/genn.git``.
Then, navigate to the GeNN directory and install using ``pip install -e .``. If you wish to install the additional dependencies needed
to run the userprojects, you can do so using ``pip install -e .[userproject]``.

-------------------------------
Building with setup.py (LEGACY)
-------------------------------
Although it is not recommended, in order to build special development versions you sometimes need to install the old fashioned way!

1. Manually install PyGeNN's build dependencies using pip i.e. ``pip install pybind11 psutil pkgconfig setuptools>=61``.
2. Clone GeNN using git i.e. using ``git clone https://github.com/genn-team/genn.git``
3. From the GeNN directory, build PyGeNN using ``python setup.py develop``.
You can build a debug version of GeNN with ``python setup.py build_ext --debug develop``.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=61", "pybind11", "psutil", "pkgconfig"]
build-backend = "setuptools.build_meta"
27 changes: 16 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pkgconfig
import sys
from copy import deepcopy
from platform import system, uname
Expand Down Expand Up @@ -59,13 +60,12 @@
else:
genn_lib_suffix = "_dynamic"

genn_path = os.path.dirname(os.path.abspath(__file__))

pygenn_path = os.path.join(genn_path, "pygenn")
abs_genn_path = os.path.dirname(os.path.abspath(__file__))
genn_include = os.path.join(".", "include", "genn", "genn")
genn_third_party_include = os.path.join(".", "include", "genn", "third_party")
pygenn_path = os.path.join(".", "pygenn")
pygenn_src = os.path.join(pygenn_path, "src")
pygenn_include = os.path.join(pygenn_path, "include")
genn_include = os.path.join(genn_path, "include", "genn", "genn")
genn_third_party_include = os.path.join(genn_path, "include", "genn", "third_party")

# Always package LibGeNN
if WIN:
Expand Down Expand Up @@ -104,6 +104,11 @@
os.path.join(pygenn_path, "libffi" + genn_lib_suffix + ".dll")]
# Otherwise
else:
# Add whatever configuration libffi requires
ffi_config = pkgconfig.parse("libffi")
for k, v in ffi_config.items():
genn_extension_kwargs[k].extend(v)

# --- Linux/macOS libffi linkage ---
genn_extension_kwargs["libraries"].append("ffi")
# Add GeNN library to dependencies
Expand Down Expand Up @@ -260,7 +265,7 @@
package_data.append("libgenn_" + module_stem + "_backend" + genn_lib_suffix + ".so")

# Add backend include directory to both SWIG and C++ compiler options
backend_include_dir = os.path.join(genn_path, "include", "genn", "backends", module_stem)
backend_include_dir = os.path.join(".", "include", "genn", "backends", module_stem)
backend_extension_kwargs["libraries"].insert(0, "genn_" + module_stem + "_backend" + genn_lib_suffix)
backend_extension_kwargs["include_dirs"].append(backend_include_dir)

Expand All @@ -274,16 +279,16 @@
# If compiler is MSVC
if WIN:
# **NOTE** ensure pygenn_path has trailing slash to make MSVC happy
out_dir = os.path.join(pygenn_path, "")
out_dir = os.path.join(abs_genn_path, "pygenn", "")
check_call(["msbuild", "genn.sln", f"/t:{module_stem}_backend",
f"/p:Configuration={genn_lib_suffix[1:]}",
"/m", "/verbosity:quiet",
f"/p:OutDir={out_dir}"],
cwd=genn_path)
cwd=abs_genn_path)
else:
# Define make arguments
make_arguments = ["make", f"{module_stem}_backend", "DYNAMIC=1",
f"LIBRARY_DIRECTORY={pygenn_path}",
f"LIBRARY_DIRECTORY={os.path.join(abs_genn_path, 'pygenn')}",
f"--jobs={cpu_count(logical=False)}"]
if debug_build:
make_arguments.append("DEBUG=1")
Expand All @@ -292,10 +297,10 @@
make_arguments.append("COVERAGE=1")

# Build
check_call(make_arguments, cwd=genn_path)
check_call(make_arguments, cwd=abs_genn_path)

# Read version from txt file
with open(os.path.join(genn_path, "version.txt")) as version_file:
with open(os.path.join(abs_genn_path, "version.txt")) as version_file:
version = version_file.read().strip()

setup(
Expand Down