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

Allow control of patching via environment variables #20

Merged
merged 1 commit into from
Jun 17, 2022

Conversation

wence-
Copy link
Contributor

@wence- wence- commented Jun 16, 2022

Under some circumstances (usually involving InfiniBand network
stacks), fork() has bad consequences. Introduce environment variables
to control the behaviour of patch_numba_codegen_if_needed (which
previously unconditionally forked a subprocess), to both skip the
check and (optionally) unconditionally patch Numba codegen.

Under some circumstances (usually involving InfiniBand network
stacks), fork() has bad consequences. Introduce environment variables
to control the behaviour of patch_numba_codegen_if_needed (which
previously unconditionally forked a subprocess), to both skip the
check and (optionally) unconditionally patch Numba codegen.
Copy link
Contributor

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

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

Many thanks for the PR. This looks good to me and behaves as expected - some example invocations:

$ PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=1 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [1701] DEBUG -- PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=1
== CUDA (ptxcompiler) [1701] DEBUG -- Patching Numba codegen for forward compatibility

$ PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=0 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [282] DEBUG -- PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=0
== CUDA (ptxcompiler) [671] DEBUG -- CUDA Driver version 11.7
== CUDA (ptxcompiler) [671] DEBUG -- CUDA Runtime version 11.7
== CUDA (ptxcompiler) [671] DEBUG -- Driver version sufficient: not patching Numba codegen

$ PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=1 PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=0 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [291] DEBUG -- PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=1
== CUDA (ptxcompiler) [291] DEBUG -- PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=0
== CUDA (ptxcompiler) [652] DEBUG -- CUDA Driver version 11.7
== CUDA (ptxcompiler) [652] DEBUG -- CUDA Runtime version 11.7
== CUDA (ptxcompiler) [652] DEBUG -- Driver version sufficient: not patching Numba codegen

$ PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=0 PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=0 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [284] DEBUG -- PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=0
== CUDA (ptxcompiler) [284] DEBUG -- PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=0
== CUDA (ptxcompiler) [284] DEBUG -- Driver version sufficient: not patching Numba codegen

$ PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=0 PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=1 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [285] DEBUG -- PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=0
== CUDA (ptxcompiler) [285] DEBUG -- PTXCOMPILER_APPLY_NUMBA_CODEGEN_PATCH=1
== CUDA (ptxcompiler) [285] DEBUG -- Patching Numba codegen for forward compatibility

$ PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=0 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [281] DEBUG -- PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=0
== CUDA (ptxcompiler) [281] DEBUG -- Driver version sufficient: not patching Numba codegen

$ PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=1 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [282] DEBUG -- PTXCOMPILER_CHECK_NUMBA_CODEGEN_PATCH_NEEDED=1
== CUDA (ptxcompiler) [668] DEBUG -- CUDA Driver version 11.7
== CUDA (ptxcompiler) [668] DEBUG -- CUDA Runtime version 11.7
== CUDA (ptxcompiler) [668] DEBUG -- Driver version sufficient: not patching Numba codegen

$ NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from ptxcompiler.patch import patch_numba_codegen_if_needed; patch_numba_codegen_if_needed()"
== CUDA (ptxcompiler) [669] DEBUG -- CUDA Driver version 11.7
== CUDA (ptxcompiler) [669] DEBUG -- CUDA Runtime version 11.7
== CUDA (ptxcompiler) [669] DEBUG -- Driver version sufficient: not patching Numba codegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants