【python】kilosort4安装步骤


前言

kilosort是神经科学领域一个好用的spike sorting工具。本篇文章是根据kilosort4官方文档的安装过程,存档方便下次重装环境,供大家参考。


安装步骤

System requirements

Linux and Windows 64-bit are supported for running the code. At least 8GB of GPU RAM is required to run the software (see docs for more recommendations). The software has been tested on Windows 10 and Ubuntu 20.04.
可以在任务管理器>性能看显卡内存

Instructions

If you have an older environment you can remove it with before creating a new one.kilosort conda env remove -n kilosort

  1. Install an Anaconda distribution of Python. Note you might need to use an anaconda prompt if you did not add anaconda to the path.(如果下载很慢,anaconda可以换一下清华源,方法可以见另一篇:spikeinterface安装

  2. Open an anaconda prompt / command prompt which has for python 3 in the pathconda

  3. Create a new environment with python 3.9. Python 3.10 should work as well.
    conda create --name kilosort python=3.9

  4. To activate this new environment, run
    conda activate kilosort

  5. To install kilosort and the GUI, run . If you’re on a zsh server, you may need to use ‘ ‘ around the kilosort[gui] call: `python -m pip install ‘kilosort[gui]’.
    python -m pip install kilosort[gui]

  6. Instead of 5, you can install the minimal version of kilosort with .
    python -m pip install kilosort

  7. Next, if the CPU version of pytorch was installed (will happen on Windows), remove it with
    pip uninstall torch

  8. (跳到下一节debug,这一步装不了)Then install the GPU version of pytorch
    conda install pytorch pytorch-cuda=11.8 -c pytorch -c nvidia

  9. (直接装了就好)Note you will always have to run before you run kilosort. If you want to run jupyter notebooks in this environment, then also or , and .

conda activate kilosort 
conda install jupyter 
pip install notebook 
python -m pip install matplotlib

Debugging pytorch installation

理解原理后看下面的步骤
If step 8 does not work, you need to make sure the NVIDIA driver for your GPU is installed (available here). You may also need to install the CUDA libraries for it, we recommend CUDA 11.8.

If pytorch installation still fails, follow the instructions here to determine what version of pytorch to install. The Anaconda install is strongly recommended on Windows, and then choose the CUDA version that is supported by your GPU (newer GPUs may need newer CUDA versions > 10.2). For instance this command will install the 11.8 version on Linux and Windows (note the and commands are removed because kilosort doesn’t require them):torchvisiontorchaudio

conda install pytorch pytorch-cuda=11.8 -c pytorch -c nvidia

This video has step-by-step installation instructions for NVIDIA drivers and pytorch in Windows (ignore the environment creation step with the .yml file, we have an environment already, to activate it use conda activate kilosort).

anaconda环境中安装cuda11.8步骤

pytorch,cuda等版本需要一一对应才能正常运行

  1. 装gpu driver,在此nvidia官网上根据gpu型号选择
  2. 在anaconda环境中装CUDA cudatoolkit和cudnn,参考博客。一定要装在环境里,直接装在电脑里,其他包可能版本不对应就用不了了
conda activate kilosort
conda search cudatoolkit --info
conda install cudatoolkit==11.8
conda search cudnn --info
conda install cudnn==8.9.2.26
  1. 安装pytorch,只能用下面语句,不能用pytorch官网语句,因为上文说到没保留torch vision 和torch audio
conda install pytorch pytorch-cuda=11.8 -c pytorch -c nvidia
  1. 测试pytorch及cuda版本,输出应为11.8和8700
python
import torch
print(torch.version.cuda)
print(torch.backends.cudnn.version())

Running kilosort

Open the GUI with

conda activate kilosort
python -m kilosort

Select the path to the binary file and optionally the results directory. We recommend putting the binary file on an SSD for faster processing.

Select the probe configuration (mat files recommended, they actually exclude off channels unlike prb files)

Hit LOAD. The data should now be visible.

Hit Run. This will run the pipeline and output the results in a format compatible with Phy, the most popular spike sorting curating software.

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值