How to tell PyTorch to not use the GPU?

Before running your code, run this shell command to tell torch that there are no GPUs:

export CUDA_VISIBLE_DEVICES=""

This will tell it to use only one GPU (the one with id 0) and so on:

export CUDA_VISIBLE_DEVICES="0"

Leave a Comment