Skip to content

Conversation

@s4ayub
Copy link
Contributor

@s4ayub s4ayub commented Apr 7, 2022

Summary:
This flag is needed in the OSS example and it wasn't clear that it was needed because it wasn't explicitly used when linking to torch deploy for the tests.

Since torch deploy builds the tests using python setup.py develop, Pytorch actually sets this flag in the CMAKE_EXE_LINKER_FLAGS variable somewhere along the build. I had to print out all the variables used in the pytorch build to realize that I did not have this flag set in my OSS torch deploy example.

I think having it explicit for the tests makes it clear which flags are actually necessary in an open source environment.

What is -rdynamic?

This flag (also known as --export-dynamic at the linker level) signals that the library it is targeting should export its symbols to the dynamic table. In doing so, shared libraries that are opened using dlopen (which is what torch deploy uses to launch subinterpreters: https://www.internalfb.com/code/fbsource/[ff6d5cfcc2b3]/xplat/caffe2/torch/csrc/deploy/deploy.cpp?lines=254), will be able to reference symbols defined in the modules that launched them.

Without this flag, the symbols from the torch::deploy library that the subinterpreters need, remain undefined.

This leads to runtime errors like:

/tmp/torch_XYZ: undefined symbol - torch::deploy::Etc.

/tmp/torch_XYZ is a subinterpreter.

Test Plan:
Ran the tests in an OSS environment
python torch/csrc/deploy/example/generate_examples.py
./build/bin/test_deploy

Differential Revision: D35477135

Summary:
This flag is needed in the OSS example and it wasn't clear that it was needed because it wasn't explicitly used when linking to torch deploy for the tests.

 Since torch deploy builds the tests using `python setup.py develop`, Pytorch actually sets this flag in the `CMAKE_EXE_LINKER_FLAGS` variable somewhere along the build. I had to print out all the variables used in the pytorch build to realize that I did not have this flag set in my OSS torch deploy example.

I think having it explicit for the tests makes it clear which flags are actually necessary in an open source environment.

**What is -rdynamic?**

This flag (also known as `--export-dynamic` at the linker level) signals that the library it is targeting should export its symbols to the dynamic table. In doing so, shared libraries that are opened using `dlopen` (which is what torch deploy uses to launch subinterpreters: https://www.internalfb.com/code/fbsource/[ff6d5cfcc2b3]/xplat/caffe2/torch/csrc/deploy/deploy.cpp?lines=254), will be able to reference symbols defined in the modules that launched them.

Without this flag, the symbols from the  `torch::deploy` library that the subinterpreters need, remain `undefined`.

This leads to runtime errors like:

`/tmp/torch_XYZ: undefined symbol - torch::deploy::Etc.`

`/tmp/torch_XYZ` is a subinterpreter.

Test Plan:
Ran the tests in an OSS environment
`python torch/csrc/deploy/example/generate_examples.py`
`./build/bin/test_deploy`

Differential Revision: D35477135

fbshipit-source-id: 10b5bfb6f652f1703128d3b0c82b3785f8186558
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 7, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 868e9b6 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D35477135

@PaliC PaliC self-requested a review April 8, 2022 00:22
facebook-github-bot pushed a commit that referenced this pull request Apr 8, 2022
)

Summary:
Pull Request resolved: #75461

This flag is needed in the OSS example and it wasn't clear that it was needed because it wasn't explicitly used when linking to torch deploy for the tests.

 Since torch deploy builds the tests using `python setup.py develop`, Pytorch actually sets this flag in the `CMAKE_EXE_LINKER_FLAGS` variable somewhere along the build. I had to print out all the variables used in the pytorch build to realize that I did not have this flag set in my OSS torch deploy example.

I think having it explicit for the tests makes it clear which flags are actually necessary in an open source environment.

**What is -rdynamic?**

This flag (also known as `--export-dynamic` at the linker level) signals that the library it is targeting should export its symbols to the dynamic table. In doing so, shared libraries that are opened using `dlopen` (which is what torch deploy uses to launch subinterpreters: https://www.internalfb.com/code/fbsource/[ff6d5cfcc2b3]/xplat/caffe2/torch/csrc/deploy/deploy.cpp?lines=254), will be able to reference symbols defined in the modules that launched them.

Without this flag, the symbols from the  `torch::deploy` library that the subinterpreters need, remain `undefined`.

This leads to runtime errors like:

`/tmp/torch_XYZ: undefined symbol - torch::deploy::Etc.`

`/tmp/torch_XYZ` is a subinterpreter.

Test Plan:
Ran the tests in an OSS environment
`python torch/csrc/deploy/example/generate_examples.py`
`./build/bin/test_deploy`

Reviewed By: PaliC

Differential Revision: D35477135

fbshipit-source-id: 30bd2b9fadd36b2a32066a52cda5b746d597e99f
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2022

Hey @s4ayub.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants