openai / baselines

OpenAI Baselines: high-quality implementations of reinforcement learning algorithms
MIT License
15.64k stars 4.86k forks source link

ImportError: cannot import name '_check_onnx_proto' #1110

Open budfox3 opened 4 years ago

budfox3 commented 4 years ago

Hi, not sure I'm doing this right (first time), but I get the error message after installing pytorch and torchvision the following way:

conda install pytorch torchvision cpuonly -c pytorch


ImportError Traceback (most recent call last) u:\Private\Master Thesis\Online Classes\machine_learning_examples\unsupervised_class3\vae_pytorch.py in 7 8 from torch.utils.data import DataLoader ----> 9 import torchvision

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torchvision__init__.py in 1 import warnings 2 ----> 3 from torchvision import models 4 from torchvision import datasets 5 from torchvision import ops

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torchvision\models__init__.py in 10 from .shufflenetv2 import * 11 from . import segmentation ---> 12 from . import detection 13 from . import video 14 from . import quantization

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torchvision\models\detection__init__.py in ----> 1 from .faster_rcnn import 2 from .mask_rcnn import 3 from .keypoint_rcnn import *

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torchvision\models\detection\faster_rcnn.py in 5 import torch.nn.functional as F 6 ----> 7 from torchvision.ops import misc as misc_nn_ops 8 from torchvision.ops import MultiScaleRoIAlign 9

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torchvision\ops__init__.py in 11 from ._register_onnx_ops import _register_custom_op 12 ---> 13 _register_custom_op() 14 15

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torchvision\ops_register_onnx_ops.py in _register_custom_op() 6 7 def _register_custom_op(): ----> 8 from torch.onnx.symbolic_helper import parse_args, scalar_type_to_onnx, scalar_type_to_pytorch_type, \ 9 cast_pytorch_to_onnx 10 from torch.onnx.symbolic_opset9 import select, unsqueeze, squeeze, _cast_Long, reshape

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torch\onnx\symbolic_helper.py in 9 # This import monkey-patches graph manipulation methods on Graph, used for the 10 # ONNX symbolics ---> 11 import torch.onnx.utils 12 13 from functools import wraps

~\AppData\Local\Continuum\anaconda3\envs\gan_lecture\lib\site-packages\torch\onnx\utils.py in 19 from torch.jit import _unique_state_dict 20 from torch.onnx import ONNX_ARCHIVE_MODEL_PROTO_NAME, ExportTypes, OperatorExportTypes ---> 21 from torch._C import ListType, _propagate_and_assign_input_shapes, _assign_output_shapes, _check_onnx_proto 22 23

ImportError: cannot import name '_check_onnx_proto'


I'm using a conda env with python 3.6.10 / Windows 10

Name Version Build Channel

