Skip to content

Make 8-bit matrix multiplication compatible with cpuonly builds #22

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

Closed
wants to merge 1 commit into from

Conversation

mryab
Copy link
Collaborator

@mryab mryab commented Aug 22, 2022

While trying to use the latest release of bitsandbytes in hivemind, I faced an error after installing the library in a cpuonly mode (both from PyPI and from source): https://github.com/learning-at-home/hivemind/runs/7961913748?check_suite_focus=true#step:8:56

The gist of this error seems to be unprotected usage of torch.cuda.get_device_capability(), which fails for non-GPU builds of PyTorch. To handle this, I've moved the corresponding imports in the root of bitsandbytes inside the COMPILED_WITH_CUDA block and also moved the relevant function/class declarations inside the similar block to avoid accidental imports.

The solution appears to work locally (at least the tests pass), happy to improve on the PR if any additional work is needed.

@mryab mryab requested a review from TimDettmers August 22, 2022 23:11

matmul = MatMul8bitLt.apply
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This gets immediately redefined below

Comment on lines -1688 to -1699
def get_special_format_str():
major, minor = torch.cuda.get_device_capability()
if major < 7:
print(
f"Device with CUDA capability of {major} not supported for 8-bit matmul. Device has no tensor cores!"
)
assert major >= 7

if major == 7: return 'col_turing'
elif major == 8: return 'col_ampere'
else: return 'col_turing'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is already defined above (L186)

@TimDettmers
Copy link
Collaborator

Thank you, Max! We chatted about this and I used your suggestions and fixed this in 7e0fb65 and ee5b947 and it has been deployed already.

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