bitsandbytes-rocm/bitsandbytes/cextension.py

31 lines
1.1 KiB
Python
Raw Normal View History

2022-07-01 14:16:10 +00:00
import ctypes as ct
2022-10-27 11:15:21 +00:00
import torch
from pathlib import Path
from warnings import warn
2022-07-01 14:16:10 +00:00
from bitsandbytes.cuda_setup.main import CUDASetup
setup = CUDASetup.get_instance()
if setup.initialized != True:
setup.run_cuda_setup()
lib = setup.lib
2022-07-01 14:16:10 +00:00
try:
if lib is None and torch.cuda.is_available():
CUDASetup.get_instance().generate_instructions()
CUDASetup.get_instance().print_log_stack()
raise RuntimeError('''
CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs above to fix your environment!
If you cannot find any issues and suspect a bug, please open an issue with detals about your environment:
https://github.com/TimDettmers/bitsandbytes/issues''')
2022-07-01 14:16:10 +00:00
lib.cadam32bit_g32
2022-07-22 21:41:05 +00:00
lib.get_context.restype = ct.c_void_p
lib.get_cusparse.restype = ct.c_void_p
2022-07-01 14:16:10 +00:00
COMPILED_WITH_CUDA = True
except AttributeError:
2022-11-01 01:04:49 +00:00
warn("The installed version of bitsandbytes was compiled without GPU support. "
"8-bit optimizers and GPU quantization are unavailable.")
2022-07-01 14:16:10 +00:00
COMPILED_WITH_CUDA = False