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

Latest pyyaml expecting class but getting function #840

Open
squeakus opened this issue Mar 16, 2019 · 7 comments

Comments

@squeakus
Copy link

@squeakus squeakus commented Mar 16, 2019

Hi,
I am not sure if the issue is with you or pyyaml but I just completed a clean build and get the following error when running infer_simple.py example with pyyaml version 5.1

yaml.constructor.ConstructorError: while constructing a Python instance expected a class, but found <class 'builtin_function_or_method'> in "<unicode string>", line 3, column 20: BBOX_XFORM_CLIP: !!python/object/apply:numpy.core ...

I rolled the version back to 4.2 and it works fine:
pip install pyyaml==4.2b2

System information

  • Operating system: 18.04
  • Compiler version: 3.6
  • CUDA version: 10
  • cuDNN version: 9
  • NVIDIA driver version: 415
  • GPU models (for all devices if they are not all the same): 1080ti
  • PYTHONPATH environment variable: NA
  • python --version output: 3.6.7
  • Anything else that seems relevant: ?
@matthhan

This comment has been minimized.

Copy link

@matthhan matthhan commented Mar 31, 2019

I encountered the same error and solved the problem by changing
yaml_load = yaml.load
to
yaml_load = lambda x: yaml.load(x, Loader=yaml.Loader)
in detectron/utils/env.py
Not sure if this is a valid solution in every case, because yaml.load might be used elsewhere in the codebase. However, in my case this was a good workaround.

@yaceben

This comment has been minimized.

Copy link

@yaceben yaceben commented Apr 3, 2019

@matthhan solved it for me. Thanks!

@ZhongYingMatrix

This comment has been minimized.

Copy link

@ZhongYingMatrix ZhongYingMatrix commented Apr 10, 2019

I encountered the same error and solved the problem by changing
yaml_load = yaml.load
to
yaml_load = lambda x: yaml.load(x, Loader=yaml.Loader)
in detectron/utils/env.py
Not sure if this is a valid solution in every case, because yaml.load might be used elsewhere in the codebase. However, in my case this was a good workaround.

It really works!! Thx ~

@haoransh

This comment has been minimized.

Copy link

@haoransh haoransh commented Apr 20, 2019

Another workaround is to roll back the pyyaml to 3.12 version, since the detectron seems built on that version initially. A similar problem is in facebookresearch/DensePose#216

whitesockcat added a commit to whitesockcat/FlagsDetection that referenced this issue May 11, 2019
@SuperMisswei

This comment has been minimized.

Copy link

@SuperMisswei SuperMisswei commented Jul 18, 2019

I get the same error but my pyyaml=3.12 , i need help.

System information
Operating system: 16.04
Compiler version: 2.7
CUDA version: 9

@SuperMisswei

This comment has been minimized.

Copy link

@SuperMisswei SuperMisswei commented Jul 19, 2019

Hi,
I am not sure if the issue is with you or pyyaml but I just completed a clean build and get the following error when running infer_simple.py example with pyyaml version 5.1

yaml.constructor.ConstructorError: while constructing a Python instance expected a class, but found <class 'builtin_function_or_method'> in "<unicode string>", line 3, column 20: BBOX_XFORM_CLIP: !!python/object/apply:numpy.core ...

I rolled the version back to 4.2 and it works fine:
pip install pyyaml==4.2b2

System information

  • Operating system: 18.04
  • Compiler version: 3.6
  • CUDA version: 10
  • cuDNN version: 9
  • NVIDIA driver version: 415
  • GPU models (for all devices if they are not all the same): 1080ti
  • PYTHONPATH environment variable: NA
  • python --version output: 3.6.7
  • Anything else that seems relevant: ?

hello ,I want to know how do you compile your caffe2 with cuda10. Looking forward to your reply.

facebook-github-bot added a commit that referenced this issue Jul 25, 2019
Summary:
I found that newer version of pyyaml cause error while parsing yaml files. Fix the pyyaml version can solve this problem.
Reference issue: #840
Pull Request resolved: #922

Reviewed By: rbgirshick

Differential Revision: D16483989

Pulled By: ir413

fbshipit-source-id: 427013e8fd045184401b5669af18314d5e8ecba1
@manyaafonso

This comment has been minimized.

Copy link

@manyaafonso manyaafonso commented Oct 18, 2019

I am sharing my experience in case it helps someone: I had the same issue on a computer with Ubuntu 16.04, Cuda 9.0, Python 3.7. We tried the suggestions from the first two posts, and tried forcing installation of PyYAML 3.12, to no avail. On checking the lines from config.py where the error occurred, we realized that the config.py in the docker container was an older version than the one downloaded using git clone (!?!). On copying the latest version to the docker container, along with the changes in env.py in @matthhan 's post, we were able to get it to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.