openfl icon indicating copy to clipboard operation
openfl copied to clipboard

PyTorch >=2.5.0 - TypeError: Type parameter +RV without a default follows type parameter with a default

Open tanwarsh opened this issue 9 months ago • 1 comments

Describe the bug Version: PyTorch >=2.5.0 PIP > 24.1.2 Torchvision >=0.20.1

The error shown in screenshot below occurs when using a dataset with PyTorch and Torchvision.

To Reproduce Steps to reproduce the behavior:

  1. Follow https://openfl.readthedocs.io/en/latest/tutorials/taskrunner.html# and run torch/mnist workspace with version mentioned above.

Expected behavior The experiment should run without any issues.

Screenshots

Image

Solution

  1. Use PIP version <=24.1.2 for dependency management.
  2. Apply the following patch before importing datasets from torchvision.
import sys
import typing_extensions
sys.modules["pip._vendor.typing_extensions"] = typing_extensions
from torchvision import datasets

tanwarsh avatar Mar 12 '25 06:03 tanwarsh

Thanks for publishing the workaround, @tanwarsh !

teoparvanov avatar Mar 19 '25 10:03 teoparvanov