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 'DisableTorchFunctionSubclass' from 'torch._C' #7126

Closed
lukazso opened this issue Jan 25, 2023 · 4 comments
Closed

Comments

@lukazso
Copy link

lukazso commented Jan 25, 2023

🐛 Describe the bug

Hi all,

I was recently trying to install torchvision from the main branch to include the prototype features. I followed the install procedure specified on the contributor page:

pip install numpy
pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu117/torch_nightly.html

git clone https://github.com/pytorch/vision.git
cd vision
python setup.py develop
pip install flake8 typing mypy pytest pytest-mock scipy

However, when I try to import the protoype features, I run into following problem:

>>> from torchvision.prototype import datapoints, transforms as T
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/vision/torchvision/prototype/__init__.py", line 1, in <module>
    from . import datapoints, models, transforms, utils
  File "/vision/torchvision/prototype/datapoints/__init__.py", line 1, in <module>
    from ._bounding_box import BoundingBox, BoundingBoxFormat
  File "/vision/torchvision/prototype/datapoints/_bounding_box.py", line 9, in <module>
    from ._datapoint import Datapoint, FillTypeJIT
  File "/vision/torchvision/prototype/datapoints/_datapoint.py", line 8, in <module>
    from torch._C import DisableTorchFunctionSubclass
ImportError: cannot import name 'DisableTorchFunctionSubclass' from 'torch._C' (/usr/local/lib/python3.8/dist-packages/torch/_C.cpython-38-x86_64-linux-gnu.so)

I tried it in a virtual environment as well as a Docker container, both the same results.

Versions

Environment in Docker:

PyTorch version: 1.13.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31

Python version: 3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-50-generic-x86_64-with-glibc2.29
Is CUDA available: False
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy==0.991
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.24.1
[pip3] torch==1.13.1
[pip3] torchvision==0.15.0a0+5dd9594
[conda] Could not collect

Environment on local machine in virtual environment:

Collecting environment information...
PyTorch version: 1.13.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31

Python version: 3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-50-generic-x86_64-with-glibc2.29
Is CUDA available: True
CUDA runtime version: 11.7.64
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: Tesla V100-DGXS-32GB
GPU 1: Tesla V100-DGXS-32GB
GPU 2: Tesla V100-DGXS-32GB
GPU 3: Tesla V100-DGXS-32GB

Nvidia driver version: 470.141.03
cuDNN version: Probably one of the following:
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn.so.8.4.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.4.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.4.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.4.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.4.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.4.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.4.1
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy==0.991
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.24.1
[pip3] torch==1.13.1
[pip3] torchvision==0.15.0a0+d2d448c
[conda] Could not collect

I am not sure if this has to do with the installation procedure from my side or if this is a general thing. Any help would be appreciated!

Thanks
Lukas

@NicolasHug
Copy link
Member

Hi @lukazso

[pip3] torch==1.13.1

I suspect this is the problem: you're actually not using the nightly version (which should look like 2.0.dev....

You used:

pip install --pre torch -f https://download.pytorch.org/whl/nightly/cu117/torch_nightly.html

But the official installation instruction suggest

pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu117

Perhaps try these?


Side note: which prototype features are you interested in? If it's about the new transforms, please feel free to provide any feedback you may have in this thread #6753 ! It will help us provide the best user experience.

@lukazso
Copy link
Author

lukazso commented Jan 25, 2023

Thanks @NicolasHug for the quick feedback! This was indeed the problem. I am also closely following the thread regarding the new transforms (really cool feature).

However, now I encounter the following:

>>> from torchvision.prototype import datapoints, transforms as T
/home/user/project/vision/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: libnvjpeg.so.11: cannot open shared object file: No such file or directory
  warn(f"Failed to load image Python extension: {e}")

This looks similar to me as #7104. I already installed the additional libraries:

sudo apt install libjpeg-turbo8 libjpeg-turbo8-dev \
libpng16-16 libpng-tools libpng-dev

Also, I reinstalled torchvision from the repo again after installing the additional libraries.

Is there still something wrong with my installation?

@NicolasHug
Copy link
Member

nvjpeg is the nvidia lib for jpeg decoding (unrelated to libjpeg-turbo / libjpeg). I'm not sure why it's not present on your system, it could be another problem with your env. If you don't need GPU-decoding of jpegs (you probably don't), you should be able to bypass the problem by setting TORCHVISION_USE_NVJPEG=0 before building torchvision

@Subhankhan41
Copy link

Hi,

I tried using nightly as well but I am still struggling to use from torchvision.prototype import datapoints or simply from torchvision import datapoints. Any fix to it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants