2022-07-01 14:16:10 +00:00
|
|
|
import ctypes as ct
|
2022-10-27 11:15:21 +00:00
|
|
|
import torch
|
|
|
|
|
2023-01-02 11:31:43 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from warnings import warn
|
2022-07-01 14:16:10 +00:00
|
|
|
|
2023-01-02 11:31:43 +00:00
|
|
|
from bitsandbytes.cuda_setup.main import CUDASetup
|
2022-08-01 00:47:44 +00:00
|
|
|
|
|
|
|
|
2023-01-02 11:31:43 +00:00
|
|
|
setup = CUDASetup.get_instance()
|
|
|
|
if setup.initialized != True:
|
|
|
|
setup.run_cuda_setup()
|
2022-08-01 00:47:44 +00:00
|
|
|
|
2023-01-02 11:31:43 +00:00
|
|
|
lib = setup.lib
|
2022-07-01 14:16:10 +00:00
|
|
|
try:
|
2022-10-25 15:01:19 +00:00
|
|
|
if lib is None and torch.cuda.is_available():
|
|
|
|
CUDASetup.get_instance().generate_instructions()
|
|
|
|
CUDASetup.get_instance().print_log_stack()
|
|
|
|
raise RuntimeError('''
|
2022-11-01 08:53:47 +00:00
|
|
|
CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs above to fix your environment!
|
2022-10-25 15:01:19 +00:00
|
|
|
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
|