安裝pytorch GPU版不能使用問題


雖然我已經安裝了GPU版的pytorch,但是只能使用CPU的。

安裝的pytorch版本pytorch1.5.1-py36-cu102-cudn70

執行:

>>> import torch
>>> import torchvision
>>> torch.cuda.is_available()
False

因為anconda也確實安裝了cudatoolkit 10.2.89,不能用感覺莫名其妙,就在程序中的:

DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") # 讓torch判斷是否使用GPU

強制改成:

DEVICE = torch.device('cuda')

結果運行報錯:

AssertionError: 
The NVIDIA driver on your system is too old (found version 10010).
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.

原來是驅動版本太低,找到原因自然就好解決了。

然后重新安裝cuda10.2就可以正常使用了。

說明,之前我安裝cuda10.2的時候是自定義安裝的,只安裝了cuda,其他組件都沒有安裝。

安裝后

(base) C:\Users\Administrator>conda activate pytorch

(pytorch) C:\Users\Administrator>python
Python 3.6.10 |Anaconda, Inc.| (default, May  7 2020, 19:46:08) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True

另外,下面這里也可以查看cuda驅動版本。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM