You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-32Lines changed: 29 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Project Templete to Kickoff Machine Learning Project
2
-
> This template currently uses `Python 3.11`, and either `conda`, `docker`, `poetry`, or `micromamba`
2
+
> This template currently uses `Python 3.11`, `Python 3.12`, and either `conda`, `poetry`, or `conda` or `micromamba`
3
3
4
4
Template project aims to promote *versioning library*, *environment isolation* practice and help all ML practitioners quickly start a project. Using this template, practitioners will have below libraries
5
5
+ Pytorch
@@ -17,15 +17,30 @@ Template project aims to promote *versioning library*, *environment isolation* p
17
17
18
18
Those libraries of course aren't enough, but it's easy to update other libraries that support your project.
19
19
20
-
> Using `poetry` is highly recommended. If you are using `conda` or `micromamba`, make sure that you use package hashes to ensure package selection is reproducible via `conda-lock` or `micromamba`
20
+
> Using `poetry` is highly recommended. If you are using `conda` or `micromamba`, make sure that you use package hashes to ensure package selection is reproducible via `conda-lock`.
21
21
22
-
## Install library dependencies
22
+
## Isolate Environment with Docker
23
+
- This tutorial is for those who have NVIDIA GPU (hereafter GPU), and you must have `docker`
24
+
- Install Nvidia driver
25
+
- Then install [Nvidia docker container toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html).
26
+
27
+
### Up and run (fast but not recommended)
28
+
-`docker run -v "$PWD:/workspace" --gpus all --rm -it pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime bash`
29
+
-`poetry install`
30
+
-`poetry shell`
31
+
32
+
### Using Conda-based environment
33
+
- Note: Docker will use `micromamba` instead of `miniconda`. Replace `conda` with `micromamba` in your usual commands
34
+
- Edit `.env` locates the same level with `run_docker.sh`, to add environment variables to the prospective docker container
35
+
- There is a file named `run_docker.sh`, allow to execute it by `chmod +x run_docker.sh` and run `run_docker.sh`
36
+
- Enjoy Jupyter lab at localhost:8888 as usual. Notebook token is shown after `run_docker.sh` runs successfully
37
+
38
+
## Isolate Environment without Docker
23
39
### With `poetry`
24
40
-`pip install poetry`
25
41
- Create, install, activate environment
26
42
```console
27
-
poetry install --with cpu # cpu
28
-
poetry install --with cu117 # cuda 11.7
43
+
poetry install
29
44
poetry shell
30
45
```
31
46
- Need to update environment after `poetry add a_lib`
- This tutorial is for those who have NVIDIA GPU (hereafter GPU). For CPU case, this should be similar but need to adjust `Dockerfile` and `run_docker.sh`
65
-
- Note: Docker will use `micromamba` instead of `miniconda`. Replace `conda` with `micromamba` in your usual commands
66
-
- You need to install `docker`
67
-
- Install Nvidia driver (ignore if you don't have GPU)
68
-
- Then install [Nvidia docker container toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html), ignore if you aim to use CPU.
69
-
- Edit `.env` locates the same level with `run_docker.sh`, to add environment variables to the prospective docker container
70
-
- There is a file named `run_docker.sh`, allow to execute it by `chmod +x run_docker.sh` and run `run_docker.sh`
71
-
- Enjoy Jupyter lab at localhost:8888 as usual. Notebook token is shown after `run_docker.sh` runs successfully
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)
84
93
85
94
data = Data(x=x, edge_index=edge_index.t().contiguous())
86
-
```
87
-
88
-
## Q&A
89
-
### My default Python is not 3.11, how I can instruct `poetry` to use Python 3.11
90
-
Use `poetry env use` to select Python version, more details are at more details https://stackoverflow.com/questions/60580113/change-python-version-to-3-x
91
-
### I don't want to use Python 3.11, how to change configs and make it reproducible
92
-
If you aim to use `poetry`, the steps are following
93
-
- edit file `pyproject.toml`
94
-
- select a Python version, then `poetry shell`
95
-
- generate new `poetry.lock` by run `poetry lock`
96
-
97
-
If you aim to follow `conda`
98
-
- edit file `environment.yml`
99
-
- create a new environment that has the version you want
100
-
- switch to that environment
95
+
print(data)
101
96
102
-
## Current limitation
103
-
-`torch_geometric` with CPU version in `poetry` has a problem. I created a discussion at https://github.com/pyg-team/pytorch_geometric/discussions/7788
97
+
classifier = pipeline("sentiment-analysis")
98
+
result = classifier("We are very happy to show you the 🤗 Transformers library.")
0 commit comments