Skip to content

Commit 6afe679

Browse files
committed
upgrade to cuda 12.4
1 parent cb1ed8f commit 6afe679

File tree

7 files changed

+4200
-3131
lines changed

7 files changed

+4200
-3131
lines changed

.condarc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
channel_priority: strict
21
channels:
3-
- conda-forge
4-
- defaults
2+
- pytorch
3+
- nvidia
4+
- pyg
5+
- conda-forge

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM mambaorg/micromamba:1.5.1 as micromamba
2-
FROM nvcr.io/nvidia/pytorch:23.09-py3
1+
FROM mambaorg/micromamba:2.0 as micromamba
2+
FROM nvcr.io/nvidia/pytorch:24.10-py3
33

44
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
55
ENV ENV_NAME=ml-venv
@@ -30,10 +30,11 @@ USER $MAMBA_USER
3030
SHELL ["/usr/local/bin/_dockerfile_shell.sh"]
3131
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]
3232

33-
RUN micromamba install -y -n base -c conda-forge python=3.11 \
33+
RUN micromamba install -y -n base -c conda-forge python=3.12 \
3434
&& micromamba clean --all --yes
3535

3636
WORKDIR /tmp
37+
3738
# Install any needed packages specified in environment.yml
3839
COPY environment.yml environment.yml
3940
RUN micromamba create -n $ENV_NAME -f environment.yml -y \

README.md

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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`
33
44
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
55
+ Pytorch
@@ -17,15 +17,30 @@ Template project aims to promote *versioning library*, *environment isolation* p
1717

1818
Those libraries of course aren't enough, but it's easy to update other libraries that support your project.
1919

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`.
2121
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
2339
### With `poetry`
2440
- `pip install poetry`
2541
- Create, install, activate environment
2642
```console
27-
poetry install --with cpu # cpu
28-
poetry install --with cu117 # cuda 11.7
43+
poetry install
2944
poetry shell
3045
```
3146
- Need to update environment after `poetry add a_lib`
@@ -60,21 +75,15 @@ conda env update --file binder/environment.yml --prune
6075
conda env export --from-history -f binder/environment.yml
6176
```
6277

63-
### With `docker`
64-
- 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
72-
7378
## After installing libraries, verify
79+
7480
try this in `ipython`
7581
```python
7682
import torch
7783
from torch_geometric.data import Data
84+
from transformers import pipeline
85+
86+
print(torch.cuda.is_available())
7887

7988
edge_index = torch.tensor([[0, 1],
8089
[1, 0],
@@ -83,21 +92,9 @@ edge_index = torch.tensor([[0, 1],
8392
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)
8493

8594
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)
10196

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.")
99+
print(result)
100+
```

environment.yml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
11
name: ml-venv
2+
channel_priority: disabled
23
channels:
4+
- pytorch
5+
- nvidia
6+
- pyg
37
- conda-forge
4-
- defaults
58
dependencies:
6-
- python=3.11
9+
- python=3.12
10+
- pip
11+
- blas
12+
- networkx
713
- numpy
14+
- scipy
815
- pandas
16+
- scikit-learn
917
- matplotlib
10-
- pip
1118
- jupyterlab
1219
- ipywidgets
13-
- scipy
14-
- scikit-learn
1520
- panel
1621
- pytest
22+
- pytorch::pytorch=2.4.1
23+
- pytorch::pytorch-cuda=12.4
24+
- pytorch::torchvision=0.19.1
25+
- pytorch::torchaudio=2.4.1
26+
- pyg=2.6.1
27+
- transformers=4.46.0
28+
- sentencepiece
29+
- lightning
30+
- click
31+
- wandb
32+
- dvc
33+
- torchmetrics
34+
- evaluate
1735
- pip:
18-
- click
19-
- torch
20-
- torchvision
21-
- torchaudio
22-
- transformers
23-
- pytorch-lightning
24-
- wandb
25-
- torch_geometric
26-
- torchmetrics
27-
- accelerate
28-
- datasets
29-
- dvc
36+
- pyg_lib==0.4.0+pt24cu124
37+
- torch_scatter==2.1.2+pt24cu124
38+
- torch_sparse==0.6.18+pt24cu124
39+
- torch_cluster==1.6.3+pt24cu124
40+
- torch_spline_conv==1.2.2+pt24cu124
41+
- -f https://data.pyg.org/whl/torch-2.4.0+cu124.html

0 commit comments

Comments
 (0)