_pytorch_select 1.1.0 cpu absl-py 0.9.0 pypi_0 pypi astunparse 1.6.3 pypi_0 pypi attrs 19.3.0 py_0 backcall 0.1.0 py36_0 blas 1.0 mkl bleach 3.1.4 py_0 ca-certificates 2020.1.1 0 cachetools 4.1.0 pypi_0 pypi certifi 2020.4.5.1 py36_0 cffi 1.14.0 py36h7a1dbc1_0 chardet 3.0.4 py36_1003 colorama 0.4.3 py_0 cpuonly 1.0 0 pytorch cryptography 2.9.2 py36h7a1dbc1_0 cycler 0.10.0 py36h009560c_0 decorator 4.4.2 py_0 defusedxml 0.6.0 py_0 entrypoints 0.3 py36_0 freetype 2.9.1 ha9979f8_1 gast 0.3.3 pypi_0 pypi google-auth 1.14.3 pypi_0 pypi google-auth-oauthlib 0.4.1 pypi_0 pypi google-pasta 0.2.0 pypi_0 pypi graphviz 2.38 hfd603c8_2 grpcio 1.28.1 pypi_0 pypi h5py 2.10.0 pypi_0 pypi icc_rt 2019.0.0 h0cc432a_1 icu 58.2 ha925a31_3 idna 2.9 py_1 imageio 2.8.0 py_0 importlib_metadata 1.5.0 py36_0 intel-openmp 2020.1 216 ipykernel 5.1.4 py36h39e3cac_0 ipython 7.13.0 py36h5ca1d4c_0 ipython_genutils 0.2.0 py36_0 jedi 0.17.0 py36_0 jinja2 2.11.2 py_0 jpeg 9b hb83a4c4_2 jsonschema 3.2.0 py36_0 jupyter_client 6.1.3 py_0 jupyter_core 4.6.3 py36_0 keras 2.3.1 pypi_0 pypi keras-applications 1.0.8 pypi_0 pypi keras-preprocessing 1.1.2 pypi_0 pypi kiwisolver 1.2.0 py36h74a9793_0 libgpuarray 0.7.6 hfa6e2cd_0 libpng 1.6.37 h2a8f88b_0 libpython 2.1 py36_0 libsodium 1.0.16 h9d3ae62_0 libtiff 4.1.0 h56a325e_0 m2w64-binutils 2.25.1 5 m2w64-bzip2 1.0.6 6 m2w64-crt-git 5.0.0.4636.2595836 2 m2w64-gcc 5.3.0 6 m2w64-gcc-ada 5.3.0 6 m2w64-gcc-fortran 5.3.0 6 m2w64-gcc-libgfortran 5.3.0 6 m2w64-gcc-libs 5.3.0 7 m2w64-gcc-libs-core 5.3.0 7 m2w64-gcc-objc 5.3.0 6 m2w64-gmp 6.1.0 2 m2w64-headers-git 5.0.0.4636.c0ad18a 2 m2w64-isl 0.16.1 2 m2w64-libiconv 1.14 6 m2w64-libmangle-git 5.0.0.4509.2e5a9a2 2 m2w64-libwinpthread-git 5.0.0.4634.697f757 2 m2w64-make 4.1.2351.a80a8b8 2 m2w64-mpc 1.0.3 3 m2w64-mpfr 3.1.4 4 m2w64-pkg-config 0.29.1 2 m2w64-toolchain 5.3.0 7 m2w64-tools-git 5.0.0.4592.90b8472 2 m2w64-windows-default-manifest 6.4 3 m2w64-winpthreads-git 5.0.0.4634.697f757 2 m2w64-zlib 1.2.8 10 mako 1.1.2 py_0 markdown 3.2.2 pypi_0 pypi markupsafe 1.1.1 py36he774522_0 matplotlib 3.1.3 py36_0 matplotlib-base 3.1.3 py36h64f37c6_0 mistune 0.8.4 py36he774522_0 mkl 2020.1 216 mkl-service 2.3.0 py36hb782905_0 mkl_fft 1.0.15 py36h14836fe_0 mkl_random 1.1.0 py36h675688f_0 msys2-conda-epoch 20160418 1 nbconvert 5.6.1 py36_0 nbformat 5.0.6 py_0 ninja 1.9.0 py36h74a9793_0 notebook 6.0.3 py36_0 numpy 1.18.1 py36h93ca92e_0 numpy-base 1.18.1 py36hc3f5095_1 oauthlib 3.1.0 pypi_0 pypi olefile 0.46 py36_0 openssl 1.1.1g he774522_0 opt-einsum 3.2.1 pypi_0 pypi pandoc 2.2.3.2 0 pandocfilters 1.4.2 py36_1 parso 0.7.0 py_0 pickleshare 0.7.5 py36_0 pillow 7.1.2 py36hcc1f983_0 pip 20.0.2 py36_3 prometheus_client 0.7.1 py_0 prompt-toolkit 3.0.4 py_0 prompt_toolkit 3.0.4 0 protobuf 3.11.3 pypi_0 pypi pyasn1 0.4.8 pypi_0 pypi pyasn1-modules 0.2.8 pypi_0 pypi pycparser 2.20 py_0 pydot 1.4.1 pypi_0 pypi pydot-ng 2.0.0 pypi_0 pypi pygments 2.6.1 py_0 pygpu 0.7.6 py36h452e1ab_0 pyopenssl 19.1.0 py36_0 pyparsing 2.4.7 py_0 pyqt 5.9.2 py36h6538335_2 pyrsistent 0.16.0 py36he774522_0 pysocks 1.7.1 py36_0 python 3.6.10 h9f7ef89_2 python-dateutil 2.8.1 py_0 python-graphviz 0.14 py_0 pytorch 1.5.0 py3.6_cpu_0 [cpuonly] pytorch pytz 2020.1 py_0 pywin32 227 py36he774522_1 pywinpty 0.5.7 py36_0 pyyaml 5.3.1 pypi_0 pypi pyzmq 18.1.1 py36ha925a31_0 qt 5.9.7 vc14h73c81de_0 requests 2.23.0 py36_0 requests-oauthlib 1.3.0 pypi_0 pypi rsa 4.0 pypi_0 pypi scipy 1.4.1 py36h9439919_0 seaborn 0.10.1 pypi_0 pypi send2trash 1.5.0 py36_0 setuptools 46.2.0 py36_0 sip 4.19.8 py36h6538335_0 six 1.14.0 py36_0 sqlite 3.31.1 h2a8f88b_1 tensorboard 2.2.1 pypi_0 pypi tensorboard-plugin-wit 1.6.0.post3 pypi_0 pypi tensorflow 2.2.0 pypi_0 pypi tensorflow-estimator 2.2.0 pypi_0 pypi termcolor 1.1.0 pypi_0 pypi terminado 0.8.3 py36_0 testpath 0.4.4 py_0 theano 1.0.4 py36_0 tk 8.6.8 hfa6e2cd_0 torchvision 0.6.0 py36_cpu [cpuonly] pytorch tornado 6.0.4 py36he774522_1 tqdm 4.46.0 py_0 traitlets 4.3.3 py36_0 urllib3 1.25.8 py36_0 vc 14.1 h0510ff6_4 vs2015_runtime 14.16.27012 hf0eaf9b_1 wcwidth 0.1.9 py_0 webencodings 0.5.1 py36_1 werkzeug 1.0.1 pypi_0 pypi wheel 0.34.2 py36_0 win_inet_pton 1.1.0 py36_0 wincertstore 0.2 py36h7fe50ca_0 winpty 0.4.3 4 xz 5.2.5 h62dcd97_0 zeromq 4.3.1 h33f27b4_3 zipp 3.1.0 py_0 zlib 1.2.11 h62dcd97_4 zstd 1.3.7 h508b16e_0

JayThibs commented 3 years ago

Same issue with

conda install torchvision -c pytorch

but this isn't an openai issue.

JayThibs commented 3 years ago

I was able to resolve the issue by installing with the following command:

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 torchtext==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

so, I'm guessing you should be able to resolve the issue with the same versions, but remove +cu110 and adding +cpu. This command should work:

pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.2 torchtext==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

edit: just noticed that this was posted in 2020, but I'll leave this here in case somebody else comes across it.