neuralmagic / sparsify

ML model optimization product to accelerate inference.
Apache License 2.0
320 stars 29 forks source link

Fix Sparsifyml not installed prompt #256

Closed rahul-tuli closed 1 year ago

rahul-tuli commented 1 year ago

The recently added environment check cli was missing authenticated import of sparsifyml, This led to a ModuleNotFoundError instead of a SparsifyLoginRequired

Current PR fixes that.

Test Command:

sparsify.run sparse-transfer --use-case image-classification --data /network/datasets/imagenette-160 --optim-level 25

Command Output:

Before this PR: (Reported by @dsikka)

Traceback (most recent call last):
  File "/home/dsikka/venvs/sparsify_main/bin/sparsify.run", line 5, in <module>
    from sparsify.cli.run import main
  File "/home/dsikka/sparsify/src/sparsify/cli/run.py", line 21, in <module>
    from sparsify.check_environment import auto_checks, one_shot_checks
  File "/home/dsikka/sparsify/src/sparsify/check_environment/__init__.py", line 19, in <module>
    from .ort_health import *
  File "/home/dsikka/sparsify/src/sparsify/check_environment/ort_health.py", line 26, in <module>
    from sparsifyml.one_shot.utils import run_onnx_model
ModuleNotFoundError: No module named 'sparsifyml'

After this PR:

$ sparsify.run sparse-transfer --use-case image-classification --data /network/datasets/imagenette-160 --optim-level 25
Traceback (most recent call last):
  File "/home/rahul/venvs/sparsify/bin/sparsify.run", line 5, in <module>
    from sparsify.cli.run import main
  File "/home/rahul/projects/sparsify/src/sparsify/cli/run.py", line 21, in <module>
    from sparsify.check_environment import auto_checks, one_shot_checks
  File "/home/rahul/projects/sparsify/src/sparsify/check_environment/__init__.py", line 19, in <module>
    from .ort_health import *
  File "/home/rahul/projects/sparsify/src/sparsify/check_environment/ort_health.py", line 29, in <module>
    import_sparsifyml_authenticated()
  File "/home/rahul/projects/sparsify/src/sparsify/login.py", line 137, in import_sparsifyml_authenticated
    authenticate()
  File "/home/rahul/projects/sparsify/src/sparsify/login.py", line 150, in authenticate
    raise SparsifyLoginRequired(
sparsify.utils.exceptions.SparsifyLoginRequired: No valid sparsify credentials found. Please run `sparsify.login`