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
text-generation-inference
Commits
146e72c3
Commit
146e72c3
authored
May 30, 2023
by
OlivierDehaene
Browse files
fix(launcher): parse num cuda devices from CUDA_VISIBLE_DEVICES and NVIDIA_VISIBLE_DEVICES
parent
5fde8d99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
launcher/src/main.rs
launcher/src/main.rs
+8
-8
No files found.
launcher/src/main.rs
View file @
146e72c3
...
...
@@ -455,11 +455,11 @@ fn shutdown_shards(shutdown: Arc<Mutex<bool>>, shutdown_receiver: &mpsc::Receive
}
fn
num_cuda_devices
()
->
Option
<
usize
>
{
if
let
Ok
(
cuda_visible_
devices
)
=
env
::
var
(
"CUDA_VISIBLE_DEVICES"
)
{
let
n_devices
=
cuda_visible_devices
.split
(
','
)
.count
();
return
Some
(
n_devices
)
;
}
None
let
devices
=
env
::
var
(
"CUDA_VISIBLE_DEVICES"
)
.map_err
(|
_
|
env
::
var
(
"NVIDIA_VISIBLE_DEVICES"
))
.ok
()
?
;
let
n_devices
=
devices
.split
(
','
)
.count
();
Some
(
n_devices
)
}
#[derive(Deserialize)]
...
...
@@ -509,9 +509,9 @@ fn find_num_shards(sharded: Option<bool>, num_shard: Option<usize>) -> usize {
let
num_shard
=
match
(
sharded
,
num_shard
)
{
(
Some
(
true
),
None
)
=>
{
// try to default to the number of available GPUs
tracing
::
info!
(
"Parsing num_shard from CUDA_VISIBLE_DEVICES"
);
let
n_devices
=
num_cuda_devices
()
.expect
(
"--num-shard and CUDA_VISIBLE_DEVICES are not set"
);
tracing
::
info!
(
"Parsing num_shard from CUDA_VISIBLE_DEVICES
/NVIDIA_VISIBLE_DEVICES
"
);
let
n_devices
=
num_cuda_devices
()
.expect
(
"--num-shard and CUDA_VISIBLE_DEVICES
/NVIDIA_VISIBLE_DEVICES
are not set"
);
if
n_devices
<=
1
{
panic!
(
"`sharded` is true but only found {n_devices} CUDA devices"
);
}
...
...
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