1.直接去对应官网https://pytorch.org/get-started/locally/
选择对应的版本(我的显卡是MX150)
之后直接安装就行
1.安装之后,在ananconda里输入
import torch
torch.cuda.is_available()
输出False,然后输入下面的代码
torch.cuda.current_device()
torch.cuda.device(0)
这个会报error:
AssertionError: The NVIDIA driver on your system is too old (found version 9010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx
Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.
直接去对应的网站http://www.nvidia.com/Download/index.aspx选择好显卡种类更新驱动就行。
完成后:
import torch
torch.cuda.current_device()
Out[3]: 0
torch.cuda.device(0)
Out[4]: <torch.cuda.device at 0x2d35f156390>
torch.cuda.device_count()
Out[7]: 1
torch.cuda.get_device_name(0)
Out[8]: 'GeForce MX150'
torch.cuda.is_available()
Out[10]: True