Merge branch 'main' into cleanup
This commit is contained in:
commit
30f28b94a0
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -138,3 +138,20 @@ Features:
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
- Fixed a problem where warning messages would be displayed even though everything worked correctly.
|
- Fixed a problem where warning messages would be displayed even though everything worked correctly.
|
||||||
|
|
||||||
|
|
||||||
|
### 0.35.2
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
- Fixed a bug where the CUDA setup failed due to a wrong function call.
|
||||||
|
|
||||||
|
### 0.35.3
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
- Fixed a bug in the CUDA Setup which led to an incomprehensible error if no GPU was detected.
|
||||||
|
|
||||||
|
### 0.35.4
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
- Fixed a bug in the CUDA Setup failed with the cuda runtime was found, but not the cuda library.
|
||||||
|
- Fixed a bug where not finding the cuda runtime led to an incomprehensible error.
|
||||||
|
|
|
@ -116,7 +116,7 @@ try:
|
||||||
CUDASetup.get_instance().generate_instructions()
|
CUDASetup.get_instance().generate_instructions()
|
||||||
CUDASetup.get_instance().print_log_stack()
|
CUDASetup.get_instance().print_log_stack()
|
||||||
raise RuntimeError('''
|
raise RuntimeError('''
|
||||||
CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs to fix your environment!
|
CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs aboveto fix your environment!
|
||||||
If you cannot find any issues and suspect a bug, please open an issue with detals about 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''')
|
https://github.com/TimDettmers/bitsandbytes/issues''')
|
||||||
lib.cadam32bit_g32
|
lib.cadam32bit_g32
|
||||||
|
@ -124,8 +124,6 @@ try:
|
||||||
lib.get_cusparse.restype = ct.c_void_p
|
lib.get_cusparse.restype = ct.c_void_p
|
||||||
COMPILED_WITH_CUDA = True
|
COMPILED_WITH_CUDA = True
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
warn(
|
warn("The installed version of bitsandbytes was compiled without GPU support. "
|
||||||
"The installed version of bitsandbytes was compiled without GPU support. "
|
"8-bit optimizers and GPU quantization are unavailable.")
|
||||||
"8-bit optimizers and GPU quantization are unavailable."
|
|
||||||
)
|
|
||||||
COMPILED_WITH_CUDA = False
|
COMPILED_WITH_CUDA = False
|
||||||
|
|
|
@ -17,6 +17,7 @@ evaluation:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import torch
|
||||||
|
|
||||||
from bitsandbytes.cextension import CUDASetup
|
from bitsandbytes.cextension import CUDASetup
|
||||||
|
|
||||||
|
@ -28,14 +29,17 @@ def check_cuda_result(cuda, result_val):
|
||||||
if result_val != 0:
|
if result_val != 0:
|
||||||
error_str = ctypes.c_char_p()
|
error_str = ctypes.c_char_p()
|
||||||
cuda.cuGetErrorString(result_val, ctypes.byref(error_str))
|
cuda.cuGetErrorString(result_val, ctypes.byref(error_str))
|
||||||
CUDASetup.get_instance.add_log_entry(f"CUDA exception! Error code: {error_str.value.decode()}")
|
CUDASetup.get_instance().add_log_entry(f"CUDA exception! Error code: {error_str.value.decode()}")
|
||||||
|
|
||||||
|
|
||||||
def get_cuda_version(cuda, cudart_path):
|
|
||||||
# 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):
|
||||||
|
if cuda is None: return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cudart = ctypes.CDLL(cudart_path)
|
cudart = ctypes.CDLL(cudart_path)
|
||||||
except OSError:
|
except OSError:
|
||||||
CUDASetup.get_instance.add_log_entry(f'ERROR: libcudart.so could not be read from path: {cudart_path}!')
|
CUDASetup.get_instance().add_log_entry(f'ERROR: libcudart.so could not be read from path: {cudart_path}!')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
version = ctypes.c_int()
|
version = ctypes.c_int()
|
||||||
|
@ -55,7 +59,7 @@ def get_cuda_lib_handle():
|
||||||
try:
|
try:
|
||||||
cuda = ctypes.CDLL("libcuda.so")
|
cuda = ctypes.CDLL("libcuda.so")
|
||||||
except OSError:
|
except OSError:
|
||||||
CUDA_RUNTIME_LIB.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))
|
check_cuda_result(cuda, cuda.cuInit(0))
|
||||||
|
|
||||||
|
@ -73,7 +77,6 @@ def get_compute_capabilities(cuda):
|
||||||
# bits taken from https://gist.github.com/f0k/63a664160d016a491b2cbea15913d549
|
# bits taken from https://gist.github.com/f0k/63a664160d016a491b2cbea15913d549
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
nGpus = ctypes.c_int()
|
nGpus = ctypes.c_int()
|
||||||
cc_major = ctypes.c_int()
|
cc_major = ctypes.c_int()
|
||||||
cc_minor = ctypes.c_int()
|
cc_minor = ctypes.c_int()
|
||||||
|
@ -87,9 +90,7 @@ def get_compute_capabilities(cuda):
|
||||||
ref_major = ctypes.byref(cc_major)
|
ref_major = ctypes.byref(cc_major)
|
||||||
ref_minor = ctypes.byref(cc_minor)
|
ref_minor = ctypes.byref(cc_minor)
|
||||||
# 2. call extern C function to determine CC
|
# 2. call extern C function to determine CC
|
||||||
check_cuda_result(
|
check_cuda_result(cuda, cuda.cuDeviceComputeCapability(ref_major, ref_minor, device))
|
||||||
cuda, cuda.cuDeviceComputeCapability(ref_major, ref_minor, device)
|
|
||||||
)
|
|
||||||
ccs.append(f"{cc_major.value}.{cc_minor.value}")
|
ccs.append(f"{cc_major.value}.{cc_minor.value}")
|
||||||
|
|
||||||
return ccs
|
return ccs
|
||||||
|
@ -102,11 +103,11 @@ def get_compute_capability(cuda):
|
||||||
capabilities are downwards compatible. If no GPUs are detected, it returns
|
capabilities are downwards compatible. If no GPUs are detected, it returns
|
||||||
None.
|
None.
|
||||||
"""
|
"""
|
||||||
ccs = get_compute_capabilities(cuda)
|
if cuda is None: return None
|
||||||
if ccs:
|
|
||||||
# TODO: handle different compute capabilities; for now, take the max
|
# TODO: handle different compute capabilities; for now, take the max
|
||||||
return ccs[-1]
|
ccs = get_compute_capabilities(cuda)
|
||||||
return None
|
if ccs: return ccs[-1]
|
||||||
|
|
||||||
|
|
||||||
def evaluate_cuda_setup():
|
def evaluate_cuda_setup():
|
||||||
|
@ -116,28 +117,31 @@ def evaluate_cuda_setup():
|
||||||
#print('Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues')
|
#print('Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues')
|
||||||
#print('For effortless bug reporting copy-paste your error into this form: https://docs.google.com/forms/d/e/1FAIpQLScPB8emS3Thkp66nvqwmjTEgxp8Y9ufuWTzFyr9kJ5AoI47dQ/viewform?usp=sf_link')
|
#print('For effortless bug reporting copy-paste your error into this form: https://docs.google.com/forms/d/e/1FAIpQLScPB8emS3Thkp66nvqwmjTEgxp8Y9ufuWTzFyr9kJ5AoI47dQ/viewform?usp=sf_link')
|
||||||
#print('='*80)
|
#print('='*80)
|
||||||
#if not torch.cuda.is_available():
|
if not torch.cuda.is_available(): return 'libsbitsandbytes_cpu.so', None, None, None, None
|
||||||
#print('No GPU detected. Loading CPU library...')
|
|
||||||
#return binary_name
|
|
||||||
|
|
||||||
binary_name = "libbitsandbytes_cpu.so"
|
|
||||||
|
|
||||||
cuda_setup = CUDASetup.get_instance()
|
cuda_setup = CUDASetup.get_instance()
|
||||||
cudart_path = determine_cuda_runtime_lib_path()
|
cudart_path = determine_cuda_runtime_lib_path()
|
||||||
if cudart_path is None:
|
|
||||||
cuda_setup.add_log_entry("WARNING: No libcudart.so found! Install CUDA or the cudatoolkit package (anaconda)!", is_warning=True)
|
|
||||||
return binary_name
|
|
||||||
|
|
||||||
cuda_setup.add_log_entry(f"CUDA SETUP: CUDA runtime path found: {cudart_path}")
|
|
||||||
cuda = get_cuda_lib_handle()
|
cuda = get_cuda_lib_handle()
|
||||||
cc = get_compute_capability(cuda)
|
cc = get_compute_capability(cuda)
|
||||||
cuda_setup.add_log_entry(f"CUDA SETUP: Highest compute capability among GPUs detected: {cc}")
|
|
||||||
cuda_version_string = get_cuda_version(cuda, cudart_path)
|
cuda_version_string = get_cuda_version(cuda, cudart_path)
|
||||||
|
|
||||||
|
failure = False
|
||||||
|
if cudart_path is None:
|
||||||
|
failure = True
|
||||||
|
cuda_setup.add_log_entry("WARNING: No libcudart.so found! Install CUDA or the cudatoolkit package (anaconda)!", is_warning=True)
|
||||||
|
else:
|
||||||
|
cuda_setup.add_log_entry(f"CUDA SETUP: CUDA runtime path found: {cudart_path}")
|
||||||
|
|
||||||
if cc == '':
|
if cc == '' or cc is None:
|
||||||
cuda_setup.add_log_entry("WARNING: No GPU detected! Check your CUDA paths. Processing to load CPU-only library...", is_warning=True)
|
failure = True
|
||||||
return binary_name
|
cuda_setup.add_log_entry("WARNING: No GPU detected! Check your CUDA paths. Proceeding to load CPU-only library...", is_warning=True)
|
||||||
|
else:
|
||||||
|
cuda_setup.add_log_entry(f"CUDA SETUP: Highest compute capability among GPUs detected: {cc}")
|
||||||
|
|
||||||
|
if cuda is None:
|
||||||
|
failure = True
|
||||||
|
else:
|
||||||
|
cuda_setup.add_log_entry(f'CUDA SETUP: Detected CUDA version {cuda_version_string}')
|
||||||
|
|
||||||
# 7.5 is the minimum CC vor cublaslt
|
# 7.5 is the minimum CC vor cublaslt
|
||||||
has_cublaslt = cc in ["7.5", "8.0", "8.6"]
|
has_cublaslt = cc in ["7.5", "8.0", "8.6"]
|
||||||
|
@ -148,16 +152,13 @@ def evaluate_cuda_setup():
|
||||||
|
|
||||||
# we use ls -l instead of nvcc to determine the cuda version
|
# we use ls -l instead of nvcc to determine the cuda version
|
||||||
# since most installations will have the libcudart.so installed, but not the compiler
|
# since most installations will have the libcudart.so installed, but not the compiler
|
||||||
cuda_setup.add_log_entry(f'CUDA SETUP: Detected CUDA version {cuda_version_string}')
|
|
||||||
|
|
||||||
def get_binary_name():
|
if failure:
|
||||||
"if not has_cublaslt (CC < 7.5), then we have to choose _nocublaslt.so"
|
binary_name = "libbitsandbytes_cpu.so"
|
||||||
bin_base_name = "libbitsandbytes_cuda"
|
elif has_cublaslt:
|
||||||
if has_cublaslt:
|
binary_name = f"libbitsandbytes_cuda{cuda_version_string}.so"
|
||||||
return f"{bin_base_name}{cuda_version_string}.so"
|
|
||||||
else:
|
else:
|
||||||
return f"{bin_base_name}{cuda_version_string}_nocublaslt.so"
|
"if not has_cublaslt (CC < 7.5), then we have to choose _nocublaslt.so"
|
||||||
|
binary_name = f"libbitsandbytes_cuda{cuda_version_string}_nocublaslt.so"
|
||||||
binary_name = get_binary_name()
|
|
||||||
|
|
||||||
return binary_name, cudart_path, cuda, cc, cuda_version_string
|
return binary_name, cudart_path, cuda, cc, cuda_version_string
|
||||||
|
|
|
@ -62,7 +62,7 @@ def warn_in_case_of_duplicates(results_paths: Set[Path]) -> None:
|
||||||
"If you get `CUDA error: invalid device function` errors, the above "
|
"If you get `CUDA error: invalid device function` errors, the above "
|
||||||
"might be the cause and the solution is to make sure only one "
|
"might be the cause and the solution is to make sure only one "
|
||||||
f"{CUDA_RUNTIME_LIB} in the paths that we search based on your env.")
|
f"{CUDA_RUNTIME_LIB} in the paths that we search based on your env.")
|
||||||
CUDASetup.get_instance.add_log_entry(warning_msg, is_warning=True)
|
CUDASetup.get_instance().add_log_entry(warning_msg, is_warning=True)
|
||||||
|
|
||||||
|
|
||||||
def determine_cuda_runtime_lib_path() -> Union[Path, None]:
|
def determine_cuda_runtime_lib_path() -> Union[Path, None]:
|
||||||
|
@ -88,7 +88,7 @@ def determine_cuda_runtime_lib_path() -> Union[Path, None]:
|
||||||
if conda_cuda_libs:
|
if conda_cuda_libs:
|
||||||
return next(iter(conda_cuda_libs))
|
return next(iter(conda_cuda_libs))
|
||||||
|
|
||||||
CUDASetup.get_instance.add_log_entry(f'{candidate_env_vars["CONDA_PREFIX"]} did not contain '
|
CUDASetup.get_instance().add_log_entry(f'{candidate_env_vars["CONDA_PREFIX"]} did not contain '
|
||||||
f'{CUDA_RUNTIME_LIB} as expected! Searching further paths...', is_warning=True)
|
f'{CUDA_RUNTIME_LIB} as expected! Searching further paths...', is_warning=True)
|
||||||
|
|
||||||
if "LD_LIBRARY_PATH" in candidate_env_vars:
|
if "LD_LIBRARY_PATH" in candidate_env_vars:
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -18,7 +18,7 @@ def read(fname):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=f"bitsandbytes",
|
name=f"bitsandbytes",
|
||||||
version=f"0.35.1",
|
version=f"0.35.4",
|
||||||
author="Tim Dettmers",
|
author="Tim Dettmers",
|
||||||
author_email="dettmers@cs.washington.edu",
|
author_email="dettmers@cs.washington.edu",
|
||||||
description="8-bit optimizers and matrix multiplication routines.",
|
description="8-bit optimizers and matrix multiplication routines.",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user