How to check if pytorch is using the GPU?

后端 未结 10 1259
既然无缘
既然无缘 2020-12-04 05:01

I would like to know if pytorch is using my GPU. It\'s possible to detect with nvidia-smi if there is any activity from the GPU during the process,

10条回答
  •  星月不相逢
    2020-12-04 05:26

    Create a tensor on the GPU as follows:

    $ python
    >>> import torch
    >>> print(torch.rand(3,3).cuda()) 
    

    Do not quit, open another terminal and check if the python process is using the GPU using:

    $ nvidia-smi
    

提交回复
热议问题