megvii-research / Sparsebit

A model compression and acceleration toolbox based on pytorch.
Apache License 2.0
327 stars 40 forks source link

ImportError #49

Closed haiduo closed 2 years ago

haiduo commented 2 years ago

My setting: cuda 10.2 python=3.8

intsall SparseBit by :

git clone https://github.com/megvii-research/Sparsebit.git
cd sparsebit
python3 setup.py develop --user
pip3 install tensorrt-8.2.5.1-cp38-none-linux_x86_64.whl

after installed that: run /root/Sparsebit/examples/cifar10_ptq/main.ipynb, but exposing RuntimeError: Ninja is required to load C++ extensions, so ,also run pip install Ninja, then run main.ipynb again, exposing an error:

Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?9abbaedb-76bc-4b54-8e8c-3079840743b9)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/root/Sparsebit/examples/cifar10_ptq/main.ipynb Cell 2 in <cell line: 24>()
     [21](vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a2268616964756f546974616e5f7870227d/root/Sparsebit/examples/cifar10_ptq/main.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=20) import torchvision.datasets as datasets
     [22](vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a2268616964756f546974616e5f7870227d/root/Sparsebit/examples/cifar10_ptq/main.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=21) from model import resnet20
---> [24](vscode-notebook-cell://ssh-remote%2B7b22686f73744e616d65223a2268616964756f546974616e5f7870227d/root/Sparsebit/examples/cifar10_ptq/main.ipynb#W1sdnNjb2RlLXJlbW90ZQ%3D%3D?line=23) from sparsebit.quantization import QuantModel, parse_qconfig

File ~/Sparsebit/sparsebit/quantization/__init__.py:1, in <module>
----> 1 from .quant_model import *
      2 from .quant_config import parse_qconfig

File ~/Sparsebit/sparsebit/quantization/quant_model.py:18, in <module>
     15 import onnx
     17 from sparsebit.utils import update_config
---> 18 from sparsebit.quantization.modules import *
     19 from sparsebit.quantization.observers import Observer
     20 from sparsebit.quantization.quantizers import Quantizer

File ~/Sparsebit/sparsebit/quantization/modules/__init__.py:16, in <module>
     12     return real_register
     15 # 将需要注册的module文件填写至此
---> 16 from .base import QuantOpr, MultipleInputsQuantOpr
     17 from .activations import *
     18 from .conv import *
...
-> 1775     module = importlib.util.module_from_spec(spec)
   1776     assert isinstance(spec.loader, importlib.abc.Loader)
   1777     spec.loader.exec_module(module)

ImportError: /root/Sparsebit/sparsebit/quantization/torch_extensions/build/fake_quant.so: cannot open shared object file: No such file or directory

I examine the "build directory", and find it is empty: image

haiduo commented 2 years ago

Solved! It is just only path error of miniconda envs!