Skip to content

Commit 0af1bab

Browse files
committed
Add poetry support
1 parent 50b8b7f commit 0af1bab

File tree

3 files changed

+76
-6
lines changed

3 files changed

+76
-6
lines changed

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ store/plots
99
store/datasets
1010
store/results
1111

12-
venv
12+
venv
13+
.venv
14+
15+
# Normally, you would add this file to VCS but it's ignored here
16+
# because of different torch GPU accelerators
17+
poetry.lock

README.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,35 @@ with the following versions of PyTorch and Torchvision:
2828
* `pytorch 1.11.0`
2929
* `torchvision 0.12.0`
3030

31-
Further Python-packages used are listed in `requirements.txt`.
32-
Assuming Python and pip are set up, these packages can be installed using:
33-
```bash
34-
pip install -r requirements.txt
35-
```
31+
Further Python-packages used are listed in `requirements.txt` and `pyproject.toml`.
3632

3733
The code in this repository itself does not need to be installed, but a number of scripts should be made executable:
3834
```bash
3935
chmod +x main*.py compare*.py all_results.sh
4036
```
4137

38+
### Installation via poetry
39+
If you have poetry installed, you can install all project dependencies with a single command.
40+
41+
For CPU-only PyTorch acceleration:
42+
```bash
43+
poetry install --extras "cpu"
44+
```
45+
For CUDA PyTorch acceleration:
46+
```bash
47+
poetry install --extras "cuda"
48+
```
49+
50+
The choice of between `cpu` and `cuda` will only affect the source used to install `torch` and `torchvision`.
51+
52+
**Note** that poetry installs dependencies to a virtual environment, not globally.
53+
54+
### Installation via pip
55+
56+
Assuming Python and pip are set up, these packages can be installed using:
57+
```bash
58+
pip install -r requirements.txt
59+
```
4260

4361
## NeurIPS tutorial "Lifelong Learning Machines"
4462
This code repository is used for the

pyproject.toml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[project]
2+
name = "continual-learning"
3+
version = "1.0.0"
4+
description = "PyTorch implementation of various methods for continual learning (XdG, EWC, SI, LwF, FROMP, DGR, BI-R, ER, A-GEM, iCaRL, Generative Classifier) in three different scenarios."
5+
authors = [
6+
{name = "Gido van de Ven",email = "[email protected]"}
7+
]
8+
readme = "README.md"
9+
requires-python = ">=3.10"
10+
dependencies = [
11+
"numpy (>=2.2.5,<3.0.0)",
12+
"scipy (>=1.15.2,<2.0.0)",
13+
"pandas (>=2.2.3,<3.0.0)",
14+
"tqdm (>=4.67.1,<5.0.0)",
15+
"scikit-learn (>=1.6.1,<2.0.0)",
16+
"matplotlib (>=3.10.1,<4.0.0)",
17+
"visdom (>=0.2.4,<0.3.0)",
18+
"jupyterlab (>=4.4.0,<5.0.0)",
19+
"ipywidgets (>=8.1.6,<9.0.0)"
20+
]
21+
22+
[tool.poetry.dependencies]
23+
torch = [
24+
{ markers = "extra == 'cpu' and extra != 'cuda'", source = "pytorch-cpu"},
25+
{ markers = "extra == 'cuda' and extra != 'cpu'", source = "pytorch-cuda"},
26+
]
27+
28+
[project.optional-dependencies]
29+
cpu = ["torch (>=2.6.0)", "torchvision"]
30+
cuda = ["torch (>=2.6.0)", "torchvision"]
31+
32+
[build-system]
33+
requires = ["poetry-core>=2.0.0,<3.0.0"]
34+
build-backend = "poetry.core.masonry.api"
35+
36+
[tool.poetry]
37+
package-mode = false
38+
39+
[[tool.poetry.source]]
40+
name = "pytorch-cpu"
41+
url = "https://download.pytorch.org/whl/cpu"
42+
priority = "explicit"
43+
44+
[[tool.poetry.source]]
45+
name = "pytorch-cuda"
46+
url = "https://download.pytorch.org/whl/cu124"
47+
priority = "explicit"

0 commit comments

Comments
 (0)