From 8ecf4dc3514ef1667575c1e310670b52844e0246 Mon Sep 17 00:00:00 2001 From: Nina Miolane Date: Fri, 5 Apr 2024 23:28:58 -0700 Subject: [PATCH] Put gpu-specific installs in pyproject.toml --- README.md | 16 +++++++++---- environment.yml | 57 -------------------------------------------- pyproject.toml | 1 + setup_environment.py | 55 ------------------------------------------ 4 files changed, 13 insertions(+), 116 deletions(-) delete mode 100644 environment.yml delete mode 100644 setup_environment.py diff --git a/README.md b/README.md index 07ef0c6..de7187e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Screen Shot 2024-04-05 at 8 50 36 PM -**Neurometry** is a computational framework to quantify geometric intelligence in natural and artificial brains. Neurometry provides functionalities to analyze the geometric structures underlying computation in neural systems - neural representations and neural manifolds. +**Neurometry** is a computational framework to quantify geometric intelligence in natural and artificial brains. Neurometry provides functionalities to analyze the geometric structures underlying computation in neural systems - neural representations and neural manifolds. This repository contains the official PyTorch implementation of the papers: - **Quantifying Extrinsic Curvature in Neural Manifolds**. CVPR Workshop on Topology, Algebra and Geometry 2023. @@ -9,13 +9,13 @@ This repository contains the official PyTorch implementation of the papers: [Francisco Acosta](https://web.physics.ucsb.edu/~facosta/), [Colin Conwell](https://colinconwell.github.io/), [Sophia Sanborn](https://www.sophiasanborn.com/), [David Klindt](https://david-klindt.github.io/) and [Nina Miolane](https://www.ninamiolane.com/). -The neural manifold hypothesis postulates that the activity of a neural population forms a low-dimensional manifold within the larger neural state space, whose structure reflects the structure of the encoded task variables. Many dimensionality reduction techniques have been used to study the structure of neural manifolds, but these methods do not provide an explicit parameterization of the manifold, and may not capture the global structure of topologically nontrivial manifolds. Topological data analysis methods can reveal the shared topological structure between neural manifolds and the task variables they represent, but may not to capture much of the geometric information including distance, angles, and curvature. +The neural manifold hypothesis postulates that the activity of a neural population forms a low-dimensional manifold within the larger neural state space, whose structure reflects the structure of the encoded task variables. Many dimensionality reduction techniques have been used to study the structure of neural manifolds, but these methods do not provide an explicit parameterization of the manifold, and may not capture the global structure of topologically nontrivial manifolds. Topological data analysis methods can reveal the shared topological structure between neural manifolds and the task variables they represent, but may not to capture much of the geometric information including distance, angles, and curvature. ![Overview of method to extract geometric features from neural activation manifolds. ](/method_overview.png) We introduce a novel approach (see figure above) for studying the geometry of neural manifolds. This approach: - computes an explicit parameterization of the manifolds, and -- estimates their local extrinsic curvature. +- estimates their local extrinsic curvature. We hope to open new avenues of inquiry exploring geometric neural correlates of perception and behavior, and provide a new means to compare representations in biological and artificial neural systems. @@ -26,8 +26,16 @@ We hope to open new avenues of inquiry exploring geometric neural correlates of We recommend using Anaconda for easy installation and use of the method. To create the necessary conda environment, run: ``` -conda env create -f environment.yml +conda create -n neurometry python=3.11.3 -y conda activate neurometry +pip install -e '.[all]' +``` + +If cuda is available, run instead: +``` +conda create -n neurometry python=3.11.3 -y +conda activate neurometry +pip install -e '.[all,gpu]' ``` ## 🌎 Bibtex ## diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 0d1e50a..0000000 --- a/environment.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: neurometry -channels: - - conda-forge -dependencies: - - python=3.9 - - pip - - pandas - - matplotlib - - numpy - - scikit-learn - - jupyter - - jupyterlab - - pip: - - black - - giotto-ph - - git+https://github.com/geomstats/geomstats.git - - hyperopt==0.2.5 - - isort - - mat73 - - pre-commit - - pytest - - ray[tune] - - torch - - wandb - - seaborn - - plotly - - gdown - - fastparquet - - mtalg - - torchmetrics - - torchinfo - - git+https://github.com/johnmarktaylor91/torchlens - - kneed - - jupyter-black - - adjustText - - git+https://github.com/ahwillia/netrep.git - - cython - - nibabel - - pycortex - - scikit-image - - # pyLDDMM dependencies: - # - cycler==0.10.0 - # - decorator==4.4.1 - # - imageio==2.6.1 - # - kiwisolver==1.1.0 - # - matplotlib==3.1.2 - # - networkx==2.4 - # - Pillow==6.2.1 - # - pyparsing==2.4.6 - # - python-dateutil==2.8.1 - # - PyWavelets==1.1.1 - # - scikit-image==0.16.2 - # - scipy==1.4.1 - # - six==1.13.0 - # - numpy==1.24.3 - diff --git a/pyproject.toml b/pyproject.toml index 6b15c74..0c5ae4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,7 @@ test = [ "pandas-stubs", "types-requests" ] +gpu = ["cupy-cuda11x"] dev = ["neurometry[test, lint]"] all = ["neurometry[doc, dev]",] diff --git a/setup_environment.py b/setup_environment.py deleted file mode 100644 index cef0054..0000000 --- a/setup_environment.py +++ /dev/null @@ -1,55 +0,0 @@ -import subprocess -import sys - - -def is_cuda_available(): - """Check if CUDA is available on the system.""" - try: - subprocess.run( - ["nvidia-smi"], check=True, capture_output=True - ) - return True - except Exception: - return False - - -def create_conda_environment(env_file_path): - """Create a Conda environment from a yml file.""" - try: - subprocess.run(["conda", "env", "create", "-f", env_file_path], check=True) - print("Conda environment created successfully.") - except subprocess.CalledProcessError as e: - print("Failed to create Conda environment:", e) - sys.exit(1) - - -def install_cuda_packages(env_name): - """Install CUDA-dependent packages in the specified Conda environment.""" - cuda_packages = ["cupy-cuda11x"] - - for package in cuda_packages: - cmd = f"conda run -n {env_name} pip install {package}" - try: - subprocess.run(cmd, check=True, shell=True) - print(f"Installed {package} in {env_name} environment.") - except subprocess.CalledProcessError as e: - print(f"Failed to install {package} in {env_name}: {e}") - sys.exit(1) - - -def main(): - env_file_path = "environment.yml" - - # Create Conda environment - create_conda_environment(env_file_path) - - # Check for CUDA availability and install packages if necessary - if is_cuda_available(): - print("CUDA is available. Installing CUDA-dependent packages.") - install_cuda_packages("neurometry") - else: - print("CUDA not available. Skipping CUDA-dependent packages.") - - -if __name__ == "__main__": - main()