Merge branch 'main' into bugfixes
This commit is contained in:
commit
ac155f7415
|
@ -323,7 +323,7 @@ class MatMul8bitLt(torch.autograd.Function):
|
||||||
|
|
||||||
# 1. Quantize A
|
# 1. Quantize A
|
||||||
if len(A.shape) == 3:
|
if len(A.shape) == 3:
|
||||||
A = A.view(-1, A.shape[-1]).contiguous()
|
A = A.reshape(-1, A.shape[-1])
|
||||||
CA, CAt, SCA, SCAt, coo_tensorA = F.double_quant(A.to(torch.float16), threshold=state.threshold)
|
CA, CAt, SCA, SCAt, coo_tensorA = F.double_quant(A.to(torch.float16), threshold=state.threshold)
|
||||||
|
|
||||||
if state.threshold > 0.0 and coo_tensorA is not None:
|
if state.threshold > 0.0 and coo_tensorA is not None:
|
||||||
|
|
|
@ -280,37 +280,11 @@ def determine_cuda_runtime_lib_path() -> Union[Path, None]:
|
||||||
return next(iter(cuda_runtime_libs)) if cuda_runtime_libs else None
|
return next(iter(cuda_runtime_libs)) if cuda_runtime_libs else None
|
||||||
|
|
||||||
|
|
||||||
def check_cuda_result(cuda, result_val):
|
|
||||||
# 3. Check for CUDA errors
|
|
||||||
if result_val != 0:
|
|
||||||
error_str = ct.c_char_p()
|
|
||||||
cuda.cuGetErrorString(result_val, ct.byref(error_str))
|
|
||||||
if error_str.value is not None:
|
|
||||||
CUDASetup.get_instance().add_log_entry(f"CUDA exception! Error code: {error_str.value.decode()}")
|
|
||||||
else:
|
|
||||||
CUDASetup.get_instance().add_log_entry(f"Unknown CUDA exception! Please check your CUDA install. It might also be that your GPU is too old.")
|
|
||||||
|
|
||||||
|
|
||||||
# https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART____VERSION.html#group__CUDART____VERSION
|
# https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART____VERSION.html#group__CUDART____VERSION
|
||||||
def get_cuda_version(cuda, cudart_path):
|
def get_cuda_version(cuda, cudart_path):
|
||||||
if cuda is None: return None
|
if cuda is None: return None
|
||||||
|
|
||||||
try:
|
major, minor = map(int, torch.version.cuda.split("."))
|
||||||
cudart = ct.CDLL(cudart_path)
|
|
||||||
except OSError:
|
|
||||||
CUDASetup.get_instance().add_log_entry(f'ERROR: libcudart.so could not be read from path: {cudart_path}!')
|
|
||||||
return None
|
|
||||||
|
|
||||||
version = ct.c_int()
|
|
||||||
try:
|
|
||||||
check_cuda_result(cuda, cudart.cudaRuntimeGetVersion(ct.byref(version)))
|
|
||||||
except AttributeError as e:
|
|
||||||
CUDASetup.get_instance().add_log_entry(f'ERROR: {str(e)}')
|
|
||||||
CUDASetup.get_instance().add_log_entry(f'CUDA SETUP: libcudart.so path is {cudart_path}')
|
|
||||||
CUDASetup.get_instance().add_log_entry(f'CUDA SETUP: Is seems that your cuda installation is not in your path. See https://github.com/TimDettmers/bitsandbytes/issues/85 for more information.')
|
|
||||||
version = int(version.value)
|
|
||||||
major = version//1000
|
|
||||||
minor = (version-(major*1000))//10
|
|
||||||
|
|
||||||
if major < 11:
|
if major < 11:
|
||||||
CUDASetup.get_instance().add_log_entry('CUDA SETUP: CUDA version lower than 11 are currently not supported for LLM.int8(). You will be only to use 8-bit optimizers and quantization routines!!')
|
CUDASetup.get_instance().add_log_entry('CUDA SETUP: CUDA version lower than 11 are currently not supported for LLM.int8(). You will be only to use 8-bit optimizers and quantization routines!!')
|
||||||
|
@ -325,37 +299,15 @@ def get_cuda_lib_handle():
|
||||||
except OSError:
|
except OSError:
|
||||||
CUDASetup.get_instance().add_log_entry('CUDA SETUP: WARNING! libcuda.so not found! Do you have a CUDA driver installed? If you are on a cluster, make sure you are on a CUDA machine!')
|
CUDASetup.get_instance().add_log_entry('CUDA SETUP: WARNING! libcuda.so not found! Do you have a CUDA driver installed? If you are on a cluster, make sure you are on a CUDA machine!')
|
||||||
return None
|
return None
|
||||||
check_cuda_result(cuda, cuda.cuInit(0))
|
|
||||||
|
|
||||||
return cuda
|
return cuda
|
||||||
|
|
||||||
|
|
||||||
def get_compute_capabilities(cuda):
|
def get_compute_capabilities(cuda):
|
||||||
"""
|
|
||||||
1. find libcuda.so library (GPU driver) (/usr/lib)
|
|
||||||
init_device -> init variables -> call function by reference
|
|
||||||
2. call extern C function to determine CC
|
|
||||||
(https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__DEVICE__DEPRECATED.html)
|
|
||||||
3. Check for CUDA errors
|
|
||||||
https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
|
|
||||||
# bits taken from https://gist.github.com/f0k/63a664160d016a491b2cbea15913d549
|
|
||||||
"""
|
|
||||||
|
|
||||||
nGpus = ct.c_int()
|
|
||||||
cc_major = ct.c_int()
|
|
||||||
cc_minor = ct.c_int()
|
|
||||||
|
|
||||||
device = ct.c_int()
|
|
||||||
|
|
||||||
check_cuda_result(cuda, cuda.cuDeviceGetCount(ct.byref(nGpus)))
|
|
||||||
ccs = []
|
ccs = []
|
||||||
for i in range(nGpus.value):
|
for i in range(torch.cuda.device_count()):
|
||||||
check_cuda_result(cuda, cuda.cuDeviceGet(ct.byref(device), i))
|
cc_major, cc_minor = torch.cuda.get_device_capability(torch.cuda.device(i))
|
||||||
ref_major = ct.byref(cc_major)
|
ccs.append(f"{cc_major}.{cc_minor}")
|
||||||
ref_minor = ct.byref(cc_minor)
|
|
||||||
# 2. call extern C function to determine CC
|
|
||||||
check_cuda_result(cuda, cuda.cuDeviceComputeCapability(ref_major, ref_minor, device))
|
|
||||||
ccs.append(f"{cc_major.value}.{cc_minor.value}")
|
|
||||||
|
|
||||||
return ccs
|
return ccs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user