RTX 3090的深度學習環境配置指南:Pytorch、TensorFlow、Keras

點擊上方AI算法與圖像處理”,選擇加"星標"或“置頂

重磅乾貨,第一時間送達


   
   
   

推薦閱讀

31個Python實戰項目教你掌握圖像處理,PDF開放下載

opencv_contrib擴展模塊中文教程pdf,限時領取


轉載於: 作者丨Yukyin@知乎
來源丨https://zhuanlan.zhihu.com/p/279401802      編輯丨極市平臺


筆者中山大學研究生,醫學生+計科學生的集合體,機器學習愛好者。

最近剛入了3090,發現網上寫的各種環境配置相當混亂而且速度很慢。所以自己測了下速度最快的3090配置環境,歡迎補充!

基本環境(整個流程大約需要5分鐘甚至更少)

  
  
  
py37py38cuda11.0cudnn8.0.4tf2.5tf-nightly)或 tf1.15.4pytorch1.7keras2.3

(1)官網下載,安裝顯卡驅動:

  
  
  
bash NVIDIA-Linux-x86_64-455.23.04.run

(2)安裝Anaconda並換源

  
  
  
bash Anaconda3-5.2.0-Linux-x86_64.shvim ~/.bashrcexport PATH=/home/XXX/anaconda3/bin:$PATH(XXX爲自己的用戶名)(在文件末尾處添加該語句)source ~/.bashrc
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/conda config --set show_channel_urls yes之後vim ~/.condarc,把defaults刪掉

(3)創建虛擬環境,一般用py37或py38(以下都在虛擬環境中操作)

  
  
  
conda create -n exp38 python==3.8conda activate exp38

(4)安裝cuda11.0和pytorch1.7(不用再conda install cudatoolkit==11.0)

conda install pytorch torchvision cudatoolkit=11

(5)安裝cudnn8(因爲conda還不支持cudatoolkit=11中下載cudnn)

從https://developer.nvidia.com/rdp/cudnn-download下載cudnn,解壓後進入cuda/lib64路徑下,把裏面所有文件拷入對應虛擬環境(exp38)的lib中

(6)裝tf2.5(不要裝tensorflow-gpu==2.4.0rc0,會報錯'NoneType' object has no attribute 'TFE_MonitoringDeleteBuckets')

pip install tf-nightly-gpu -i http://pypi.douban.com/simple --trusted-host pypi.douban.compip install tf-nightly -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

(7)裝tf1.15.4

此處參考這位大佬的tf1.15.4安裝步驟
https://blog.csdn.net/wu496963386/article/details/109583045?utm_medium=distribute.wap_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.wap_blog_relevant_pic
pip install google_pasta-0.2.0-py3-none-any.whl nvidia_cublas-11.2.1.74-cp36-cp36m-linux_x86_64.whl nvidia_cuda_cupti-11.1.69-cp36-cp36m-linux_x86_64.whl nvidia_cuda_nvcc-11.1.74-cp36-cp36m-linux_x86_64.whl nvidia_cuda_nvrtc-11.1.74-cp36-cp36m-linux_x86_64.whl nvidia_cuda_runtime-11.1.74-cp36-cp36m-linux_x86_64.whl nvidia_cudnn-8.0.4.30-cp36-cp36m-linux_x86_64.whl nvidia_cufft-10.3.0.74-cp36-cp36m-linux_x86_64.whl nvidia_curand-10.2.2.74-cp36-cp36m-linux_x86_64.whl nvidia_cusolver-11.0.0.74-cp36-cp36m-linux_x86_64.whl nvidia_cusparse-11.2.0.275-cp36-cp36m-linux_x86_64.whl nvidia_dali_cuda110-0.26.0-1608709-py3-none-manylinux2014_x86_64.whl nvidia_dali_nvtf_plugin-0.26.0+nv20.10-cp36-cp36m-linux_x86_64.whl nvidia_nccl-2.7.8-cp36-cp36m-linux_x86_64.whl  nvidia_tensorrt-7.2.1.4-cp36-none-linux_x86_64.whl tensorflow_estimator-1.15.1-py2.py3-none-any.whl nvidia_tensorboard-1.15.0+nv20.10-py3-none-any.whlnvidia_tensorflow-1.15.4+nv20.10-cp36-cp36m-linux_x86_64.whl -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

(8)裝keras2.3

pip install keras==2.3 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

(9)測試(使用cuda10.2也可以測試使用gpu,但貌似不能把數據寫入gpu)

pytorch

tensorflow-2.5或1.15.4

keras(測試需要改部分源碼_get_available_gpus())

  
  
  
import tensorflow as tfimport keras.backend.tensorflow_backend as tfbackprint("tf.__version__ is", tf.__version__)print("tf.keras.__version__ is:", tf.keras.__version__) def _get_available_gpus():    if tfback._LOCAL_DEVICES is None:        devices = tf.config.list_logical_devices()        tfback._LOCAL_DEVICES = [x.name for x in devices]    return [x for x in tfback._LOCAL_DEVICES if 'device:gpu' in x.lower()]tfback._get_available_gpus = _get_available_gpus
from keras import backend as KK.tensorflow_backend._get_available_gpus()

後記:實際3090需要cuda11.1,但pytorch和tf目前只支持11.0。而且講真不需要單獨配cuda、cudnn,在虛擬環境裏搞就行了。


  
     
     
     
個人微信(如果沒有備註不拉羣!
請註明: 地區+學校/企業+研究方向+暱稱



下載1:何愷明頂會分享


AI算法與圖像處理」公衆號後臺回覆:何愷明,即可下載。總共有6份PDF,涉及 ResNet、Mask RCNN等經典工作的總結分析


下載2:終身受益的編程指南:Google編程風格指南


AI算法與圖像處理」公衆號後臺回覆:c++,即可下載。歷經十年考驗,最權威的編程規範!




   
   
   
下載3 CVPR2020

AI算法與圖像處公衆號後臺回覆: CVPR2020 即可下載1467篇CVPR 2020論文


覺得不錯就點亮在看吧


本文分享自微信公衆號 - AI算法與圖像處理(AI_study)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。

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