Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INSTALLATION: While installing Kilosort in developer mode in Windows, CPU version is installed #853

Open
NirvikNU opened this issue Jan 16, 2025 · 14 comments

Comments

@NirvikNU
Copy link

Describe the issue:

When I tried to install Kilosort using the developer mode instructions provided at the end of the README file, I found that the cpu version of torch is installed:

python -c "import torch; print(torch.cuda.is_available())" gives False as output.

So I followed the instructions for uninstalling torch and then installing cuda version of pytorch. However, after doing that, kilosort doesn't run due to missing torch package:

ImportError: cannot import name 'fft' from 'torch.fft' (unknown location)

What am I doing wrong?

Provide environment info:

active environment : kilosort_latest active env location : C:\Users\Nirvik_Sinha\.conda\envs\kilosort_latest shell level : 2 user config file : C:\Users\Nirvik_Sinha\.condarc populated config files : C:\Users\Nirvik_Sinha\.condarc conda version : 24.4.0 conda-build version : not installed python version : 3.12.3.final.0 solver : libmamba (default) virtual packages : __archspec=1=cascadelake __conda=24.4.0=0 __cuda=12.3=0 __win=0=0 base environment : C:\ProgramData\miniconda3 (read only) conda av data dir : C:\ProgramData\miniconda3\etc\conda conda av metadata url : None channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\ProgramData\miniconda3\pkgs C:\Users\Nirvik_Sinha\.conda\pkgs C:\Users\Nirvik_Sinha\AppData\Local\conda\conda\pkgs envs directories : C:\Users\Nirvik_Sinha\.conda\envs C:\ProgramData\miniconda3\envs C:\Users\Nirvik_Sinha\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/24.4.0 requests/2.31.0 CPython/3.12.3 Windows/2019Server Windows/10.0.17763 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8 aau/0.4.4 c/. s/. e/. administrator : False netrc file : None offline mode : False

Operating system information:

Windows 10

@jacobpennington
Copy link
Collaborator

Can you please try conda list torch with the environment activated and paste the output here?

@NirvikNU
Copy link
Author

NirvikNU commented Jan 17, 2025

`(kilosort_latest) E:\PROJECTS\Nirvik_Sinha_Data\KILOSORT>conda list torch
packages in environment at C:\Users\Nirvik_Sinha.conda\envs\kilosort_latest:

Name Version Build Channel
libtorch 2.5.1 cpu_mkl_hbbd3bdd_109 conda-forge
pytorch 2.5.1 cpu_mkl_py39_h5b11d1b_109 conda-forge
pytorch-cuda 11.8 h24eeafa_6 pytorch`

@jacobpennington
Copy link
Collaborator

I'm not sure what's causing the problem. My best guess is that you might have an older environment with the same name that's causing conflicts. So, for example if your existing kilosort environment is named kilosort you could try:

git clone [email protected]:MouseLand/Kilosort.git
conda env create -f environment.yml -n new_kilosort
conda activate kilosort
pip install -e Kilosort[gui]

to create a new_kilosort environment (or whatever name you want to use). Also make sure you're downloading the file named environment.yml, not environment_cpu.yml.

@NirvikNU
Copy link
Author

I do have another environment called kilosort however to avoid conflict with that one I specifically edited the environment.yml file to create a new environment called 'kilosort_latest'. After creating the environment using the edited yaml file I activate that environment and then install kilosort in editable mode from the gitcloned repo as instructed. However, when I start the kilosort gui, only cpu is listed but not the two gpus i have in my system.

@jacobpennington
Copy link
Collaborator

Were the same GPUs detected previously in your other environment?

@ryan-budde
Copy link

@NirvikNU are you using mamba? see mamba-org/mamba#1617

@NirvikNU
Copy link
Author

Yes the previous environment detected the gpus as expected, it was a regular kilosort installation not the developer mode.

@ryan-budde
Copy link

have you separately installed pytorch as recommended by https://pytorch.org/?

@NirvikNU
Copy link
Author

NirvikNU commented Jan 17, 2025

Okay so I did this and now it seems to detect the gpus correctly:

pip uninstall torch

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

I wonder with this manual change will git pull work without breaking the environment?

@jacobpennington
Copy link
Collaborator

git pull does not interact with the environment. That would only matter if the code changed in a way that requires a newer version of some package, in which case you would have to update package versions for any environment regardless of how it was created.

@ryan-budde
Copy link

I have just done a fresh install and tests and would recommend the following as the new developer instructions:
install CUDA on computer, 11.8 is original, tested with 12.6 with no issues

git clone https://github.com/MouseLand/Kilosort.git
cd Kilosort
conda env create -f environment.yml
conda activate kilosort
cd ..
pip install -e Kilosort[gui]
pip uninstall torch
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
cd Kilosort
pytest --gpu --runslow

I passed all 25 tests in 128s

@jacobpennington
Copy link
Collaborator

jacobpennington commented Jan 17, 2025

Uninstalling and reinstalling torch should not be necessary when creating the environment from the .yml file, since it already installs the cuda version of pytorch. Creating a fresh environment with the existing developer instructions has worked fine for me on several machines, on both Windows and Linux. If it's not installing the cuda version for you, there's some other issue I'll need to figure out.

@NirvikNU
Copy link
Author

I have just done a fresh install and tests and would recommend the following as the new developer instructions: install CUDA on computer, 11.8 is original, tested with 12.6 with no issues

git clone https://github.com/MouseLand/Kilosort.git
cd Kilosort
conda env create -f environment.yml
conda activate kilosort
cd ..
pip install -e Kilosort[gui]
pip uninstall torch
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
cd Kilosort
pytest --gpu --runslow

I passed all 25 tests in 128s

Okay so this works. Now if I need to update the existing kilosort installation, all I need to do is git pull inside the cloned repo? Or is there any further steps involved?

@jacobpennington
Copy link
Collaborator

jacobpennington commented Jan 17, 2025

git pull is all you would need to do. The only exception is if there is a change to the required dependencies or their version limitations, but that is rare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants