Skip to content

Fix NCU profiling under Buck PAR via KERNEL_PROFILER_PYTHON#137

Merged
Jack-Khuu merged 1 commit into
mainfrom
wychi/fix_ncu_with_buck_par
May 19, 2026
Merged

Fix NCU profiling under Buck PAR via KERNEL_PROFILER_PYTHON#137
Jack-Khuu merged 1 commit into
mainfrom
wychi/fix_ncu_with_buck_par

Conversation

@wychi

@wychi wychi commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary:
NCU profiling subprocesses failed inside a Buck PAR with:

ImportError: .../platform010/lib/python3.12/lib-dynload/_posixsubprocess.cpython-312-x86_64-linux-gnu.so:
undefined symbol: _Py_NoneStruct
ModuleNotFoundError: No module named 'torch'

Root cause: inside a PAR, sys.executable points at the static-linked native-main binary. Re-exec'ing it from a subprocess skips the env setup that bootstrap.sh performs (LD_LIBRARY_PATH for CUDA, LD_PRELOAD for the allocator, PYTHONPATH/FB_PAR* for the embedded import system), so the spawned Python falls back to system platform010 stdlib whose lib-dynload .so files are ABI-incompatible with the static libpython.

Test Plan:
Specify the right python executable for Buck PAR via "KERNEL_PROFILER_PYTHON"

Summary:
NCU profiling subprocesses failed inside a Buck PAR with:
```
ImportError: .../platform010/lib/python3.12/lib-dynload/_posixsubprocess.cpython-312-x86_64-linux-gnu.so:
undefined symbol: _Py_NoneStruct
ModuleNotFoundError: No module named 'torch'
```

Root cause: inside a PAR, sys.executable points at the static-linked native-main binary. Re-exec'ing it from a subprocess skips the env setup that bootstrap.sh performs (LD_LIBRARY_PATH for CUDA, LD_PRELOAD for the allocator, PYTHONPATH/FB_PAR* for the embedded import system), so the spawned Python falls back to system platform010 stdlib whose lib-dynload .so files are ABI-incompatible with the static libpython.



Test Plan:
Specify the right python executable for Buck PAR via "KERNEL_PROFILER_PYTHON"
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 19, 2026
@wychi wychi requested review from Jack-Khuu and kaiming-cheng May 19, 2026 20:41
@Jack-Khuu Jack-Khuu merged commit d98f4a8 into main May 19, 2026
9 checks passed
@wychi wychi deleted the wychi/fix_ncu_with_buck_par branch May 19, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants