Skip to content

add torch/lib subdirectory in Python lib dir to $LD_LIBRARY_PATH for PyTorch installations#2183

Merged
akesandgren merged 1 commit intoeasybuilders:developfrom
Flamefire:pytorch_ld_library_path
Sep 23, 2020
Merged

add torch/lib subdirectory in Python lib dir to $LD_LIBRARY_PATH for PyTorch installations#2183
akesandgren merged 1 commit intoeasybuilders:developfrom
Flamefire:pytorch_ld_library_path

Conversation

@Flamefire
Copy link
Copy Markdown
Contributor

@Flamefire Flamefire commented Sep 22, 2020

This is the replacement for what was in previous ECs: postinstallcmds = ['cp -a %(builddir)s/%(namelower)s-%(version)s/torch/lib*/* %(installdir)s/lib/'] and fixes issues with loading libcaffe2_nvrtc.so which is loaded via dlopen from PyTorch.

Reproducible with python -c "import ctypes; ctypes.CDLL('libcaffe2_nvrtc.so')" although that is not what is the "official" way. That seems to be JIT compiling some code for CUDA kernels for which I couldn't find how to specifically do that. In case someone knows how to do that that would be good to add to the test cases.

Setting the LD_LIBRARY_PATH is also what Pytorch itself does in at least one of its CI tests

@Flamefire
Copy link
Copy Markdown
Contributor Author

Tested with PyTorch/1.4.0-fosscuda-2019b-Python-3.7.4 and the above command works

Copy link
Copy Markdown
Contributor

@akesandgren akesandgren left a comment

Choose a reason for hiding this comment

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

LGTM

@akesandgren
Copy link
Copy Markdown
Contributor

Going in, thanks @Flamefire!

@akesandgren akesandgren merged commit 975f6c9 into easybuilders:develop Sep 23, 2020
@Flamefire Flamefire deleted the pytorch_ld_library_path branch September 23, 2020 08:56
@boegel boegel changed the title Set LD_LIBRARY_PATH to PyTorch lib folder add torch/lib subdirectory in Python lib dir to $LD_LIBRARY_PATH for PyTorch installations Sep 23, 2020
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.

2 participants