Skip to content

Commit

Permalink
Relax version of Python and PyTorch (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylormordan committed Sep 28, 2023
1 parent fcf38fc commit 6d11d6c
Show file tree
Hide file tree
Showing 29 changed files with 240 additions and 104 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy-guide-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ jobs:
deploy-guide-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache checkpoints and data
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cache
data-cifar10
key: ${{ runner.os }}-${{ hashFiles('setup.py') }}

- uses: FedericoCarboni/setup-ffmpeg@v1
- uses: FedericoCarboni/setup-ffmpeg@v2
id: setup-ffmpeg

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9

- name: Install PyTorch without CUDA
run: pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
run: pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

- name: Install dependencies
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/deploy-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ jobs:
deploy-guide:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache checkpoints and data
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cache
data-cifar10
key: ${{ runner.os }}-${{ hashFiles('setup.py') }}

- uses: FedericoCarboni/setup-ffmpeg@v1
- uses: FedericoCarboni/setup-ffmpeg@v2
id: setup-ffmpeg

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.9

- name: Install PyTorch without CUDA
run: pip install torch==1.9.0+cpu torchvision==0.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
run: pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

- name: Install dependencies
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pypi-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.7'
Expand All @@ -114,7 +114,7 @@ jobs:
- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

Expand All @@ -126,12 +126,12 @@ jobs:
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@master
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
67 changes: 36 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,65 @@ jobs:
torch: 1.9.0+cpu
torchvision: 0.10.0+cpu
torch-source: https://download.pytorch.org/whl/torch_stable.html
onnx: True
- os: ubuntu-latest
python: 3.8
torch: 1.9.0+cpu
torchvision: 0.10.0+cpu
python: 3.9
torch: 1.13.1+cpu
torchvision: 0.14.1+cpu
torch-source: https://download.pytorch.org/whl/torch_stable.html
slow: True
onnx: True
conda: True
- os: ubuntu-latest
python: 3.9
torch: 1.9.0+cpu
torchvision: 0.10.0+cpu
python: '3.10'
torch: 2.0.1+cpu
torchvision: 0.15.2+cpu
torch-source: https://download.pytorch.org/whl/torch_stable.html
- os: macos-11
build-isolation: True
- os: macos-latest
python: 3.7
torch: 1.9.0
torchvision: 0.10.0
torch-source: https://download.pytorch.org/whl/torch_stable.html
- os: macos-11
python: 3.8
torch: 1.9.0
torchvision: 0.10.0
torch-source: https://download.pytorch.org/whl/torch_stable.html
conda: True
onnx: True
- os: macos-11
- os: macos-latest
python: 3.9
torch: 1.9.0
torchvision: 0.10.0
torch: 1.13.1
torchvision: 0.14.1
torch-source: https://download.pytorch.org/whl/torch_stable.html
slow: True
conda: True
- os: macos-latest
python: '3.10'
torch: 2.0.1
torchvision: 0.15.2
torch-source: https://download.pytorch.org/whl/torch_stable.html
build-isolation: True
- os: windows-latest
python: 3.8
torch: 1.9.0+cpu
torchvision: 0.10.0+cpu
python: 3.9
torch: 1.13.1+cpu
torchvision: 0.14.1+cpu
torch-source: https://download.pytorch.org/whl/torch_stable.html
slow: True
onnx: True

env:
DEBUG: 1
# DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
steps:
- run: ls -n /Applications/ | grep Xcode*
if: matrix.os == 'macos-11'
- uses: actions/checkout@v2
if: matrix.os == 'macos-latest'
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache checkpoints and data
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cache
data-cifar10
key: ${{ runner.os }}-${{ hashFiles('setup.py') }}
- name: Set up Python ${{ matrix.python }}
if: ${{ !matrix.conda }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Set up Conda
Expand Down Expand Up @@ -98,25 +101,27 @@ jobs:
run: python -m pip install -e ".[onnx]" --no-build-isolation
- name: Install for training
if: matrix.slow
run: python -m pip install -e ".[train]" --no-build-isolation
run: |
python -m pip install cython --no-build-isolation
python -m pip install -e ".[train]" --no-build-isolation
- name: Install ffmpeg for Guide test
uses: FedericoCarboni/setup-ffmpeg@v1
uses: FedericoCarboni/setup-ffmpeg@v2
if: matrix.slow
id: setup-ffmpeg
- name: ffmpeg codecs
if: matrix.slow
run: ffmpeg -codecs
- name: Install for MacOSX - CoreML
if: matrix.os == 'macos-11'
if: matrix.os == 'macos-latest'
run: python -m pip install -e ".[coreml]" --no-build-isolation
- name: Install OpenCV
if: matrix.slow && matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get --no-install-recommends install python3-opencv libopencv-dev
- name: Download libtorch binaries compiled with CXX11-ABI=1
if: matrix.slow && matrix.os == 'ubuntu-latest'
run: |
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcpu.zip
unzip libtorch-cxx11-abi-shared-with-deps-1.9.0+cpu.zip
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.13.1%2Bcpu.zip
unzip libtorch-cxx11-abi-shared-with-deps-1.13.1+cpu.zip
ls
ls libtorch
ls libtorch/lib
Expand Down Expand Up @@ -197,7 +202,7 @@ jobs:
python -m pip install --no-build-isolation ../dist/openpifpaf-vita*
python -c "import openpifpaf"
- name: sdist installable with build isolation
if: matrix.os != 'windows-latest' # because of path separator
if: matrix.build-isolation && matrix.os != 'windows-latest' # because of path separator
run: |
mkdir sdist_with_build_isolation_test_dir
cd sdist_with_build_isolation_test_dir
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
update-stable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
Expand Down
5 changes: 3 additions & 2 deletions guide/dev.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"\n",
"This version of OpenPifPaf (`openpifpaf-vita`) cannot co-exist with the original one ([`openpifpaf`](https://github.com/openpifpaf/openpifpaf)) in the same environment. If you have previously installed the package `openpifpaf`, remove it before installation to avoid conflicts.\n",
"\n",
"For development of the openpifpaf source code itself, you need to clone this repository and then:\n",
"For development of the openpifpaf source code itself, you need to clone this repository and install it:\n",
"\n",
"```sh\n",
"pip3 install --editable '.[dev,train,test]'\n",
"git clone https://github.com/vita-epfl/openpifpaf\n",
"pip3 install --editable './openpifpaf[dev,train,test,backbones]'\n",
"```\n",
"\n",
"The last command installs the Python package in the current directory\n",
Expand Down
10 changes: 10 additions & 0 deletions guide/faq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
"[GitHub issue](https://github.com/vita-epfl/openpifpaf/issues)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation with older PyTorch versions\n",
"\n",
"When installing `openpifpaf-vita` with some older PyTorch version, an error (`undefined symbol`) can happen.\n",
"Try using the `pip` option `--no-build-isolation` to solve the issue."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
3 changes: 0 additions & 3 deletions guide/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ For a live demo, we recommend to try the
Alternatively, {ref}`python3 -m openpifpaf.video <cli-help-video>` (requires OpenCV)
provides a live demo as well.

_Only on MacOS (Dec 2021)_: There seems to be an issue with Torch 1.10. Please try
to stick with Torch 1.9 for now.


## Pre-trained Models

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
"torch==1.9.0",
"torch>=1.9.0",
"wheel",
]

Expand Down
18 changes: 8 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ def add_cpp_extension():
ext_modules=EXTENSIONS,
zip_safe=False,

python_requires='>=3.6',
python_requires='>=3.7',
install_requires=[
'importlib_metadata!=3.8.0', # temporary for pytest
'numpy>=1.16',
'pysparkling', # for log analysis
'python-json-logger',
'torch==1.9.0',
'torchvision==0.10.0',
'torch>=1.9.0',
'torchvision>=0.10.0',
'pillow!=8.3.0', # exclusion torchvision 0.10.0 compatibility
'dataclasses; python_version<"3.7"',
],
extras_require={
'backbones': [
Expand All @@ -97,6 +96,7 @@ def add_cpp_extension():
'dev': [
'flameprof',
'ipython<8', # temporarily added to avoid broken output cells in jupyter-book
'jsonschema[format-nongpl]==4.17.3',
'jupyter-book>=0.9.1,<0.14', # breaking changes introduced in 0.14
'matplotlib>=3.3',
'nbdime',
Expand All @@ -107,13 +107,11 @@ def add_cpp_extension():
],
'onnx': [
'onnx',
'onnxruntime',
'onnx-simplifier>=0.2.9; python_version<"3.9"', # Python 3.9 not supported yet
'onnxruntime; python_version<="3.9"',
'protobuf<4', # temporary explicit dependency until tests pass again
],
'coreml': [
'coremltools>=5.0b3',
'numpy<1.24', # for coremltools compatibility
'coremltools>=5.0b3,<7',
],
'test': [
'cpplint',
Expand All @@ -130,9 +128,9 @@ def add_cpp_extension():
],
'train': [
'matplotlib>=3.3', # required by pycocotools
'pycocotools>=2.0.1,!=2.0.5,!=2.0.6', # pre-install cython (currently incompatible with numpy 1.18 or above)
'pycocotools@git+https://github.com/ppwwyyxx/cocoapi.git#subdirectory=PythonAPI', # pre-install cython, last version fixing compilation not on pypi
'scipy',
'xtcocotools>=1.5; sys_platform == "linux"', # required for wholebody eval, only wheels and only for linux on pypi
'xtcocotools>=1.5; sys_platform == "linux"', # pre-install numpy. required for wholebody eval, only wheels and only for linux on pypi
],
},
)
2 changes: 1 addition & 1 deletion src/openpifpaf/decoder/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def apply(f, items):
return [apply(f, i) for i in items]
return f(items)

with torch.no_grad():
with torch.inference_mode():
if device is not None:
image_batch = image_batch.to(device, non_blocking=True)

Expand Down
4 changes: 4 additions & 0 deletions src/openpifpaf/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import os
import platform
import sys
import time

Expand Down Expand Up @@ -251,6 +252,9 @@ def watch(args):
def main():
args = cli()

LOG.info('Running Python %s', platform.python_version())
LOG.info('Running PyTorch %s', torch.__version__)

if args.watch:
watch(args)
else:
Expand Down
Loading

0 comments on commit 6d11d6c

Please sign in to comment.