["python","machine-learning","deep-learning","pytorch","gpu"]
How to tell PyTorch to not use the GPU?

I want to do some timing comparisons between CPU & GPU as well as some profiling and would like to know if there's a way to tell pytorch to not use the GPU and instead use the CPU only? I realize I could install another CPU-only pytorch, but hoping there's an easier way.
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"