Skip to content
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

ImportError: cannot import name 'TorchDispatchMode' from 'torch.utils._python_dispatch' #137

Closed
euminds opened this issue Jun 6, 2024 · 2 comments · Fixed by #141
Closed
Labels
bug Something isn't working

Comments

@euminds
Copy link

euminds commented Jun 6, 2024

ImportError: cannot import name 'TorchDispatchMode' from 'torch.utils._python_dispatch' (/home/user/miniconda3/envs/vclip/lib/python3.7/site-packages/torch/utils/_python_dispatch.py)

conda list

# packages in environment at /home/user/miniconda3/envs/vclip:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
addict                    2.4.0                    pypi_0    pypi
beautifulsoup4            4.12.2                   pypi_0    pypi
blas                      1.0                         mkl  
brotlipy                  0.7.0           py37h27cfd23_1003  
bzip2                     1.0.8                h7b6447c_0  
ca-certificates           2023.05.30           h06a4308_0  
certifi                   2022.12.7        py37h06a4308_0  
cffi                      1.15.1           py37h5eee18b_3  
charset-normalizer        2.0.4              pyhd3eb1b0_0  
clip                      1.0                      pypi_0    pypi
cryptography              39.0.1           py37h9ce1e76_0  
cudatoolkit               11.3.1               h2bc3f7f_2  
decord                    0.6.0                    pypi_0    pypi
einops                    0.6.1                    pypi_0    pypi
faiss-cpu                 1.7.3           py3.7_h2a577fa_0_cpu    pytorch
ffmpeg                    4.3                  hf484d3e_0    pytorch
filelock                  3.12.2                   pypi_0    pypi
flit-core                 3.6.0              pyhd3eb1b0_0  
freetype                  2.12.1               h4a9f257_0  
fsspec                    2023.1.0                 pypi_0    pypi
ftfy                      6.1.1                    pypi_0    pypi
gdown                     4.7.1                    pypi_0    pypi
giflib                    5.2.1                h5eee18b_3  
gmp                       6.2.1                h295c915_3  
gnutls                    3.6.15               he1e5248_0  
huggingface-hub           0.15.1                   pypi_0    pypi
idna                      3.4              py37h06a4308_0  
importlib-metadata        6.7.0                    pypi_0    pypi
intel-openmp              2021.4.0          h06a4308_3561  
jpeg                      9e                   h5eee18b_1  
lame                      3.100                h7b6447c_0  
lcms2                     2.12                 h3be6417_0  
ld_impl_linux-64          2.38                 h1181459_1  
lerc                      3.0                  h295c915_0  
libdeflate                1.17                 h5eee18b_0  
libfaiss                  1.7.3            h2bc3f7f_0_cpu    pytorch
libffi                    3.4.4                h6a678d5_0  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libiconv                  1.16                 h7f8727e_2  
libidn2                   2.3.4                h5eee18b_0  
libpng                    1.6.39               h5eee18b_0  
libstdcxx-ng              11.2.0               h1234567_1  
libtasn1                  4.19.0               h5eee18b_0  
libtiff                   4.5.0                h6a678d5_2  
libunistring              0.9.10               h27cfd23_0  
libuv                     1.44.2               h5eee18b_0  
libwebp                   1.2.4                h11a3e52_1  
libwebp-base              1.2.4                h5eee18b_1  
lz4-c                     1.9.4                h6a678d5_0  
mkl                       2021.4.0           h06a4308_640  
mkl-service               2.4.0            py37h7f8727e_0  
mkl_fft                   1.3.1            py37hd3c417c_0  
mkl_random                1.2.2            py37h51133e4_0  
mmcv-full                 1.7.1                    pypi_0    pypi
ncurses                   6.4                  h6a678d5_0  
nettle                    3.7.3                hbbd107a_1  
numpy                     1.21.5           py37h6c91a56_3  
numpy-base                1.21.5           py37ha15fc14_3  
opencv-python             4.7.0.72                 pypi_0    pypi
openh264                  2.1.1                h4ff587b_0  
openssl                   1.1.1u               h7f8727e_0  
packaging                 23.1                     pypi_0    pypi
pandas                    1.3.5                    pypi_0    pypi
pathlib                   1.0.1                    pypi_0    pypi
pillow                    9.4.0            py37h6a678d5_0  
pip                       22.3.1           py37h06a4308_0  
platformdirs              3.7.0                    pypi_0    pypi
ptflops                   0.7.3                    pypi_0    pypi
pycparser                 2.21               pyhd3eb1b0_0  
pyopenssl                 23.0.0           py37h06a4308_0  
pysocks                   1.7.1                    py37_1  
python                    3.7.16               h7a1cb2a_0  
python-dateutil           2.8.2                    pypi_0    pypi
pytorch                   1.11.0          py3.7_cuda11.3_cudnn8.2.0_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytz                      2023.3                   pypi_0    pypi
pyyaml                    6.0                      pypi_0    pypi
readline                  8.2                  h5eee18b_0  
regex                     2023.6.3                 pypi_0    pypi
requests                  2.28.1           py37h06a4308_0  
safetensors               0.3.1                    pypi_0    pypi
scipy                     1.7.3                    pypi_0    pypi
setuptools                65.6.3           py37h06a4308_0  
six                       1.16.0             pyhd3eb1b0_1  
soupsieve                 2.4.1                    pypi_0    pypi
sqlite                    3.41.2               h5eee18b_0  
termcolor                 2.3.0                    pypi_0    pypi
timm                      0.9.2                    pypi_0    pypi
tk                        8.6.12               h1ccaba5_0  
tomli                     2.0.1                    pypi_0    pypi
torchvision               0.12.0               py37_cu113    pytorch
tqdm                      4.65.0                   pypi_0    pypi
typing-extensions         4.6.3                    pypi_0    pypi
urllib3                   1.26.14          py37h06a4308_0  
wcwidth                   0.2.6                    pypi_0    pypi
wheel                     0.38.4           py37h06a4308_0  
xz                        5.4.2                h5eee18b_0  
yacs                      0.1.8                    pypi_0    pypi
yapf                      0.40.1                   pypi_0    pypi
zipp                      3.15.0                   pypi_0    pypi
zlib                      1.2.13               h5eee18b_0  
zstd                      1.5.5                hc292b87_0  
@sovrasov sovrasov added the bug Something isn't working label Jun 6, 2024
@sovrasov
Copy link
Owner

sovrasov commented Jun 6, 2024

@euminds please upgrade your torch version to 2.x if possible, or downgrade ptflops. torch 1.x does not support TorchDispatchMode

pip install ptflops==0.7.2.2

@lan0011
Copy link

lan0011 commented Jun 26, 2024

@euminds please upgrade your torch version to 2.x if possible, or downgrade ptflops. torch 1.x does not support TorchDispatchMode

pip install ptflops==0.7.2.2

useful!(btw, with torch==1.11.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants