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
Static linking master bug #21737
Comments
|
cc @marchss |
|
cc @Palmitoxico |
|
Hi @ezyang , I'm wondering if this issue is fixed in 1.2 release? I have experienced this issue in runtime after building libtorch in a totally different building environment with static linking. However, specifying dynamic linking works like a charm. btw, the error message is like |
|
We haven't explicitly fixed this, but the mobile work done recently has made the state of static linking better on master. I haven't checked how many of the issues I've listed here are still a problem. The error message you're seeing looks consistent with the static initializers being pruned away. Try the suggested |
|
Any update on this ? |
|
Hey, Trying to build the static libraries from PyTorch 1.5rc1 release branch I have added PyTorch as a submodule of my project and then updated the my None of the lines mentioned in the diff of the OP of this issue were there so I ignored that step, maybe related to @ezyang's most recent comment in this issue? Next I configure the build with which results in an error I have uploaded the file It seems unable to find pthreads and AVX both of which I'm pretty sure should be available? |
|
Have you managed to successfully compile a non-statically-linked version of PyTorch? The logs you posted strongly suggest you are missing some relevant devel libraries. |
|
Not yet, though a little further :) I built a docker container to run the build and managed to get the configure to work within that. I had to modify this line Will changing and then during build I am getting this error Maybe related to #16444? I have tried re running cmake several times but it hasn't worked yet. Might have a go at using ninja instead of CMake tomorrow though I am not sure if this will be compatible with the JUCE stuff. Open to other suggestions though! Thanks |
|
Same issue with ninja |
|
If you can't build a normal version of PyTorch then the problem is probably not static linking related. I'd post in https://discuss.pytorch.org/ with a more detailed description of how you are setting up your build environment and look for help. Normal build of PyTorch should be working without any problems and it is almost certainly an environment problem. |
|
Normal build works fine, I have created a repo to reproduce the issue Should I still move to the forum? |
|
Top of master fails with a tensorpipe dependency on libuv: -- Configuring done |
also have this issue when building libtorch from source, |
|
@b93901190 update your repo and try again: git submodule sync
git submodule update --init --recursive |
I tried this for the v1.6.0 branch and I still get this error: |
I tried |
|
I am able to build it, but I get linker errors on runtime with my application |
ezyang commentedJun 13, 2019
•
edited
Statically linking PyTorch doesn't work (well). This master bug is to track all of the individual bugs related to this problem, as well as record up-to-date instructions for how to do static linking on master.
Blockers:
libtorch.ais not generated, even when building with-DBUILD_SHARED_LIBS=OFFcaffe2::mklwith-Wl,--no-as-needed)-Wl,--whole-archive)Other issues:
-DUSE_MKLDNN=OFF)How to create a statically linked executable as of 5a7e2cc aka Jun 13 (WORK IN PROGRESS: these instructions use hacks; as we fix the build process, these instructions will change. Our current general strategy will be to edit PyTorch's top-level CMakeLists.txt to add the build rules for the binary we want to build, and then build do a "normal" static library build.)
CMakeLists.txtin top-level PyTorch and add cmake rules for the binary you want to build. The rules I have quoted here contain workarounds for a number of bugs in our build:A pretty good
example-app.cppmight be:Also, apply this patch:
mkdir buildand cd into it.cmake -GNinja -DBUILD_SHARED_LIBS=OFF -DUSE_MKLDNN=OFF ..(if it can't run the code gen script, add-DPYTHON_EXECUTABLE=$(which python)) (make works too, but ninja is better from a recompilation avoidance perspective)ninja example-appbuild/bin/example-app. Here is my ldd output:The text was updated successfully, but these errors were encountered: