2022-08-01 00:47:44 +00:00
|
|
|
import os
|
2022-08-02 02:22:41 +00:00
|
|
|
from typing import List, NamedTuple
|
2022-07-28 04:16:04 +00:00
|
|
|
|
2022-10-27 11:15:21 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
import bitsandbytes as bnb
|
2023-01-02 11:31:43 +00:00
|
|
|
from bitsandbytes.cuda_setup.main import (
|
2022-08-03 04:26:50 +00:00
|
|
|
determine_cuda_runtime_lib_path,
|
2022-10-27 11:15:21 +00:00
|
|
|
evaluate_cuda_setup,
|
2022-08-03 04:26:50 +00:00
|
|
|
extract_candidate_paths,
|
2022-08-01 16:32:47 +00:00
|
|
|
)
|
2022-07-28 04:16:04 +00:00
|
|
|
|
2022-08-03 04:26:50 +00:00
|
|
|
|
2023-04-11 19:10:20 +00:00
|
|
|
def test_cuda_full_system():
|
2022-08-01 00:47:44 +00:00
|
|
|
## this only tests the cuda version and not compute capability
|
2022-08-02 02:43:09 +00:00
|
|
|
|
|
|
|
# if CONDA_PREFIX exists, it has priority before all other env variables
|
|
|
|
# but it does not contain the library directly, so we need to look at the a sub-folder
|
2022-08-03 04:26:50 +00:00
|
|
|
version = ""
|
|
|
|
if "CONDA_PREFIX" in os.environ:
|
2023-04-11 19:10:20 +00:00
|
|
|
ls_output, err = bnb.utils.execute_and_return(f'ls -l {os.environ["CONDA_PREFIX"]}/lib/libcudart.so.11.0')
|
2022-10-25 15:01:19 +00:00
|
|
|
major, minor, revision = (ls_output.split(" ")[-1].replace("libcudart.so.", "").split("."))
|
2022-08-03 04:26:50 +00:00
|
|
|
version = float(f"{major}.{minor}")
|
|
|
|
|
2022-08-05 15:57:52 +00:00
|
|
|
if version == "" and "LD_LIBRARY_PATH" in os.environ:
|
2022-08-02 02:22:41 +00:00
|
|
|
ld_path = os.environ["LD_LIBRARY_PATH"]
|
|
|
|
paths = ld_path.split(":")
|
|
|
|
version = ""
|
|
|
|
for p in paths:
|
|
|
|
if "cuda" in p:
|
|
|
|
idx = p.rfind("cuda-")
|
|
|
|
version = p[idx + 5 : idx + 5 + 4].replace("/", "")
|
|
|
|
version = float(version)
|
|
|
|
break
|
|
|
|
|
2022-08-05 15:57:52 +00:00
|
|
|
|
2022-08-02 02:22:41 +00:00
|
|
|
assert version > 0
|
2022-10-25 15:01:19 +00:00
|
|
|
binary_name, cudart_path, cuda, cc, cuda_version_string = evaluate_cuda_setup()
|
2022-08-01 10:31:48 +00:00
|
|
|
binary_name = binary_name.replace("libbitsandbytes_cuda", "")
|
|
|
|
assert binary_name.startswith(str(version).replace(".", ""))
|