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

Uniformly apply Windows logic in cpp_extensions everywhere #31161

Closed
wants to merge 13 commits into from

Conversation

ezyang
Copy link
Contributor

@ezyang ezyang commented Dec 12, 2019

Stack from ghstack:

Previously, it wasn't necessary to specify DT_NEEDED in C++ extensions on Linux (aka pass -l flags) because all of the symbols would have already been loaded with RTLD_GLOBAL, so there wouldn't be any undefined symbols. But when we switch to loading _C with RTLD_LOCAL, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang ezyang@fb.com

Differential Revision: D19262578

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
@kostmo
Copy link
Member

kostmo commented Dec 12, 2019

💊 CircleCI build failures summary and remediations

As of commit 8a6d169:

  • 1/3 failures introduced in this PR
  • 2/3 recognized as flaky ❄️
    • Re-run these jobs?

Detailed failure analysis

One may explore the probable reasons each build failed interactively on the Dr. CI website.

❄️ 2 failures recognized as flaky

The following build failures have been detected as flaky and may not be your fault:

See CircleCI build pytorch_macos_10_13_py3_test (1/2)

Step: "Test" (full log | pattern match details) ❄️

Jan 08 12:46:26 RuntimeError: test_quantized_nn_mods failed! Received signal: SIGSEGV
Jan 08 12:46:22 Generating XML reports... 
Jan 08 12:46:22 Running test_quantized_nn_mods ... [2020-01-08 12:46:22.980646] 
Jan 08 12:46:23  
Jan 08 12:46:23 Running tests... 
Jan 08 12:46:23 ---------------------------------------------------------------------- 
Jan 08 12:46:26 s...Traceback (most recent call last): 
Jan 08 12:46:26   File "test/run_test.py", line 456, in <module> 
Jan 08 12:46:26     main() 
Jan 08 12:46:26   File "test/run_test.py", line 449, in main 
Jan 08 12:46:26     raise RuntimeError(message) 
Jan 08 12:46:26 RuntimeError: test_quantized_nn_mods failed! Received signal: SIGSEGV 
Jan 08 12:46:26 + cleanup 
Jan 08 12:46:26 + retcode=1 
Jan 08 12:46:26 + set +x 

See CircleCI build pytorch_linux_xenial_cuda9_cudnn7_py3_NO_AVX_NO_AVX2_test (2/2)

Step: "Test" (full log | pattern match details) ❄️

Jan 08 21:07:23 AssertionError: 1024 not less than or equal to 1e-05 : __main__.TestAutogradDeviceTypeCUDA.test_logdet_1x1_cuda leaked 1024 bytes CUDA memory on device 0
Jan 08 21:07:23 ====================================================================== 
Jan 08 21:07:23 FAIL [0.118s]: test_logdet_1x1_cuda (__main__.TestAutogradDeviceTypeCUDA) 
Jan 08 21:07:23 ---------------------------------------------------------------------- 
Jan 08 21:07:23 Traceback (most recent call last): 
Jan 08 21:07:23   File "/var/lib/jenkins/workspace/test/common_utils.py", line 676, in wrapper 
Jan 08 21:07:23     method(*args, **kwargs) 
Jan 08 21:07:23   File "/var/lib/jenkins/workspace/test/common_utils.py", line 532, in __exit__ 
Jan 08 21:07:23     self.name, after - before, i)) 
Jan 08 21:07:23   File "/var/lib/jenkins/workspace/test/common_utils.py", line 888, in assertEqual 
Jan 08 21:07:23     super(TestCase, self).assertLessEqual(abs(x - y), prec, message) 
Jan 08 21:07:23 AssertionError: 1024 not less than or equal to 1e-05 : __main__.TestAutogradDeviceTypeCUDA.test_logdet_1x1_cuda leaked 1024 bytes CUDA memory on device 0 
Jan 08 21:07:23  
Jan 08 21:07:23 ---------------------------------------------------------------------- 
Jan 08 21:07:23 Ran 1885 tests in 891.537s 
Jan 08 21:07:23  
Jan 08 21:07:23 FAILED (failures=1, skipped=13, expected failures=1) 
Jan 08 21:07:23  
Jan 08 21:07:23 Generating XML reports... 
Jan 08 21:07:24 Traceback (most recent call last): 
Jan 08 21:07:24   File "test/run_test.py", line 456, in <module> 
Jan 08 21:07:24     main() 

