forked from mrq/bitsandbytes-rocm
Fixed CUDA setup bugs, including #81.
This commit is contained in:
parent
4844aef4ff
commit
8d87c0b852
|
@ -149,3 +149,9 @@ Bug fixes:
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
- Fixed a bug in the CUDA Setup which led to an incomprehensible error if no GPU was detected.
|
- 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 .paths import determine_cuda_runtime_lib_path
|
from .paths import determine_cuda_runtime_lib_path
|
||||||
from bitsandbytes.cextension import CUDASetup
|
from bitsandbytes.cextension import CUDASetup
|
||||||
|
@ -29,8 +30,11 @@ def check_cuda_result(cuda, result_val):
|
||||||
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()}")
|
||||||
|
|
||||||
|
|
||||||
|
# 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):
|
||||||
# https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART____VERSION.html#group__CUDART____VERSION
|
if cuda is None: return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cudart = ctypes.CDLL(cudart_path)
|
cudart = ctypes.CDLL(cudart_path)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -72,7 +76,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()
|
||||||
|
@ -99,11 +102,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():
|
||||||
|
@ -113,28 +116,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 == '' or cc is None:
|
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, cudart_path, cuda, cc, cuda_version_string
|
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"]
|
||||||
|
@ -145,16 +151,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
|
||||||
|
|
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.3",
|
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