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
e9669a40
Unverified
Commit
e9669a40
authored
May 23, 2023
by
OlivierDehaene
Committed by
GitHub
May 23, 2023
Browse files
feat(server): do not use device_map auto on single GPU (#362)
parent
cfaa8580
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
server/text_generation_server/models/causal_lm.py
server/text_generation_server/models/causal_lm.py
+4
-1
server/text_generation_server/models/seq2seq_lm.py
server/text_generation_server/models/seq2seq_lm.py
+4
-1
No files found.
server/text_generation_server/models/causal_lm.py
View file @
e9669a40
...
@@ -468,9 +468,12 @@ class CausalLM(Model):
...
@@ -468,9 +468,12 @@ class CausalLM(Model):
model_id
,
model_id
,
revision
=
revision
,
revision
=
revision
,
torch_dtype
=
dtype
,
torch_dtype
=
dtype
,
device_map
=
"auto"
if
torch
.
cuda
.
is_available
()
else
None
,
device_map
=
"auto"
if
torch
.
cuda
.
is_available
()
and
torch
.
cuda
.
device_count
()
>
1
else
None
,
load_in_8bit
=
quantize
==
"bitsandbytes"
,
load_in_8bit
=
quantize
==
"bitsandbytes"
,
)
)
if
torch
.
cuda
.
is_available
()
and
torch
.
cuda
.
device_count
()
==
1
:
model
=
model
.
cuda
()
tokenizer
.
pad_token_id
=
(
tokenizer
.
pad_token_id
=
(
model
.
config
.
pad_token_id
model
.
config
.
pad_token_id
if
model
.
config
.
pad_token_id
is
not
None
if
model
.
config
.
pad_token_id
is
not
None
...
...
server/text_generation_server/models/seq2seq_lm.py
View file @
e9669a40
...
@@ -518,9 +518,12 @@ class Seq2SeqLM(Model):
...
@@ -518,9 +518,12 @@ class Seq2SeqLM(Model):
model_id
,
model_id
,
revision
=
revision
,
revision
=
revision
,
torch_dtype
=
dtype
,
torch_dtype
=
dtype
,
device_map
=
"auto"
if
torch
.
cuda
.
is_available
()
else
None
,
device_map
=
"auto"
if
torch
.
cuda
.
is_available
()
and
torch
.
cuda
.
device_count
()
>
1
else
None
,
load_in_8bit
=
quantize
==
"bitsandbytes"
,
load_in_8bit
=
quantize
==
"bitsandbytes"
,
)
)
if
torch
.
cuda
.
is_available
()
and
torch
.
cuda
.
device_count
()
==
1
:
model
=
model
.
cuda
()
tokenizer
=
AutoTokenizer
.
from_pretrained
(
tokenizer
=
AutoTokenizer
.
from_pretrained
(
model_id
,
revision
=
revision
,
padding_side
=
"left"
,
truncation_side
=
"left"
model_id
,
revision
=
revision
,
padding_side
=
"left"
,
truncation_side
=
"left"
)
)
...
...
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