From cd857bcb9d8c00c2b51542864c46d59fd22d09ff Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 1 Mar 2024 17:19:50 +0000 Subject: [PATCH 1/3] Kilosort4 image --- kilosort4/Dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ kilosort4/README.md | 39 +++++++++++++++++++++++++++++++++++++++ kilosort4/build.sh | 3 +++ kilosort4/push.sh | 3 +++ 4 files changed, 86 insertions(+) create mode 100644 kilosort4/Dockerfile create mode 100644 kilosort4/README.md create mode 100755 kilosort4/build.sh create mode 100644 kilosort4/push.sh diff --git a/kilosort4/Dockerfile b/kilosort4/Dockerfile new file mode 100644 index 0000000..385957b --- /dev/null +++ b/kilosort4/Dockerfile @@ -0,0 +1,41 @@ +FROM nvidia/cuda:12.0.0-base-ubuntu20.04 + +LABEL maintainer="Alessio Buccino " + +# USER root +# Ubuntu package installs +RUN apt update && \ + apt install -y --no-install-recommends \ + libfftw3-dev \ + git \ + wget && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# install miniconda +ENV MINICONDA_VERSION 24.1.2-0 +ENV PY_VERSION py311 +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 +RUN conda update conda && \ + conda install conda-build + +# 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 torch +# RUN conda install -y pytorch pytorch-cuda=11.8 -c pytorch -c nvidia +RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 + +# install kilosort4 +RUN git clone https://github.com/MouseLand/Kilosort.git && \ + cd Kilosort && \ + pip install . && \ + cd .. diff --git a/kilosort4/README.md b/kilosort4/README.md new file mode 100644 index 0000000..83d3405 --- /dev/null +++ b/kilosort4/README.md @@ -0,0 +1,39 @@ +### Build this image +Build default image: +docker build -t pykilosort:latest -f dockerfiles/Dockerfile . + +Build image with additional testing components: +docker build -t pykilosort:test -f dockerfiles/Dockerfile.testing context + +### Run container +docker run --rm -it -v : --gpus all pykilosort:latest +flags: +--rm: removes container once it's stopped +-it: for interactive session +-v: mounted volumes (directories) +--gpus: enables GPU use within container + +### Test +Download Neuropixel 1.0 data to your data directory: https://catalystneuro.github.io/spike-sorting-hackathon/datasets/datasets.html#allen-institute-example +(see also https://github.com/int-brain-lab/pykilosort/tree/ibl_prod/examples, although apparently not up to date) + +$docker run --rm -it -v /my/dir/to/data:/data --gpus all pykilosort +#conda activate pyks2 +#cd /data + --- alternatively, get data from kachery (if installed and configured) --- + ``` + wget https://catalystneuro.github.io/spike-sorting-hackathon/datasets/examples/example_allen_NP1.py + python example_allen_NP1.py + ``` + +The either run tests in ipython console, or run example from /home/test_file directory (if using `.testing` image), after editing directory paths +#ipython +``` +from pathlib import Path +from pykilosort import run, add_default_handler, np1_probe, np2_probe + +data_path = Path('/data/Allen_Institute_NP1/continuous_1min.bin') +dir_path = Path('/data/Allen_Institute_NP1/output') +add_default_handler(level='INFO') # print output as the algorithm runs +run(data_path, dir_path=dir_path, probe=np1_probe(sync_channel=False)) +``` diff --git a/kilosort4/build.sh b/kilosort4/build.sh new file mode 100755 index 0000000..dfda5b6 --- /dev/null +++ b/kilosort4/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -t spikeinterface/kilosort4-base:latest -t spikeinterface/kilosort4-base:0.1.0 . diff --git a/kilosort4/push.sh b/kilosort4/push.sh new file mode 100644 index 0000000..a0681a4 --- /dev/null +++ b/kilosort4/push.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker push --all-tags spikeinterface/kilosort4-base From 4152f3e933389b07318c4c3e03922fd81d1f8cbc Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Mon, 4 Mar 2024 17:57:51 +0000 Subject: [PATCH 2/3] Install KS4 from pip --- kilosort4/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kilosort4/Dockerfile b/kilosort4/Dockerfile index 385957b..001da23 100644 --- a/kilosort4/Dockerfile +++ b/kilosort4/Dockerfile @@ -35,7 +35,4 @@ RUN conda init bash RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 # install kilosort4 -RUN git clone https://github.com/MouseLand/Kilosort.git && \ - cd Kilosort && \ - pip install . && \ - cd .. +RUN pip install kilosort==4.0 From 514308a257e38f9b4363dc5f03a9a7a0ec1875b2 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Mon, 4 Mar 2024 18:17:19 +0000 Subject: [PATCH 3/3] Remove README and add cuda version to tag --- kilosort4/README.md | 39 --------------------------------------- kilosort4/build.sh | 2 +- 2 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 kilosort4/README.md diff --git a/kilosort4/README.md b/kilosort4/README.md deleted file mode 100644 index 83d3405..0000000 --- a/kilosort4/README.md +++ /dev/null @@ -1,39 +0,0 @@ -### Build this image -Build default image: -docker build -t pykilosort:latest -f dockerfiles/Dockerfile . - -Build image with additional testing components: -docker build -t pykilosort:test -f dockerfiles/Dockerfile.testing context - -### Run container -docker run --rm -it -v : --gpus all pykilosort:latest -flags: ---rm: removes container once it's stopped --it: for interactive session --v: mounted volumes (directories) ---gpus: enables GPU use within container - -### Test -Download Neuropixel 1.0 data to your data directory: https://catalystneuro.github.io/spike-sorting-hackathon/datasets/datasets.html#allen-institute-example -(see also https://github.com/int-brain-lab/pykilosort/tree/ibl_prod/examples, although apparently not up to date) - -$docker run --rm -it -v /my/dir/to/data:/data --gpus all pykilosort -#conda activate pyks2 -#cd /data - --- alternatively, get data from kachery (if installed and configured) --- - ``` - wget https://catalystneuro.github.io/spike-sorting-hackathon/datasets/examples/example_allen_NP1.py - python example_allen_NP1.py - ``` - -The either run tests in ipython console, or run example from /home/test_file directory (if using `.testing` image), after editing directory paths -#ipython -``` -from pathlib import Path -from pykilosort import run, add_default_handler, np1_probe, np2_probe - -data_path = Path('/data/Allen_Institute_NP1/continuous_1min.bin') -dir_path = Path('/data/Allen_Institute_NP1/output') -add_default_handler(level='INFO') # print output as the algorithm runs -run(data_path, dir_path=dir_path, probe=np1_probe(sync_channel=False)) -``` diff --git a/kilosort4/build.sh b/kilosort4/build.sh index dfda5b6..1c735c3 100755 --- a/kilosort4/build.sh +++ b/kilosort4/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker build -t spikeinterface/kilosort4-base:latest -t spikeinterface/kilosort4-base:0.1.0 . +docker build -t spikeinterface/kilosort4-base:latest -t spikeinterface/kilosort4-base:4.0_cuda-12.0.0 .