@@ -59,44 +59,37 @@ jobs:
5959
6060 steps :
6161 - uses : actions/checkout@v4
62- - uses : actions/setup-python@v5
63- with :
64- python-version : ${{ matrix.python-version }}
65-
6662 - name : Get year & week number
6763 id : get-date
6864 run : |
6965 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
7867 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
8476
85- - run : pip install pip wheel setuptools -Uqq
77+ - name : Install dev tools
78+ run : uv pip install wheel setuptools -Uqq
8679
8780 - name : Install PyTorch
8881 if : ${{ matrix.pytorch-channel == 'pytorch' }}
89- run : pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
82+ run : uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
9083
9184 - name : Install PyTorch (nightly)
9285 if : ${{ matrix.pytorch-channel == 'pytorch-nightly' }}
93- run : pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
86+ run : uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
9487
9588 - name : Install dependencies
9689 run : |
97- pip install -r requirements-dev.txt
98- pip install .
99- pip list
90+ uv pip install -r requirements-dev.txt
91+ uv pip install .
92+ uv pip list
10093
10194 - name : Check code formatting
10295 run : |
@@ -142,63 +135,63 @@ jobs:
142135 run : |
143136 # MNIST
144137 # 1) mnist.py
145- python examples/mnist/mnist.py --epochs=1
138+ uv run python examples/mnist/mnist.py --epochs=1
146139
147140 - name : Run MNIST with loggers Examples
148141 if : ${{ matrix.os == 'ubuntu-latest' }}
149142 run : |
150143 # 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 &
144+ 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
145+ uv run python -m visdom.server &
153146 sleep 10
154- python examples/mnist/mnist_with_visdom.py --epochs=1
147+ uv run python examples/mnist/mnist_with_visdom.py --epochs=1
155148 kill %1
156149 # 3.1) mnist_with_tensorboard.py with tbX
157- python examples/mnist/mnist_with_tensorboard.py --epochs=1
150+ uv run python examples/mnist/mnist_with_tensorboard.py --epochs=1
158151 # 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
152+ uv pip uninstall tensorboardX
153+ uv run python examples/mnist/mnist_with_tensorboard.py --epochs=1
161154
162155 - name : Run MNIST Example With Crash
163156 if : ${{ matrix.os == 'ubuntu-latest' }}
164157 continue-on-error : true
165158 run : |
166159 # 4) mnist_save_resume_engine.py
167- python examples/mnist/mnist_save_resume_engine.py --epochs=2 --crash_iteration 1100
160+ uv run python examples/mnist/mnist_save_resume_engine.py --epochs=2 --crash_iteration 1100
168161
169162 - name : Resume MNIST from previous crash
170163 if : ${{ matrix.os == 'ubuntu-latest' }}
171164 run : |
172- python examples/mnist/mnist_save_resume_engine.py --epochs=2 --resume_from=/tmp/mnist_save_resume/checkpoint_1.pt
165+ uv run python examples/mnist/mnist_save_resume_engine.py --epochs=2 --resume_from=/tmp/mnist_save_resume/checkpoint_1.pt
173166
174167 - name : Run GAN example
175168 if : ${{ matrix.os == 'ubuntu-latest' }}
176169 run : |
177170 # DCGAN
178- python examples/gan/dcgan.py --dataset fake --dataroot /tmp/fakedata --output-dir /tmp/outputs-dcgan --batch-size 2 --epochs 2 --workers 0
171+ uv run python examples/gan/dcgan.py --dataset fake --dataroot /tmp/fakedata --output-dir /tmp/outputs-dcgan --batch-size 2 --epochs 2 --workers 0
179172
180173 - name : Run RL Examples
181174 if : ${{ matrix.os == 'ubuntu-latest' }}
182175 run : |
183176 # RL
184177 # 1) Actor-Critic
185- python examples/reinforcement_learning/actor_critic.py --max-episodes=2
178+ uv run python examples/reinforcement_learning/actor_critic.py --max-episodes=2
186179 # 2) Reinforce
187- python examples/reinforcement_learning/reinforce.py --max-episodes=2
180+ uv run python examples/reinforcement_learning/reinforce.py --max-episodes=2
188181
189182 - name : Run Neural Style Example
190183 if : ${{ matrix.os == 'ubuntu-latest' }}
191184 run : |
192185 #fast-neural-style
193186 #train
194187 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
188+ 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
196189 - name : Run SR Example
197190 if : ${{ matrix.os == 'ubuntu-latest' }}
198191 run : |
199192 set -e
200193 echo "Testing Caltech101 dataset availability..."
201- if python -c "import torchvision; torchvision.datasets.Caltech101(root='./data', download=True)"; then
194+ if uv run python -c "import torchvision; torchvision.datasets.Caltech101(root='./data', download=True)"; then
202195 echo "Caltech101 dataset downloaded successfully. Please remove this workaround and restore dataset check."
203196 exit 1
204197 # 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