Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
bitsandbytes
Commits
3fd06fb6
Commit
3fd06fb6
authored
Aug 01, 2022
by
Titus von Koeller
Browse files
refactored subshell execution code for greater readability and moved it to utils
parent
54efd874
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
bitsandbytes/cuda_setup.py
bitsandbytes/cuda_setup.py
+0
-11
bitsandbytes/utils.py
bitsandbytes/utils.py
+22
-0
No files found.
bitsandbytes/cuda_setup.py
View file @
3fd06fb6
...
@@ -19,8 +19,6 @@ evaluation:
...
@@ -19,8 +19,6 @@ evaluation:
"""
"""
import
ctypes
import
ctypes
import
shlex
import
subprocess
from
os
import
environ
as
env
from
os
import
environ
as
env
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Set
,
Union
from
typing
import
Set
,
Union
...
@@ -28,15 +26,6 @@ from typing import Set, Union
...
@@ -28,15 +26,6 @@ from typing import Set, Union
from
.utils
import
print_err
,
warn_of_missing_prerequisite
from
.utils
import
print_err
,
warn_of_missing_prerequisite
def
execute_and_return
(
strCMD
):
proc
=
subprocess
.
Popen
(
shlex
.
split
(
strCMD
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
proc
.
communicate
()
out
,
err
=
out
.
decode
(
"UTF-8"
).
strip
(),
err
.
decode
(
"UTF-8"
).
strip
()
return
out
,
err
def
check_cuda_result
(
cuda
,
result_val
):
def
check_cuda_result
(
cuda
,
result_val
):
if
result_val
!=
0
:
if
result_val
!=
0
:
cuda
.
cuGetErrorString
(
result_val
,
ctypes
.
byref
(
error_str
))
cuda
.
cuGetErrorString
(
result_val
,
ctypes
.
byref
(
error_str
))
...
...
bitsandbytes/utils.py
View file @
3fd06fb6
import
shlex
import
subprocess
import
sys
import
sys
def
execute_and_return
(
command_string
:
str
)
->
Tuple
[
str
,
str
]:
def
_decode
(
subprocess_err_out_tuple
):
return
tuple
(
to_decode
.
decode
(
"UTF-8"
).
strip
()
for
to_decode
in
subprocess_err_out_tuple
)
def
execute_and_return_decoded_std_streams
(
command_string
):
return
_decode
(
subprocess
.
Popen
(
shlex
.
split
(
command_string
),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
).
communicate
()
)
std_out
,
std_err
=
execute_and_return_decoded_std_streams
()
return
std_out
,
std_err
def
print_err
(
s
:
str
)
->
None
:
def
print_err
(
s
:
str
)
->
None
:
print
(
s
,
file
=
sys
.
stderr
)
print
(
s
,
file
=
sys
.
stderr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment