0

I have made a python package which uses CUDA code. Using autodoc_mock_imports I managed a CUDA dependency error due to the import of PyCuda. The issue I have right now is directly inside my package: at a point I try to write a Cubin PyCuda (mocked) would create. Locally, without GPU, it works for some reason, on RTD though, it doesn't. The error I have is this :

    self.compiled_source = self.try_load_cubin()
  File "/home/docs/checkouts/readthedocs.org/user_builds/.../compiler_base.py", line 66, in try_load_cubin
    cubin_file.write(cubin)
TypeError: a bytes-like object is required, not 'compile'

compile in this error refers to a pycuda function (mocked). The exact command executed is :

python -m sphinx -T -E -b html -d _build/doctrees -D language=en . $READTHEDOCS_OUTPUT/html

Again, when I run it on my local environment which doesn't have a GPU this commands works. Would you know how ignore this part of the code or ignore the error or any type of solution ?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Maxime D.
  • 306
  • 5
  • 17

1 Answers1

1

It seems like the issue is that the cubin being passed to cubin_file.write() is not of the expected type (bytes-like instead of compile). One potential solution could be to convert the compile object to bytes before passing it to write().

You could try modifying the code to something like this:


    cubin_bytes = bytes(cubin)
    cubin_file.write(cubin_bytes)

This should ensure that the cubin object is in the expected bytes-like format when it is written to file.

As for handling this error in RTD, you could try wrapping the offending code block in a try-except block that catches the TypeError and ignores it:

try:

        self.compiled_source = self.try_load_cubin()
    except TypeError:
        # Ignore the TypeError and continue executing the rest of the code block
        pass

Kim Marry
  • 55
  • 3