1 failure not recognized by patterns:

Job Step Status
CircleCI pytorch_linux_backward_compatibility_check_test Test New in PR

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 26 times.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
@ezyang ezyang changed the title Actually get rid of Windows hacks in cpp_extensions. Uniformly apply Windows logic in cpp_extensions everywhere Dec 14, 2019
Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

[ghstack-poisoned]
@ezyang ezyang requested a review from yf225 January 2, 2020 14:33
Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D19262578](https://our.internmc.facebook.com/intern/diff/D19262578)

[ghstack-poisoned]
Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D19262578](https://our.internmc.facebook.com/intern/diff/D19262578)

[ghstack-poisoned]
Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D19262578](https://our.internmc.facebook.com/intern/diff/D19262578)

[ghstack-poisoned]
Copy link
Member

@soumith soumith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D19262578](https://our.internmc.facebook.com/intern/diff/D19262578)

[ghstack-poisoned]
Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D19262578](https://our.internmc.facebook.com/intern/diff/D19262578)

[ghstack-poisoned]
@yf225 yf225 requested a review from peterjc123 January 8, 2020 12:57
@yf225
Copy link
Contributor

yf225 commented Jan 8, 2020

@peterjc123 Would you like to take a look?

libraries.append('_C')
libraries.append('c10')
libraries.append('c10_cuda')
libraries.append('torch')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is torch here used for? The functions should be in torch_cpu and torch_cuda, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's supposed to be an empty library. I put torch in here for "good luck", in case someone ever accidentally puts some symbols in it.


libraries = kwargs.get('libraries', [])
libraries.append('c10')
libraries.append('torch')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here?

extra_ldflags.append('-ltorch_cpu')
if with_cuda:
extra_ldflags.append('-ltorch_cuda')
extra_ldflags.append('-ltorch')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here?

Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Differential Revision: [D19262578](https://our.internmc.facebook.com/intern/diff/D19262578)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@ezyang merged this pull request in 8614860.

@facebook-github-bot facebook-github-bot deleted the gh/ezyang/579/head branch January 13, 2020 15:39
xxtEchjovs44 pushed a commit to xxtEchjovs44/pytorch that referenced this pull request Jan 29, 2020
Signed-off-by: Edward Z. Yang <ezyang@fb.com>

ghstack-source-id: 77b5ed9aa069925703ede06a23b268084347436f
Pull Request resolved: pytorch/pytorch#31161
xxtEchjovs44 pushed a commit to xxtEchjovs44/pytorch that referenced this pull request Jan 29, 2020
Signed-off-by: Edward Z. Yang <ezyang@fb.com>

ghstack-source-id: 98f3dbeb0958d541e2b72e210097a42f1d10e046
Pull Request resolved: pytorch/pytorch#31161
wuhuikx pushed a commit to wuhuikx/pytorch that referenced this pull request Jan 30, 2020
…1161)

Summary:
Pull Request resolved: pytorch#31161

Previously, it wasn't necessary to specify `DT_NEEDED` in C++ extensions on Linux (aka pass `-l` flags) because all of the symbols would have already been loaded with `RTLD_GLOBAL`, so there wouldn't be any undefined symbols.  But when we switch to loading `_C` with `RTLD_LOCAL`, it's now necessary for all the C++ extensions to know what libraries to link with. The resulting code is clearer and more uniform, so it's wins all around.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Differential Revision: D19262578

Pulled By: ezyang

fbshipit-source-id: a893cc96f2e9aad1c064a6de4f7ccf79257dec3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants