Closed wm901115nwpu closed 1 year ago
Hi @wm901115nwpu can you please share the code snippet you tried to run?
╭─ ~/workspace ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ pt2 08:19:13 上午 ─╮ ╰─ python ─╯ Python 3.10.11 (main, May 17 2023, 14:30:36) [Clang 14.0.6 ] on darwin Type "help", "copyright", "credits" or "license" for more information.
import torchvision Traceback (most recent call last): File "
", line 1, in File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torchvision/init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torchvision/_meta_registrations.py", line 100, in def meta_nms(dets, scores, iou_threshold): File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torch/library.py", line 417, in inner handle = entry.abstract_impl.register(func, source) File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torch/_library/abstract_impl.py", line 30, in register if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"): RuntimeError: operator torchvision::nms does not exist
Do import torch
first?
─ ~/workspace ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ 8m 37s pt2 08:27:53 上午 ─╮ ╰─ python ─╯ Python 3.10.11 (main, May 17 2023, 14:30:36) [Clang 14.0.6 ] on darwin Type "help", "copyright", "credits" or "license" for more information.
import torch import torchvision Traceback (most recent call last): File "
", line 1, in File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torchvision/init.py", line 6, in from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torchvision/_meta_registrations.py", line 100, in def meta_nms(dets, scores, iou_threshold): File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torch/library.py", line 417, in inner handle = entry.abstract_impl.register(func, source) File "/Users/unicorn/miniconda3/envs/pt2/lib/python3.10/site-packages/torch/_library/abstract_impl.py", line 30, in register if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"): RuntimeError: operator torchvision::nms does not exist
same error
Did you try to build form source? Or install the nightlies
the error is that I use pytorch and torchvision building from source, I use nightly version import is OK.I guess pytorch the source is something wrong.
Hm yeah, it looks like something is going wrong when you build pytorch from source then
I try to delete build folder, rebuild it
I update torchvision and torch from source, rebuild, import is OK。
I'm seeing the same issue on my end building from latest main from both torch and torchvision. I suspect that it has something to do with this change https://github.com/pytorch/pytorch/pull/113182. Nightly CPU build works fine.
The issue is indeed fixed when doing a clean build
hey @huydhn @NicolasHug
i'm seeing it on the latest torch version (2.2.0) + torchvision 0.17.0
$ virtualenv venv-p python3.11
$ source venv/bin/activate
$ pip install torch==2.2.0 --index-url https://download.pytorch.org/whl/cpu
$ pip install torchvision
$ pip show torchvision
Name: torchvision
Version: 0.17.0
Summary: image and video datasets and models for torch deep learning
Home-page: https://github.com/pytorch/vision
Author: PyTorch Core Team
Author-email: soumith@pytorch.org
License: BSD
Location: /tmp/venv/lib/python3.11/site-packages
Requires: numpy, pillow, requests, torch
Required-by:
$ python -c "import torchvision;print('Pytorch vision version: ', torchvision.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/venv/lib/python3.11/site-packages/torchvision/__init__.py", line 6, in <module>
from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
File "/tmp/venv/lib/python3.11/site-packages/torchvision/_meta_registrations.py", line 163, in <module>
@torch._custom_ops.impl_abstract("torchvision::nms")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/venv/lib/python3.11/site-packages/torch/library.py", line 440, in inner
handle = entry.abstract_impl.register(func_to_register, source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/venv/lib/python3.11/site-packages/torch/_library/abstract_impl.py", line 30, in register
if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: operator torchvision::nms does not exist
installing torchvision from pytorch index it's fine
$ virtualenv venv-p python3.11
$ source venv/bin/activate
$ pip install torch==2.2.0 torchvision --index-url https://download.pytorch.org/whl/cpu
Name: torchvision
Version: 0.17.0+cpu
Summary: image and video datasets and models for torch deep learning
Home-page: https://github.com/pytorch/vision
Author: PyTorch Core Team
Author-email: soumith@pytorch.org
License: BSD
Location: /tmp/venv/lib/python3.11/site-packages
Requires: numpy, pillow, requests, torch
Required-by:
$ python -c "import torchvision;print('Pytorch vision version: ', torchvision.__version__)"
Pytorch vision version: 0.17.0+cpu
I think this is kind of expected. Both pip install torch==2.2.0 torchvision
or pip install torch==2.2.0 torchvision --index-url https://download.pytorch.org/whl/cpu
work because torch and torchvision versions are compatible. The first command install torch and vision built with CUDA 12.1 support while the latter install their versions with only CPU support. Mixing them leads to the above failure because you will have torch built with only CPU support while torchvision from PyPI is compatible with only the torch CUDA 12.1.
Also, this works too proving torchvision from PyPI is built with CUDA 12.1:
pip install torch --index-url https://download.pytorch.org/whl/cu121
pip install torchvision
oki, yep I knew about the mix-up of cpu/cuda, but in previous versions it wasn't much of a problem to mix the two.
🐛 Describe the bug
Versions
Collecting environment information... PyTorch version: 2.2.0a0+git2d5fec4 Is debug build: True CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A
OS: macOS 14.1 (arm64) GCC version: Could not collect Clang version: 17.0.4 CMake version: version 3.26.4 Libc version: N/A
Python version: 3.10.11 (main, May 17 2023, 14:30:36) [Clang 14.0.6 ] (64-bit runtime) Python platform: macOS-14.1-arm64-arm-64bit Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True
CPU: Apple M2 Pro
Versions of relevant libraries: [pip3] iree-torch==0.0.1 [pip3] memory-efficient-attention-pytorch==0.1.6 [pip3] numpy==1.24.3 [pip3] onnx==1.16.0 [pip3] onnx-graphsurgeon==0.3.26 [pip3] onnx-tool==0.6.4 [pip3] onnxconverter-common==1.14.0 [pip3] onnxoptimizer==0.3.17 [pip3] onnxruntime-extensions==0.10.0+2cf9bab [pip3] onnxruntime-silicon==1.16.0 [pip3] onnxscript==0.1.0.dev20231021 [pip3] onnxsim==0.4.33 [pip3] skl2onnx==1.15.0 [pip3] torch==2.2.0a0+git98564d2 [pip3] torch-mlir==0.0.1 [pip3] torchaudio==2.2.0a0+6e26515 [pip3] torchdata==0.7.0a0+ce07539 [pip3] torchinfo==1.8.0 [pip3] torchvision==0.17.0a0+209b2b3 [conda] iree-torch 0.0.1 pypi_0 pypi [conda] memory-efficient-attention-pytorch 0.1.6 pypi_0 pypi [conda] numpy 1.24.3 pypi_0 pypi [conda] torch 2.2.0a0+git98564d2 pypi_0 pypi [conda] torch-mlir 0.0.1 pypi_0 pypi [conda] torchaudio 2.2.0a0+6e26515 pypi_0 pypi [conda] torchdata 0.7.0a0+ce07539 pypi_0 pypi [conda] torchinfo 1.8.0 pypi_0 pypi [conda] torchvision 0.17.0a0+209b2b3 pypi_0 pypi