windows7+cuda10.1+pytorch1.4搭建GPU深度學習環境

初始狀態:win7、GeForce GTX 1050 Ti

查看顯卡驅動是否安裝

https://jingyan.baidu.com/article/f0e83a2556f03e22e5910123.html

安裝anaconda5.2

https://jingyan.baidu.com/article/eae078275a31851fec5485b8.html,安裝很簡單

修改鏡像爲清華源,這樣之後的安裝下載會快很多

按這個教程,https://www.jianshu.com/p/9c6b7fc4f1d9,可能通道不夠,可以繼續添加鏡像,我現在的配置文件:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

新建虛擬環境

conda create --name pytorch1.4 python=3.6

上面的name後面的一項是環境名,這裏我設的是pytorch1.4,最後一項是你要配的python版本

新建之後激活環境

activate

conda activate pytorch1.4

相關的管理命令:https://blog.csdn.net/u014628771/article/details/80066624

安裝pytorch

先查清楚自己的顯卡可以對應到多少的CUDA,目前最新的pytorch1.4支持cuda9.2和10.1,如果你的顯卡跟不上,可能需要下歷史版本,pytorch最低似乎可以支持cuda7.0的

這裏我直接用官方給的命令行安裝

pytorch官方網址: https://pytorch.org/get-started/locally/

如果太慢或者連接失敗就去掉-c和之後的,用國內鏡像源裝

之後在cmd中檢測安裝成功,同樣是在已激活的環境內,導入命令不報錯就沒問題。

pycharm修改設置

因爲我真正寫代碼用的是pycharm,所以新建項目的時候要記得改設置,用conda新建環境裏的python,

教程:https://www.cnblogs.com/yuxuefeng/articles/9235431.html

另外,之後的項目中所安裝的依賴也要激活進到pytorch1.4環境裏安裝,個人認爲anconda管理環境的功能真的很好用,不同項目需要的cuda不同可以區別開用。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章