diff --git a/full-binary-pursuit/Dockerfile b/full-binary-pursuit/Dockerfile new file mode 100644 index 0000000..e50c310 --- /dev/null +++ b/full-binary-pursuit/Dockerfile @@ -0,0 +1,59 @@ +FROM nvidia/cuda:11.7.1-base-ubuntu22.04 + +LABEL maintainer="Vincent Prevosto " + +# USER root +# Ubuntu package installs +RUN apt update && \ + apt install -y --no-install-recommends \ + build-essential \ + libaio1 \ + opencl-headers \ + ocl-icd-libopencl1 \ + # nvidia-opencl-icd \ this is a virtual package - do not install. Instead install the actual package that matches your host's driver version + libnvidia-compute-535 \ + clinfo \ + git \ + wget && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# install miniconda +ENV MINICONDA_VERSION 23.3.1-0 +ENV PY_VERSION py39 +ENV CONDA_DIR /home/miniconda3 +ENV LATEST_CONDA_SCRIPT "Miniconda3-${PY_VERSION}_${MINICONDA_VERSION}-Linux-x86_64.sh" + +RUN wget --quiet https://repo.anaconda.com/miniconda/$LATEST_CONDA_SCRIPT -O ~/miniconda.sh && \ + bash ~/miniconda.sh -b -p $CONDA_DIR && \ + rm ~/miniconda.sh +ENV PATH=$CONDA_DIR/bin:$PATH +ENV PYTHONPATH=$CONDA_DIR/bin:$CONDA_DIR/lib/python3.9/site-packages +RUN conda update conda && \ + conda install conda-build && \ + conda install conda-forge::ocl-icd-system + # See pyopencl docs: + # https://documen.tician.de/pyopencl/misc.html#using-vendor-supplied-opencl-drivers-mainly-on-linux + +# make conda activate command available from /bin/bash --login shells +RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> /root/.profile +# make conda activate command available from /bin/bash --interactive shells +RUN conda init bash + +# Install IBL python port of pykilosort +RUN git clone https://github.com/njh27/spikesorting_fullpursuit.git /src/fullpursuit +WORKDIR /src/fullpursuit + +# Install conda environment +SHELL ["conda","run","-n","base","/bin/bash","-c"] +RUN conda install -c intel mkl mkl-service +RUN conda install -c defaults numpy matplotlib +RUN conda install -c conda-forge pyopencl scipy scikit-learn +RUN pip install Cython + +# Install full binary pursuit +RUN conda install --quiet --yes -c defaults ipykernel && \ + python -m ipykernel install --user --display-name "fullpursuit" && \ + pip install -e . + +WORKDIR / \ No newline at end of file diff --git a/full-binary-pursuit/README.md b/full-binary-pursuit/README.md new file mode 100644 index 0000000..c281d10 --- /dev/null +++ b/full-binary-pursuit/README.md @@ -0,0 +1,58 @@ +### Run container +docker run --rm -it -v : --gpus all fullpursuit:latest +flags: +--rm: removes container once it's stopped +-it: for interactive session (-d for detached) +-v: mounted volumes (directories) +--gpus: enables GPU use within container + +### Build this image +Build default image: +docker build -t fullpursuit-base:latest . + +Note: Full binary pursuit relies on opencl. Installation varies by OS and CPU / GPU type. +For Intel CPUs, see https://www.intel.com/content/www/us/en/developer/articles/tool/opencl-drivers.html. +For configuration on Ubuntu and Docker, see also https://linuxhandbook.com/setup-opencl-linux-docker/. On Ubuntu, you may need to add your user to the `video` and `render` groups to access the GPU. +``` +sudo gpasswd -a $USER render +sudo gpasswd -a $USER video +``` +Then log out and back in to apply the changes: `su - $USER` + +Check fullpursuit version: +docker run --rm -it spikeinterface/fullpursuit-base:latest bash -c "python -c 'import spikesorting_fullpursuit; print(spikesorting_fullpursuit.__version__)'" + +Check that pyopencl can detect your graphics card: +docker run --rm -it --gpus all spikeinterface/fullpursuit-base:latest bash -c "python -c 'import pyopencl as cl; platforms = cl.get_platforms(); print(platforms[0].get_devices(cl.device_type.GPU))'" + +### Test +Adapted from the readme file's instructions. + +First make the voltage data and save ground truth (mounting the host data folder to the docker data folder): +```bash +docker run --rm -it -v : --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/make_and_save_voltage.py /test_voltage.npy /test_ground_truth.pickle" +``` +e.g.: +Create the data folder: `mkdir -p /home/$USER/data/fullpursuit_data` +Then create the groundtruth data: `docker run --rm -it -v /home/$USER/data/fullpursuit_data:/data --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/make_and_save_voltage.py /data/test_voltage.npy /data/test_ground_truth.pickle"` + +Then run the sorting algorithm on the generated synthetic data: +```bash +docker run --rm -it -v : --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/test_demo_run_sort.py /test_voltage.npy /sorted_demo.pickle" +``` +e.g.: +`docker run --rm -it -v /home/$USER/data/fullpursuit_data:/data --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/test_demo_run_sort.py /data/test_voltage.npy /data/sorted_demo.pickle"` + +Run automated postprocessing to place sorter output into a dictionary sorted neurons: +```bash +docker run --rm -it -v : --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/test_demo_postprocessing.py /sorted_demo.pickle /sorted_neurons.pickle" +``` +e.g.: +`docker run --rm -it -v /home/$USER/data/fullpursuit_data:/data --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/test_demo_postprocessing.py /data/sorted_demo.pickle /data/sorted_neurons.pickle"` + +Finally run a quick script that compares sorted results to the ground truth generated data and make a couple figures: +```bash +docker run --rm -it -v : --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/test_demo_results.py /sorted_neurons.pickle /test_ground_truth.pickle" +``` +e.g.: +`docker run --rm -it -v /home/$USER/data/fullpursuit_data:/data --gpus all spikeinterface/fullpursuit-base:latest bash -c "python /src/fullpursuit/demos/test_demo_results.py /data/sorted_neurons.pickle /data/test_ground_truth.pickle"` diff --git a/full-binary-pursuit/build.sh b/full-binary-pursuit/build.sh new file mode 100755 index 0000000..a663eb0 --- /dev/null +++ b/full-binary-pursuit/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +docker build -t spikeinterface/fullpursuit-base:latest -t spikeinterface/fullpursuit-base:1.1.0_cuda-11.7.1 . + +# version info +# 01/31/2024 - FBP 1.1.0 CUDA 11.7.1 Ubuntu 22.04 diff --git a/full-binary-pursuit/push.sh b/full-binary-pursuit/push.sh new file mode 100755 index 0000000..e49650b --- /dev/null +++ b/full-binary-pursuit/push.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker push --all-tags spikeinterface/fullpursuit-base \ No newline at end of file