Skip to content

Commit 9eb8734

Browse files
louie-tsaiguangyey
andcommitted
Update recipes_source/recipes/profiler_recipe.py
Co-authored-by: Yu, Guangye <106960996+guangyey@users.noreply.github.com>
1 parent 6e6c103 commit 9eb8734

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

recipes_source/recipes/profiler_recipe.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@
163163
######################################################################
164164
# Profiler can also be used to analyze performance of models executed on GPUs and XPUs:
165165
# Users could switch between cpu, cuda and xpu
166-
device = 'cuda'
166+
if torch.cuda.is_available():
167+
device = 'cuda'
168+
elif torch.xpu.is_available():
169+
device = 'xpu'
170+
else:
171+
device = 'cpu'
167172

168173
activities = [ProfilerActivity.CPU]
169174
sort_by_keyword = device + "_time_total"

0 commit comments

Comments
 (0)