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
renzhc
diffusers_dcu
Commits
f8325cfd
Unverified
Commit
f8325cfd
authored
Sep 08, 2022
by
Patrick von Platen
Committed by
GitHub
Sep 08, 2022
Browse files
[MPS] Make sure it doesn't break torch < 1.12 (#425)
* [MPS] Make sure it doesn't break torch < 1.12 * up
parent
8d9c4a53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/diffusers/testing_utils.py
src/diffusers/testing_utils.py
+6
-1
No files found.
src/diffusers/testing_utils.py
View file @
f8325cfd
...
@@ -5,10 +5,15 @@ from distutils.util import strtobool
...
@@ -5,10 +5,15 @@ from distutils.util import strtobool
import
torch
import
torch
from
packaging
import
version
global_rng
=
random
.
Random
()
global_rng
=
random
.
Random
()
torch_device
=
"cuda"
if
torch
.
cuda
.
is_available
()
else
"cpu"
torch_device
=
"cuda"
if
torch
.
cuda
.
is_available
()
else
"cpu"
torch_device
=
"mps"
if
torch
.
backends
.
mps
.
is_available
()
else
torch_device
is_torch_higher_equal_than_1_12
=
version
.
parse
(
version
.
parse
(
torch
.
__version__
).
base_version
)
>=
version
.
parse
(
"1.12"
)
if
is_torch_higher_equal_than_1_12
:
torch_device
=
"mps"
if
torch
.
backends
.
mps
.
is_available
()
else
torch_device
def
parse_flag_from_env
(
key
,
default
=
False
):
def
parse_flag_from_env
(
key
,
default
=
False
):
...
...
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