-
Notifications
You must be signed in to change notification settings - Fork 22
B. Installation Instructions
0.1 Download and install Anaconda (the current version at the time this wiki was written is 4.12.0) for your Operating System, and install it following the official instructions for Linux, or for Windows.
0.2 If your system has a GPU that supports CUDA, install CUDA on your system first. Make sure that your Cuda version is the highest supported by the latest PyTorch libraries before installing Cuda here. You can download the version you need from the official NVIDIA website.
1.1 Create an environment (choose name, e.g. "bspy"):
conda create -n bspy python==3.9.1
1.2. Activate the environment:
activate bspy
You can install it directly via pip using:
pip install brainspy
If you want to use the package brainspy-smg, for surrogate model generation, you need to install it after installing brains-py:
pip install brainspy-smg
The installation of the pytorch package depends on the hardware you are using to run it, particularly if you are using GPU(s) or not, see PyTorch. You can find more information on the official PyTorch website. Remember that the supported version of PyTorch for brains-py is 1.11.0. Other versions might work as well, try them at your own risk. You can complete your installation running one of the following commands, depending on how is your computer:
-
If you do not have a GPU, and only a CPU, then run this command:
conda install cpuonly -c pytorch
-
If you have a GPU with cuda 10.2, then run this command:
conda install cudatoolkit=10.2 -c pytorch
-
If you have a GPU with cuda 11.3, then run this command:
conda install cudatoolkit=11.3 -c pytorch
To check whether CUDA works properly with Pytorch, launch Python from the activated environment 'bspy' and input the following:
>>> import torch
>>> print(torch.cuda.is_available())
It should return "True" if CUDA support is available.
If this does not work, try following the full commands from https://pytorch.org/get-started/previous-versions/ :
-
If you do not have a GPU, and only a CPU, then run this command:
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cpuonly -c pytorch
-
If you have a GPU with cuda 10.2, then run this command:
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=10.2 -c pytorch
-
If you have a GPU with cuda 11.3, then run this command:
conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch
This expansion of the installation is meant to be for computers at the laboratories only. If you are a new student and want to get access to the computers that are connected to National Instruments, please request the guide for newcomers to one of the organisers of this repository (Available on the Teams Group for BRAINS as Newcomers guide to lab computers.docx.
As further explained in the Introduction, this repository has been created to support different combinations of National Instruments (NI) products. If you are installing this repository on a new hardware setup, from scratch, you will also need to download install the drivers for the instruments. Particularly the NI-DAQmx. Although it is not strictly necessary, you can also download and install Labview for Windows, Mac OS or Linux.
For this extended installation, it is mandatory to have the latest version of NiDaQMX drivers installed from the official website of National Instruments, as the python libraries are just a wrapper for their compiled libraries. If you are using a Windows operating system, you can simply download the drivers from their official website.
If you have an installation of a computer running National Instruments with windows, you can check if the win32api library was installed adequately as follows. Launching Python from the activated environment 'bspy' and input the following:
>>> import win32api
If this throws an error, try reinstalling the package as follows:
pip uninstall pypiwin32 pywin32 -y && pip install pywin32==225
If you are using a Linux operating system, you need to compile the National Instruments driver packages yourself. You can find more information about which Linux distributions are supported here. Follow these instructions, created by MRPT.org, to compile the packages (on OpenSUSE).
You need a few packages to compile NI’s kernel driver module. Open a console, and execute:
sudo zypper in kernel-devel kernel-source kernel-syms
Check which kernel module are you using
uname -r
Change the directory to the /usr/src/linux-[VERSION] directory, where [VERSION] corresponds to the currently running kernel version. Run the following, replacing [VERSION] as corresponds to your system:
sudo su
zcat /boot/symvers-[VERSION].gz > Module.symvers
make cloneconfig # Configure sources for kernel
make modules_prepare # Prepare the headers for compilation
NI KAL is National Instruments’ Kernel Abstraction Layer (KAL). It is required before installing NI DAQmx Base or any other NI stuff.
- Download the latest version of NI KAL from the official website.
- Extract the .iso file, for example, right-clicking on it and selecting “Extract”.
- Say you have now NIKAL contents in ~/Downloads/NIKAL24. Open a console and run:
cd ~/Downloads/NIKAL24
sudo ./INSTALL --nodeps
Accept the license and confirm the target directory to finish the installation. Then, recompile the module kernel, with:
sudo /usr/local/natinst/nikal/bin/updateNIDrivers
Reboot your system. You can check that NI KAL has been installed correctly by running:
sudo modprobe nikal
sudo lsmod | grep nikal
You should see something like:
nikal 93934 0
Installing DAQmx Base in a 64bit OS is not officially supported by NI, so a few extra steps are required. Here is the recipe:
- Download the latest Linux version of NI DAQmx Base
- Save the
nidaqmxbase-3.7.0.iso
file, for example to~/Downloads
. - Open a console in the download directory and extract the ISO contents into a new directory named “DAQmx”:
mkdir DAQmx tmp
sudo mount -o loop nidaqmxbase-3.7.0.iso tmp
cp -r --no-preserve=ownership tmp/* DAQmx
sudo umount tmp
rm -fr tmp
- Before installing NVISA, patch the installation script as follows:
cd DAQmx/nivisa/
chmod u+w . INSTALL
perl -p -i -e "s/RPMOpts=--nodeps/RPMOpts=\"--replacefiles --nodeps\"/g" INSTALL
perl -p -i -e "s/RPMOpts=\"\"/RPMOpts=\"--replacefiles\"/g" INSTALL
-
Now, we can run the INSTALL script as root and NIVISA will get installed:
sudo ./INSTALL
-
Try running niiotrace with the following command:
/usr/local/bin/niiotrace
If you see the following error:/usr/local/bin/niiotrace: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
you can fix it by installing the missing libraries:
sudo zypper in libgcc_s1-32bit libstdc++6-32bit libXinerama1-32bit Mesa-libGL1-32bit
Try running niiotrace and it should work now.
-
Now we can install the rest of DAQmx Base packages"
cd ~/Downloads/DAQmx/ sudo rpm -i nidaqmxbase-common-3.7.0-f0.i386.rpm sudo rpm --replacefiles -i nidaqmxbase-board-support-3.7.0-f0.i386.rpm sudo rpm -i nidaqmxbase-cinterface-3.7.0-f0.i386.rpm sudo rpm -i --replacefiles nidaqmxbase-usb-support-3.7.0-f0.i386.rpm