Skip to content

Switched from distutils.version to pkg_resources #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions thop/fx_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import torch
import torch as th
import torch.nn as nn
from distutils.version import LooseVersion
import pkg_resources as pkg

if LooseVersion(torch.__version__) < LooseVersion("1.8.0"):
if pkg.parse_version(torch.__version__) < pkg.parse_version("1.8.0"):
logging.warning(
f"torch.fx requires version higher than 1.8.0. "
f"But You are using an old version PyTorch {torch.__version__}. "
Expand Down
6 changes: 3 additions & 3 deletions thop/profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import LooseVersion
import pkg_resources as pkg

from thop.vision.basic_hooks import *
from thop.rnn_hooks import *
Expand All @@ -9,7 +9,7 @@

from .utils import prGreen, prRed, prYellow

if LooseVersion(torch.__version__) < LooseVersion("1.0.0"):
if pkg.parse_version(torch.__version__) < pkg.parse_version("1.0.0"):
logging.warning(
"You are using an old version PyTorch {version}, which THOP does NOT support.".format(
version=torch.__version__
Expand Down Expand Up @@ -65,7 +65,7 @@
nn.PixelShuffle: zero_ops,
}

if LooseVersion(torch.__version__) >= LooseVersion("1.1.0"):
if pkg.parse_version(torch.__version__) >= pkg.parse_version("1.1.0"):
register_hooks.update({nn.SyncBatchNorm: count_normalization})


Expand Down