Skip to content

Commit

Permalink
fix(nyz): fix policy set device bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PaParaZz1 committed Jun 1, 2022
1 parent 43f6f01 commit 1e0c4a1
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions ding/policy/base_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def __init__(
if len(set(self._enable_field).intersection(set(['learn']))) > 0:
self._rank = get_rank() if self._cfg.learn.multi_gpu else 0
if self._cuda:
torch.cuda.set_device(self._rank % torch.cuda.device_count())
model.cuda()
if self._cfg.learn.multi_gpu:
bp_update_sync = self._cfg.learn.get('bp_update_sync', True)
Expand All @@ -84,7 +83,6 @@ def __init__(
else:
self._rank = 0
if self._cuda:
torch.cuda.set_device(self._rank % torch.cuda.device_count())
model.cuda()
self._model = model
self._device = 'cuda:{}'.format(self._rank % torch.cuda.device_count()) if self._cuda else 'cpu'
Expand Down

0 comments on commit 1e0c4a1

Please sign in to comment.