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
9c320e26
Unverified
Commit
9c320e26
authored
Jan 25, 2024
by
OlivierDehaene
Committed by
GitHub
Jan 25, 2024
Browse files
fix: read stderr in download (#1486)
#1186
parent
7e2a7433
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
launcher/src/main.rs
launcher/src/main.rs
+30
-18
No files found.
launcher/src/main.rs
View file @
9c320e26
...
@@ -4,7 +4,7 @@ use nix::unistd::Pid;
...
@@ -4,7 +4,7 @@ use nix::unistd::Pid;
use
serde
::
Deserialize
;
use
serde
::
Deserialize
;
use
std
::
env
;
use
std
::
env
;
use
std
::
ffi
::
OsString
;
use
std
::
ffi
::
OsString
;
use
std
::
io
::{
BufRead
,
BufReader
,
Lines
,
Read
};
use
std
::
io
::{
BufRead
,
BufReader
,
Lines
};
use
std
::
os
::
unix
::
process
::{
CommandExt
,
ExitStatusExt
};
use
std
::
os
::
unix
::
process
::{
CommandExt
,
ExitStatusExt
};
use
std
::
path
::
Path
;
use
std
::
path
::
Path
;
use
std
::
process
::{
Child
,
Command
,
ExitStatus
,
Stdio
};
use
std
::
process
::{
Child
,
Command
,
ExitStatus
,
Stdio
};
...
@@ -489,6 +489,9 @@ fn shard_manager(
...
@@ -489,6 +489,9 @@ fn shard_manager(
// Safetensors load fast
// Safetensors load fast
envs
.push
((
"SAFETENSORS_FAST_GPU"
.into
(),
"1"
.into
()));
envs
.push
((
"SAFETENSORS_FAST_GPU"
.into
(),
"1"
.into
()));
// Disable progress bar
envs
.push
((
"HF_HUB_DISABLE_PROGRESS_BARS"
.into
(),
"1"
.into
()));
// Enable hf transfer for insane download speeds
// Enable hf transfer for insane download speeds
let
enable_hf_transfer
=
env
::
var
(
"HF_HUB_ENABLE_HF_TRANSFER"
)
.unwrap_or
(
"1"
.to_string
());
let
enable_hf_transfer
=
env
::
var
(
"HF_HUB_ENABLE_HF_TRANSFER"
)
.unwrap_or
(
"1"
.to_string
());
envs
.push
((
envs
.push
((
...
@@ -573,6 +576,13 @@ fn shard_manager(
...
@@ -573,6 +576,13 @@ fn shard_manager(
thread
::
spawn
(
move
||
{
thread
::
spawn
(
move
||
{
log_lines
(
shard_stdout_reader
.lines
());
log_lines
(
shard_stdout_reader
.lines
());
});
});
// We read stderr in another thread as it seems that lines() can block in some cases
let
(
err_sender
,
err_receiver
)
=
mpsc
::
channel
();
thread
::
spawn
(
move
||
{
for
line
in
shard_stderr_reader
.lines
()
.flatten
()
{
err_sender
.send
(
line
)
.unwrap_or
(());
}
});
let
mut
ready
=
false
;
let
mut
ready
=
false
;
let
start_time
=
Instant
::
now
();
let
start_time
=
Instant
::
now
();
...
@@ -580,13 +590,6 @@ fn shard_manager(
...
@@ -580,13 +590,6 @@ fn shard_manager(
loop
{
loop
{
// Process exited
// Process exited
if
let
Some
(
exit_status
)
=
p
.try_wait
()
.unwrap
()
{
if
let
Some
(
exit_status
)
=
p
.try_wait
()
.unwrap
()
{
// We read stderr in another thread as it seems that lines() can block in some cases
let
(
err_sender
,
err_receiver
)
=
mpsc
::
channel
();
thread
::
spawn
(
move
||
{
for
line
in
shard_stderr_reader
.lines
()
.flatten
()
{
err_sender
.send
(
line
)
.unwrap_or
(());
}
});
let
mut
err
=
String
::
new
();
let
mut
err
=
String
::
new
();
while
let
Ok
(
line
)
=
err_receiver
.recv_timeout
(
Duration
::
from_millis
(
10
))
{
while
let
Ok
(
line
)
=
err_receiver
.recv_timeout
(
Duration
::
from_millis
(
10
))
{
err
=
err
+
"
\n
"
+
&
line
;
err
=
err
+
"
\n
"
+
&
line
;
...
@@ -782,6 +785,9 @@ fn download_convert_model(args: &Args, running: Arc<AtomicBool>) -> Result<(), L
...
@@ -782,6 +785,9 @@ fn download_convert_model(args: &Args, running: Arc<AtomicBool>) -> Result<(), L
// Copy current process env
// Copy current process env
let
mut
envs
:
Vec
<
(
OsString
,
OsString
)
>
=
env
::
vars_os
()
.collect
();
let
mut
envs
:
Vec
<
(
OsString
,
OsString
)
>
=
env
::
vars_os
()
.collect
();
// Disable progress bar
envs
.push
((
"HF_HUB_DISABLE_PROGRESS_BARS"
.into
(),
"1"
.into
()));
// If huggingface_hub_cache is set, pass it to the download process
// If huggingface_hub_cache is set, pass it to the download process
// Useful when running inside a docker container
// Useful when running inside a docker container
if
let
Some
(
ref
huggingface_hub_cache
)
=
args
.huggingface_hub_cache
{
if
let
Some
(
ref
huggingface_hub_cache
)
=
args
.huggingface_hub_cache
{
...
@@ -832,12 +838,20 @@ fn download_convert_model(args: &Args, running: Arc<AtomicBool>) -> Result<(), L
...
@@ -832,12 +838,20 @@ fn download_convert_model(args: &Args, running: Arc<AtomicBool>) -> Result<(), L
}
}
};
};
// Redirect STDOUT to the console
let
download_stdout
=
BufReader
::
new
(
download_process
.stdout
.take
()
.unwrap
());
let
download_stdout
=
download_process
.stdout
.take
()
.unwrap
();
let
stdout
=
BufReader
::
new
(
download_stdout
);
thread
::
spawn
(
move
||
{
log_lines
(
download_stdout
.lines
());
});
let
download_stderr
=
BufReader
::
new
(
download_process
.stderr
.take
()
.unwrap
());
// We read stderr in another thread as it seems that lines() can block in some cases
let
(
err_sender
,
err_receiver
)
=
mpsc
::
channel
();
thread
::
spawn
(
move
||
{
thread
::
spawn
(
move
||
{
log_lines
(
stdout
.lines
());
for
line
in
download_stderr
.lines
()
.flatten
()
{
err_sender
.send
(
line
)
.unwrap_or
(());
}
});
});
loop
{
loop
{
...
@@ -848,12 +862,10 @@ fn download_convert_model(args: &Args, running: Arc<AtomicBool>) -> Result<(), L
...
@@ -848,12 +862,10 @@ fn download_convert_model(args: &Args, running: Arc<AtomicBool>) -> Result<(), L
}
}
let
mut
err
=
String
::
new
();
let
mut
err
=
String
::
new
();
download_process
while
let
Ok
(
line
)
=
err_receiver
.recv_timeout
(
Duration
::
from_millis
(
10
))
{
.stderr
err
=
err
+
"
\n
"
+
&
line
;
.take
()
}
.unwrap
()
.read_to_string
(
&
mut
err
)
.unwrap
();
if
let
Some
(
signal
)
=
status
.signal
()
{
if
let
Some
(
signal
)
=
status
.signal
()
{
tracing
::
error!
(
tracing
::
error!
(
"Download process was signaled to shutdown with signal {signal}: {err}"
"Download process was signaled to shutdown with signal {signal}: {err}"
...
...
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