Skip to content

[BUG]: Unable to reliably invoke nvjitlink.add_file across threads #1023

@cpcloud

Description

@cpcloud

Is this a duplicate?

Type of Bug

Runtime Error

Component

cuda.bindings

Describe the bug

This test occasionally fails when run with the GIL disabled:

    def test_add_file(arch, ptx_bytes, tmp_path):
        handle = nvjitlink.create(1, [f"-arch={arch}"])
        file_path = tmp_path / "test_file.cubin"
        file_path.write_bytes(ptx_bytes)
        nvjitlink.add_file(handle, nvjitlink.InputType.ANY, str(file_path))

with this traceback:

cuda_bindings/tests/test_nvjitlink.py:123:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cuda/bindings/nvjitlink.pyx:146: in cuda.bindings.nvjitlink.add_file
    ???
cuda/bindings/nvjitlink.pyx:162: in cuda.bindings.nvjitlink.add_file
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   cuda.bindings.nvjitlink.nvJitLinkError: ERROR_INVALID_INPUT (3)

How to Reproduce

python -Xgil=0 -m pytest --require-gil-disabled 'cuda_bindings/tests/test_nvjitlink.py::test_add_file[sm_75_6.4]' --iterations 30 --threads 10

Expected behavior

I'm not sure. Maybe this operation doesn't make sense across threads. If not, then a better error message might be nice.

That said, this API looks very much like it has global state based on the way it's being invoked (as a function, instead of as a method on handle), so maybe this does make sense.

Operating System

Linux

nvidia-smi output

I don't think nvidia-smi output is applicable here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions