Skip to content

Commit b27420e

Browse files
committed
use glob(), search CUDA_PATH
1 parent 7686ffe commit b27420e

File tree

1 file changed

+19
-27
lines changed

1 file changed

+19
-27
lines changed

bitsandbytes/__main__.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,19 @@
1111

1212
HEADER_WIDTH = 60
1313

14-
def execute_and_return(command_string: str) -> Tuple[str, str]:
15-
def _decode(subprocess_err_out_tuple):
16-
return tuple(
17-
to_decode.decode("UTF-8").strip()
18-
for to_decode in subprocess_err_out_tuple
19-
)
20-
21-
def execute_and_return_decoded_std_streams(command_string):
22-
return _decode(
23-
subprocess.Popen(
24-
shlex.split(command_string),
25-
stdout=subprocess.PIPE,
26-
stderr=subprocess.PIPE,
27-
).communicate()
28-
)
29-
30-
std_out, std_err = execute_and_return_decoded_std_streams(command_string)
31-
return std_out, std_err
3214

3315
def find_file_recursive(folder, filename):
34-
cmd = f'find {folder} -name {filename}'
35-
out, err = execute_and_return(cmd)
36-
if len(err) > 0:
37-
raise RuntimeError('Something when wrong when trying to find file. Maybe you do not have a linux system?')
16+
import glob
17+
outs = []
18+
try:
19+
for ext in ["so", "dll", "dylib"]:
20+
print(folder, filename, ext)
21+
out = glob.glob(os.path.join(folder, "**", filename + ext))
22+
outs.extend(out)
23+
except Exception as e:
24+
raise RuntimeError('Error: Something when wrong when trying to find file. {e}')
3825

39-
return out
26+
return outs
4027

4128

4229
def generate_bug_report_information():
@@ -46,26 +33,31 @@ def generate_bug_report_information():
4633
print('')
4734

4835
if 'CONDA_PREFIX' in os.environ:
49-
paths = find_file_recursive(os.environ['CONDA_PREFIX'], '*cuda*so')
36+
paths = find_file_recursive(os.environ['CONDA_PREFIX'], '*cuda*')
5037
print_header("ANACONDA CUDA PATHS")
5138
print(paths)
5239
print('')
5340
if isdir('/usr/local/'):
54-
paths = find_file_recursive('/usr/local', '*cuda*so')
41+
paths = find_file_recursive('/usr/local', '*cuda*')
5542
print_header("/usr/local CUDA PATHS")
5643
print(paths)
5744
print('')
45+
if 'CUDA_PATH' in os.environ and isdir(os.environ['CUDA_PATH']):
46+
paths = find_file_recursive(os.environ['CUDA_PATH'], '*cuda*')
47+
print_header("CUDA PATHS")
48+
print(paths)
49+
print('')
5850

5951
if isdir(os.getcwd()):
60-
paths = find_file_recursive(os.getcwd(), '*cuda*so')
52+
paths = find_file_recursive(os.getcwd(), '*cuda*')
6153
print_header("WORKING DIRECTORY CUDA PATHS")
6254
print(paths)
6355
print('')
6456

6557
print_header("LD_LIBRARY CUDA PATHS")
6658
if 'LD_LIBRARY_PATH' in os.environ:
6759
lib_path = os.environ['LD_LIBRARY_PATH'].strip()
68-
for path in set(lib_path.split(':')):
60+
for path in set(lib_path.split(':' if not os.sep == "\\" else ";")):
6961
try:
7062
if isdir(path):
7163
print_header(f"{path} CUDA PATHS")

0 commit comments

Comments
 (0)