Skip to content

Commit 49284ba

Browse files
authored
Merge pull request #78 from daniel-unyi-42/install_update
Installation updates and fixes
2 parents 05bc6a8 + 530b9e0 commit 49284ba

File tree

10 files changed

+221
-308
lines changed

10 files changed

+221
-308
lines changed

Dockerfile

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1+
# Base image with CUDA 12.1 runtime and cuDNN
12
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
23

4+
# Install essential system tools and Python
35
RUN apt-get update -y && apt-get install -y --no-install-recommends \
46
git \
57
wget \
6-
tmux \
7-
vim \
8-
htop \
9-
zip \
8+
curl \
109
unzip \
10+
htop \
11+
vim \
1112
build-essential \
1213
python3 \
13-
python3-pip && \
14-
apt-get clean && \
14+
python3-pip \
15+
python3-venv \
16+
&& apt-get clean && \
1517
rm -rf /var/lib/apt/lists/*
1618

17-
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
18-
pip install --no-cache-dir debugpy
19+
# Create a symbolic link to enable `python` instead of `python3`
20+
RUN ln -s /usr/bin/python3 /usr/bin/python
1921

22+
# Install global python tools
23+
RUN python -m pip install --no-cache-dir --upgrade pip && \
24+
pip install --no-cache-dir debugpy jupyterlab
25+
26+
# Set working directory
2027
WORKDIR /workspace
2128

29+
# Clone the repository and install segger with CUDA 12 support
2230
RUN git clone https://github.com/EliHei2/segger_dev.git /workspace/segger_dev && \
23-
pip install -e "/workspace/segger_dev[cuda12,rapids12,cupy12,faiss]"
24-
25-
EXPOSE 5678
31+
pip install -e "/workspace/segger_dev[cuda12]"
2632

33+
# Set environment variables
2734
ENV PYTHONPATH=/workspace/segger_dev/src:$PYTHONPATH
35+
36+
# expose ports for debugpy and jupyterlab
37+
EXPOSE 5678 8888

README.md

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/EliHei2/segger_dev/main.svg)](https://results.pre-commit.ci/latest/github/EliHei2/segger_dev/main)
44

5-
**Important note (Dec 2024)**: As segger is currently undergoing constant development we highly recommending installing segger directly via github.
5+
**Important note (Dec 2024)**: As segger is currently undergoing constant development, we highly recommend installing it directly via GitHub.
66

77
**segger** is a cutting-edge tool for **cell segmentation** in **single-molecule spatial omics** datasets. By leveraging **graph neural networks (GNNs)** and heterogeneous graphs, segger offers unmatched accuracy and scalability.
88

@@ -51,75 +51,33 @@ segger tackles these with a **graph-based approach**, achieving superior segment
5151

5252
## Installation
5353

54-
**Important note (Dec 2024)**: As segger is currently undergoing constant development we highly recommending installing segger directly via github.
55-
56-
### Important: PyTorch Geometric Dependencies
57-
58-
Segger **relies heavily** on PyTorch Geometric for its graph-based operations. One **must** install its dependencies (such as `torch-sparse` and `torch-scatter`) based on their system’s specifications, especially the **CUDA** and **PyTorch** versions.
59-
60-
Please follow the official [PyTorch Geometric Installation Guide](https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html) to install the correct versions of `torch-sparse`, `torch-scatter`, and other relevant libraries.
61-
62-
Below is a quick guide for installing PyTorch Geometric dependencies for **torch 2.4.0**:
63-
64-
#### For CUDA 11.x:
65-
66-
```bash
67-
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.4.0+cu121.html
68-
```
69-
70-
#### For CUDA 12.x:
71-
72-
```bash
73-
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.4.0+cu118.html
74-
```
75-
76-
Afterwards choose the installation method that best suits your needs.
54+
**Important note (Dec 2024)**: As segger is currently undergoing constant development, we highly recommend installing it directly via GitHub.
7755

7856
### GitHub Installation
7957

8058
For a straightforward local installation from GitHub, clone the repository and install the package using `pip`:
8159

82-
#### Clone the repo
83-
8460
```bash
8561
git clone https://github.com/EliHei2/segger_dev.git
86-
git cd segger_dev
62+
cd segger_dev
63+
pip install -e ".[cuda12]"
8764
```
8865

89-
90-
#### Pip Installation (RAPIDS and CUDA 11)
91-
92-
For installations requiring RAPIDS and CUDA 11 support, run:
93-
94-
```bash
95-
pip install -e ".[rapids11]"
96-
```
97-
98-
#### Pip Installation (RAPIDS and CUDA 12)
99-
100-
For installations requiring RAPIDS and CUDA 12 support, run:
101-
102-
```bash
103-
pip install -e ".[rapids12]"
104-
```
66+
segger requires **CUDA 11** or **CUDA 12** for GPU acceleration.
67+
You can find more detailed information in our **[Installation Guide](https://elihei2.github.io/segger_dev/installation/)**.
68+
To avoid dependency conflicts, we recommend installing segger in a virtual environment or using a containerized environment.
10569

10670
### Docker Installation
10771

108-
Segger provides an easy-to-use Docker container for those who prefer a containerized environment. To pull the latest Docker image:
72+
We provide an easy-to-use Docker container for those who prefer a containerized environment. To pull and run the Docker image:
10973

11074
```bash
111-
docker pull danielunyi42/segger_dev:latest
75+
docker pull danielunyi42/segger_dev:cuda121
76+
docker run --gpus all -it danielunyi42/segger_dev:cuda121
11277
```
11378

114-
The Docker image comes with all dependencies packaged, including RAPIDS. It currently supports only CUDA 12.2, and we will soon release a version that supports CUDA 11.8.
115-
116-
### Singularity Installation
117-
118-
For users who prefer Singularity, you can pull the Docker image as follows:
119-
120-
```bash
121-
singularity pull docker://danielunyi42/segger_dev:latest
122-
```
79+
The official Docker image comes with all dependencies pre-installed, including the CUDA toolkit, PyTorch, and CuPy.
80+
The current images support **CUDA 11.8** and **CUDA 12.1**, which can be specified in the image tag.
12381

12482
---
12583

docs/installation.md

Lines changed: 101 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,141 @@
1-
## Segger Installation Guide
1+
## segger Installation Guide
22

3-
Select the appropriate installation method based on your requirements.
3+
segger provides multiple installation options to suit your requirements. You can install it using:
4+
5+
- **Virtual environments** (recommended for most users)
6+
- **Containerized environments** (Docker or Singularity)
7+
- **Editable mode from GitHub** (for developers or users who want to modify the source code)
8+
9+
!!! tip "Recommendation"
10+
To avoid dependency conflicts, we recommend installing segger in a virtual environment or a container environment.
11+
12+
segger requires **CUDA 11** or **CUDA 12** for GPU acceleration.
13+
14+
### :snake: Installation in Virtual Environment
15+
16+
#### Using `venv`
417

5-
=== ":rocket: Micromamba Installation"
618
```bash
7-
micromamba create -n segger-rapids --channel-priority 1 \
8-
-c rapidsai -c conda-forge -c nvidia -c pytorch -c pyg \
9-
rapids=24.10 python=3.* 'cuda-version>=12.0,<=12.1' jupyterlab \
10-
'pytorch=*=*cuda*' 'pyg=*=*cu121' pyg-lib pytorch-sparse
11-
micromamba install -n segger-rapids --channel-priority 1 --file mamba_environment.yml
12-
micromamba run -n segger-rapids pip install --no-deps ./
19+
# Step 1: Create and activate the virtual environment.
20+
python3.10 -m venv segger-venv
21+
source segger-venv/bin/activate
22+
23+
# Step 2: Install segger with CUDA support.
24+
pip install --upgrade pip
25+
pip install .[cuda12]
26+
27+
# Step 3: Verify the installation.
28+
python --version
29+
pip show segger
30+
31+
# step 4 [Optional]: If your system doesn't have a universally installed CUDA toolkit, you can link CuPy to PyTorch's CUDA runtime library.
32+
export LD_LIBRARY_PATH=$(pwd)/segger-venv/lib/python3.10/site-packages/nvidia/cuda_nvrtc/lib:$LD_LIBRARY_PATH
1333
```
1434

15-
=== ":snake: Conda Installation"
35+
#### Using `conda`
36+
1637
```bash
38+
# Step 1: Create and activate the conda environment.
1739
conda create -n segger-env python=3.10
1840
conda activate segger-env
19-
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
20-
conda install pyg -c pyg
21-
pip install .
41+
42+
# Step 2: Install segger with CUDA support.
43+
pip install --upgrade pip
44+
pip install .[cuda12]
45+
46+
# Step 3: Verify the installation.
47+
python --version
48+
pip show segger
49+
50+
# Step 4 [Optional]: If your system doesn't have a universally installed CUDA toolkit, you can link CuPy to PyTorch's CUDA runtime library.
51+
export LD_LIBRARY_PATH=$(conda info --base)/envs/segger-env/lib/python3.10/site-packages/nvidia/cuda_nvrtc/lib:$LD_LIBRARY_PATH
2252
```
2353

24-
=== ":whale: Docker Installation"
54+
#### How to Choose Between `[cuda11]` and `[cuda12]`
55+
1. **Check Your NVIDIA Driver Version**: Run `nvidia-smi`. Use `[cuda11]` for driver version ≥ 450.80.02 or `[cuda12]` for version ≥ 525.60.13.
56+
2. **Check for a CUDA Toolkit**: Run `nvcc --version`. If it outputs a CUDA version (11.x or 12.x), choose the corresponding `[cuda11]` or `[cuda12]`.
57+
3. **Default to PyTorch CUDA Runtime**: If CUDA toolkit is not installed, segger can use PyTorch's bundled CUDA runtime. You can link CuPy as shown in Step 4 of the venv/conda installation.
58+
59+
60+
### :whale: Installation in Container Environment
61+
62+
#### Using `docker`
63+
2564
```bash
65+
# Step 1: Pull the official Docker image.
2666
docker pull danielunyi42/segger_dev:cuda121
67+
68+
# Step 2: Run the Docker container with GPU support.
69+
docker run --gpus all -it danielunyi42/segger_dev:cuda121
2770
```
2871

29-
The Docker image comes with all required packages pre-installed, including PyTorch, RAPIDS, and PyTorch Geometric.
30-
The current images support CUDA 11.8 and CUDA 12.1, which can be specified in the image tag.
72+
The official Docker image comes with all dependencies pre-installed, including the CUDA toolkit, PyTorch, and CuPy.
73+
The current images support **CUDA 11.8** and **CUDA 12.1**, which can be specified in the image tag.
3174

32-
For users who prefer Singularity:
75+
#### Using `singularity`
3376

3477
```bash
78+
# Step 1: Pull the official Docker image.
3579
singularity pull docker://danielunyi42/segger_dev:cuda121
80+
81+
# Step 2: Run the Singularity container with GPU support.
82+
singularity exec --nv segger_dev_cuda121.sif
3683
```
3784

38-
=== ":octocat: Github Installation"
85+
The Singularity image is derived from the official Docker image and includes all pre-installed dependencies.
86+
87+
#### :file_folder: Directory Mapping for Input and Output Data
88+
89+
Directory mapping allows:
90+
91+
- **Access to input data** (spatial transcriptomics datasets) from your local machine inside the container.
92+
- **Saving output data** (segmentation results and logs) generated by segger to your local machine.
93+
94+
Setting up directory mapping is really easy:
95+
96+
- **For Docker**:
3997
```bash
40-
git clone https://github.com/EliHei2/segger_dev.git
41-
cd segger_dev
42-
pip install -e "."
98+
docker run --gpus all -it -v /path/to/local/data:/workspace/data danielunyi42/segger_dev:cuda121
4399
```
44100

45-
=== ":rocket: Pip Installation of RAPIDS with CUDA 11"
101+
- **For Singularity**:
46102
```bash
47-
pip install "segger[rapids11]"
103+
singularity exec --nv -B /path/to/local/data:/workspace/data segger_dev_cuda121.sif
48104
```
105+
- Place your input datasets in `/path/to/local/data` on your host machine.
106+
- Inside the container, access these datasets from `/workspace/data`.
107+
- Save results to `/workspace/data`, which will be available in `/path/to/local/data` on the host machine.
108+
109+
### :smirk_cat: Editable GitHub installation
110+
111+
For developers or users who want to modify the source code:
49112

50-
=== ":rocket: Pip Installation of RAPIDS with CUDA 12"
51113
```bash
52-
pip install "segger[rapids12]"
114+
git clone https://github.com/EliHei2/segger_dev.git
115+
cd segger_dev
116+
pip install -e ".[cuda12]"
53117
```
54118

55119
!!! warning "Common Installation Issues"
56-
- **Python Version**: Ensure you are using Python >= 3.10. Check your version with:
120+
- **Python Version**: Ensure you are using Python >= 3.10. Check your Python version by running:
57121
```bash
58122
python --version
59123
```
60-
If necessary, upgrade to the correct version.
124+
If your version is lower than 3.10, please upgrade Python.
61125

62-
- **CUDA Compatibility (GPU)**: For GPU installations, ensure the correct CUDA drivers are installed. Verify your setup with:
126+
- **CUDA Compatibility (GPU)**: For GPU installations, verify that your system has the correct NVIDIA drivers installed. Run:
63127
```bash
64128
nvidia-smi
65129
```
66-
Ensure your CUDA version is compatible with the package.
130+
Ensure that the displayed CUDA version is compatible with your selected `[cuda11]` or `[cuda12]` extra.
131+
132+
- Minimum driver version for **CUDA 11.x**: `450.80.02`
133+
- Minimum driver version for **CUDA 12.x**: `525.60.13`
67134

68-
- **Permissions**: If you encounter permission errors, use the `--user` flag to install without admin rights:
135+
- **Permissions**: If you encounter permission errors during installation, use the --user flag to install the package without requiring administrative privileges:
69136
```bash
70-
pip install --user .
137+
pip install --user .[cuda12]
71138
```
139+
Alternatively, consider using a virtual environment (venv or conda) to isolate the installation.
140+
141+
- **Environment Configuration**: Ensure that all required dependencies are installed in your environment.

docs/notebooks/segger_tutorial.ipynb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -506,17 +506,11 @@
506506
" min_transcripts=5,\n",
507507
" cell_id_col='segger_cell_id',\n",
508508
" use_cc=False,\n",
509-
" knn_method='cuda',\n",
509+
" knn_method='kd_tree',\n",
510510
" verbose=True,\n",
511511
")\n"
512512
]
513513
},
514-
{
515-
"cell_type": "markdown",
516-
"id": "3aa5002c",
517-
"metadata": {},
518-
"source": []
519-
},
520514
{
521515
"cell_type": "markdown",
522516
"id": "0a823035",

0 commit comments

Comments
 (0)