Skip to content

Commit

Permalink
[fix] device_lib.list_local_devices() may run fail in some case, then…
Browse files Browse the repository at this point in the history
… use CPU as default device.
  • Loading branch information
MoFHeka authored and rhdong committed Sep 17, 2024
1 parent e85da20 commit 07cdb8e
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,14 @@ def default_partition_fn(keys, shard_num):
self.short_file_name = short_file_name

def _get_default_devices():
gpu_list = [
x.name
for x in device_lib.list_local_devices()
if x.device_type == "GPU"
]
try:
gpu_list = [
x.name
for x in device_lib.list_local_devices()
if x.device_type == "GPU"
]
except:
gpu_list = []
return gpu_list[0:1] or [
"/CPU:0",
]
Expand Down

0 comments on commit 07cdb8e

Please sign in to comment.