@@ -59,44 +59,43 @@ jobs:
59
59
60
60
steps :
61
61
- uses : actions/checkout@v4
62
- - uses : actions/setup-python@v5
63
- with :
64
- python-version : ${{ matrix.python-version }}
65
-
66
62
- name : Get year & week number
67
63
id : get-date
68
64
run : |
69
65
echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
70
-
71
- - name : Get pip cache dir
72
- id : pip-cache
73
- run : |
74
- pip install -U pip || python -m pip install -U pip
75
- echo "pip_cache=$(pip cache dir)" >> $GITHUB_OUTPUT
76
-
77
- - uses : actions/cache@v4
66
+ - uses : astral-sh/setup-uv@v6
78
67
with :
79
- path : |
80
- ${{ steps.pip-cache.outputs.pip_cache }}
81
- key : ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}-${{ hashFiles('requirements-dev.txt') }}
82
- restore-keys : |
83
- ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}-
68
+ version : " latest"
69
+ python-version : ${{ matrix.python-version }}
70
+ activate-environment : true
71
+ enable-cache : true
72
+ cache-suffix : " ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}"
73
+ cache-dependency-glob : |
74
+ **/requirements-dev.txt
75
+ **/pyproject.toml
76
+ **/uv.lock
77
+
78
+ - name : Check uv lock
79
+ id : check-lock
80
+ run : |
81
+ uv lock --check
84
82
85
- - run : pip install pip wheel setuptools -Uqq
83
+ - name : Install dev tools
84
+ run : uv pip install wheel setuptools -Uqq
86
85
87
86
- name : Install PyTorch
88
87
if : ${{ matrix.pytorch-channel == 'pytorch' }}
89
- run : pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
88
+ run : uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
90
89
91
90
- name : Install PyTorch (nightly)
92
91
if : ${{ matrix.pytorch-channel == 'pytorch-nightly' }}
93
- run : pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
92
+ run : uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
94
93
95
94
- name : Install dependencies
96
95
run : |
97
- pip install -r requirements-dev.txt
98
- pip install .
99
- pip list
96
+ uv pip install -r requirements-dev.txt
97
+ uv pip install .
98
+ uv pip list
100
99
101
100
- name : Check code formatting
102
101
run : |
@@ -142,63 +141,63 @@ jobs:
142
141
run : |
143
142
# MNIST
144
143
# 1) mnist.py
145
- python examples/mnist/mnist.py --epochs=1
144
+ uv run python examples/mnist/mnist.py --epochs=1
146
145
147
146
- name : Run MNIST with loggers Examples
148
147
if : ${{ matrix.os == 'ubuntu-latest' }}
149
148
run : |
150
149
# 2) mnist_with_visdom.py
151
- python -c "from visdom.server.build import download_scripts; download_scripts()" # download scripts : https://github.com/facebookresearch/visdom/blob/master/py/server.py#L929
152
- python -m visdom.server &
150
+ uv run python -c "from visdom.server.build import download_scripts; download_scripts()" # download scripts : https://github.com/facebookresearch/visdom/blob/master/py/server.py#L929
151
+ uv run python -m visdom.server &
153
152
sleep 10
154
- python examples/mnist/mnist_with_visdom.py --epochs=1
153
+ uv run python examples/mnist/mnist_with_visdom.py --epochs=1
155
154
kill %1
156
155
# 3.1) mnist_with_tensorboard.py with tbX
157
- python examples/mnist/mnist_with_tensorboard.py --epochs=1
156
+ uv run python examples/mnist/mnist_with_tensorboard.py --epochs=1
158
157
# 3.2) mnist_with_tensorboard.py with native torch tb
159
- pip uninstall -y tensorboardX
160
- python examples/mnist/mnist_with_tensorboard.py --epochs=1
158
+ uv pip uninstall tensorboardX
159
+ uv run python examples/mnist/mnist_with_tensorboard.py --epochs=1
161
160
162
161
- name : Run MNIST Example With Crash
163
162
if : ${{ matrix.os == 'ubuntu-latest' }}
164
163
continue-on-error : true
165
164
run : |
166
165
# 4) mnist_save_resume_engine.py
167
- python examples/mnist/mnist_save_resume_engine.py --epochs=2 --crash_iteration 1100
166
+ uv run python examples/mnist/mnist_save_resume_engine.py --epochs=2 --crash_iteration 1100
168
167
169
168
- name : Resume MNIST from previous crash
170
169
if : ${{ matrix.os == 'ubuntu-latest' }}
171
170
run : |
172
- python examples/mnist/mnist_save_resume_engine.py --epochs=2 --resume_from=/tmp/mnist_save_resume/checkpoint_1.pt
171
+ uv run python examples/mnist/mnist_save_resume_engine.py --epochs=2 --resume_from=/tmp/mnist_save_resume/checkpoint_1.pt
173
172
174
173
- name : Run GAN example
175
174
if : ${{ matrix.os == 'ubuntu-latest' }}
176
175
run : |
177
176
# DCGAN
178
- python examples/gan/dcgan.py --dataset fake --dataroot /tmp/fakedata --output-dir /tmp/outputs-dcgan --batch-size 2 --epochs 2 --workers 0
177
+ uv run python examples/gan/dcgan.py --dataset fake --dataroot /tmp/fakedata --output-dir /tmp/outputs-dcgan --batch-size 2 --epochs 2 --workers 0
179
178
180
179
- name : Run RL Examples
181
180
if : ${{ matrix.os == 'ubuntu-latest' }}
182
181
run : |
183
182
# RL
184
183
# 1) Actor-Critic
185
- python examples/reinforcement_learning/actor_critic.py --max-episodes=2
184
+ uv run python examples/reinforcement_learning/actor_critic.py --max-episodes=2
186
185
# 2) Reinforce
187
- python examples/reinforcement_learning/reinforce.py --max-episodes=2
186
+ uv run python examples/reinforcement_learning/reinforce.py --max-episodes=2
188
187
189
188
- name : Run Neural Style Example
190
189
if : ${{ matrix.os == 'ubuntu-latest' }}
191
190
run : |
192
191
#fast-neural-style
193
192
#train
194
193
mkdir -p ~/.cache/torch/checkpoints/ && wget "https://download.pytorch.org/models/vgg16-397923af.pth" -O ~/.cache/torch/checkpoints/vgg16-397923af.pth
195
- python examples/fast_neural_style/neural_style.py train --epochs 1 --cuda 0 --dataset test --dataroot . --image_size 32 --style_image examples/fast_neural_style/images/style_images/mosaic.jpg --style_size 32
194
+ uv run python examples/fast_neural_style/neural_style.py train --epochs 1 --cuda 0 --dataset test --dataroot . --image_size 32 --style_image examples/fast_neural_style/images/style_images/mosaic.jpg --style_size 32
196
195
- name : Run SR Example
197
196
if : ${{ matrix.os == 'ubuntu-latest' }}
198
197
run : |
199
198
set -e
200
199
echo "Testing Caltech101 dataset availability..."
201
- if python -c "import torchvision; torchvision.datasets.Caltech101(root='./data', download=True)"; then
200
+ if uv run python -c "import torchvision; torchvision.datasets.Caltech101(root='./data', download=True)"; then
202
201
echo "Caltech101 dataset downloaded successfully. Please remove this workaround and restore dataset check."
203
202
exit 1
204
203
# python examples/super_resolution/main.py --upscale_factor 3 --crop_size 180 --batch_size 4 --test_batch_size 100 --n_epochs 1 --lr 0.001 --threads 2 --debug
0 commit comments