Spaces:
Running
The comflict between spaces and lavis
Thanks for your nice project.
When I'm trying to deploy my space with zerogpu, it seems the packge salesforce-lavis
comflicts with spaces
.
To reproduce the error, just import these two libs in a single file.
For example, if I do:
import spaces
import lavis
I get:
Traceback (most recent call last):
File "/home/user/app/tmp2.py", line 3, in
import lavis
File "/usr/local/lib/python3.10/site-packages/lavis/init.py", line 15, in
from lavis.datasets.builders import *
File "/usr/local/lib/python3.10/site-packages/lavis/datasets/builders/init.py", line 8, in
from lavis.datasets.builders.base_dataset_builder import load_dataset_config
File "/usr/local/lib/python3.10/site-packages/lavis/datasets/builders/base_dataset_builder.py", line 15, in
from lavis.common.dist_utils import is_dist_avail_and_initialized, is_main_process
File "/usr/local/lib/python3.10/site-packages/lavis/common/dist_utils.py", line 14, in
import timm.models.hub as timm_hub
File "/usr/local/lib/python3.10/site-packages/timm/init.py", line 2, in
from .models import create_model, list_models, is_model, list_modules, model_entrypoint,
File "/usr/local/lib/python3.10/site-packages/timm/models/init.py", line 1, in
from .byoanet import *
File "/usr/local/lib/python3.10/site-packages/timm/models/byoanet.py", line 16, in
from .byobnet import ByoBlockCfg, ByoModelCfg, ByobNet, interleave_blocks
File "/usr/local/lib/python3.10/site-packages/timm/models/byobnet.py", line 36, in
from .helpers import build_model_with_cfg
File "/usr/local/lib/python3.10/site-packages/timm/models/helpers.py", line 18, in
from .layers import Conv2dSame, Linear
File "/usr/local/lib/python3.10/site-packages/timm/models/layers/init.py", line 10, in
from .conv_bn_act import ConvBnAct
File "/usr/local/lib/python3.10/site-packages/timm/models/layers/conv_bn_act.py", line 8, in
from .create_norm_act import convert_norm_act
File "/usr/local/lib/python3.10/site-packages/timm/models/layers/create_norm_act.py", line 16, in
from .norm_act import BatchNormAct2d, GroupNormAct
File "/usr/local/lib/python3.10/site-packages/timm/models/layers/norm_act.py", line 7, in
from .create_act import get_act_layer
File "/usr/local/lib/python3.10/site-packages/timm/models/layers/create_act.py", line 8, in
from .activations_me import *
File "/usr/local/lib/python3.10/site-packages/timm/models/layers/activations_me.py", line 105, in
def hard_sigmoid_jit_bwd(x, grad_output):
File "/usr/local/lib/python3.10/site-packages/torch/jit/_script.py", line 1341, in script
fn = torch._C._jit_script_compile(
File "/usr/local/lib/python3.10/site-packages/torch/jit/annotations.py", line 71, in get_signature
signature = try_real_annotations(fn, loc)
File "/usr/local/lib/python3.10/site-packages/torch/jit/annotations.py", line 278, in try_real_annotations
arg_types = [ann_to_type(p.annotation, loc)
File "/usr/local/lib/python3.10/site-packages/torch/jit/annotations.py", line 278, in
arg_types = [ann_to_type(p.annotation, loc)
File "/usr/local/lib/python3.10/site-packages/torch/jit/annotations.py", line 422, in ann_to_type
raise ValueError(f"Unknown type annotation: '{ann}' at {loc.highlight()}")
ValueError: Unknown type annotation: 'Any' at File "/usr/local/lib/python3.10/site-packages/timm/models/layers/activations_me.py", line 106
@torch .jit.script
def hard_sigmoid_jit_bwd(x, grad_output):
m = torch.ones_like(x) * ((x >= -3.) & (x <= 3.)) / 6.
~~~~~~~~~~~~~~~ <--- HERE
return grad_output * m
And if I import lavis first, like:
import lavis
import spaces
I'll get:
/usr/local/lib/python3.10/site-packages/torch/cuda/init.py:546: UserWarning: Can't initialize NVML
warnings.warn("Can't initialize NVML")
Traceback (most recent call last):
File "/home/user/app/tmp2.py", line 3, in
import spaces
File "/usr/local/lib/python3.10/site-packages/spaces/init.py", line 10, in
from .zero.decorator import GPU
File "/usr/local/lib/python3.10/site-packages/spaces/zero/init.py", line 9, in
raise RuntimeError(
RuntimeError: CUDA has been initialized before importing thespaces
package
Below are the versions of the libs:
torch==2.0
salesforce-lavis==1.0.0
transformers==4.33.3
spaces==0.28.3
I've also tried the latest version of torch (V2.3.1) and the latest version of transformers (V4.26.1), and the issue persists.
This problem is fixed by updating timm
to the latest version.