Skip to content

Limit training to CPU instead of GPU #1557

Discussion options

You must be logged in to vote

For the Cifar10 dataset, you can change what device it is on by setting a manager for it in the builder:

try(NDManager manager = NDManager.newBaseManager(Device.cpu())) {
    Cifar10 cifar10 = Cifar10.builder()
       .optManager(manager)
       ...
       .build();

    // Train and build within scope of manager
}

The other one to keep in mind is that when you create a new Model, you should create it with the CPU as well like Model.newInstance(modelName, Device.cpu()).

Finally, you will also need to set the device to CPU in your TrainingConfig as well.

Just fix those three things and you should be able to do your training on CPU only.

*Edited to include missed place to update based on co…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@AngshumanChakraborty
Comment options

@zachgk
Comment options

@AngshumanChakraborty
Comment options

Answer selected by AngshumanChakraborty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants