Skip to content

Commit

Permalink
Merge pull request #3122 from naoto0804/not-use-get_device-in-examples
Browse files Browse the repository at this point in the history
Remove get_device from examples
  • Loading branch information
niboshi committed Aug 14, 2017
1 parent cfad351 commit aa76d8a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/cifar/train_cifar_custom_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def main():

model = L.Classifier(models.VGG.VGG(class_labels))
if args.gpu >= 0:
chainer.cuda.get_device(args.gpu).use() # Make a specified GPU current
# Make a specified GPU current
chainer.cuda.get_device_from_id(args.gpu).use()
model.to_gpu() # Copy the model to the GPU

optimizer = chainer.optimizers.MomentumSGD(args.learnrate)
Expand Down
2 changes: 1 addition & 1 deletion examples/reinforcement_learning/ddpg_pendulum.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def main():
env.action_space.low, env.action_space.high,
n_units=args.unit)
if args.gpu >= 0:
chainer.cuda.get_device(args.gpu).use()
chainer.cuda.get_device_from_id(args.gpu).use()
Q.to_gpu(args.gpu)
policy.to_gpu(args.gpu)
target_Q = copy.deepcopy(Q)
Expand Down
2 changes: 1 addition & 1 deletion examples/reinforcement_learning/dqn_cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def main():
# Initialize a model and its optimizer
Q = QFunction(obs_size, n_actions, n_units=args.unit)
if args.gpu >= 0:
chainer.cuda.get_device(args.gpu).use()
chainer.cuda.get_device_from_id(args.gpu).use()
Q.to_gpu(args.gpu)
target_Q = copy.deepcopy(Q)
opt = optimizers.Adam(eps=1e-2)
Expand Down

0 comments on commit aa76d8a

Please sign in to comment.