1. 程式人生 > 其它 >2020-12-17配置Ubuntu18.04深度學習開發環境

2020-12-17配置Ubuntu18.04深度學習開發環境

技術標籤:安裝教程

一、硬體簡介

顯示卡型別:GeForce GTX 1060 mobile
顯示卡驅動:NVIDIA-SMI 450.66

二、Anaconda3安裝

Anaconda可以理解為一個python的虛擬環境管理器,包含多版本Python直譯器,常用模組,可以建立互不干擾的虛擬工作環境,各虛擬環境中可以使用不同版本的Python和模組組合。
1、下載
https://www.anaconda.com/products/individual
在這裡插入圖片描述

本次下載版本為4.9.2版本。Anaconda會自動安裝一個預設的Python,該版本對應預設Python版本為Python3.8.5版本
下載下來的檔名為Anaconda3-2020.11-Linux-x86_64.sh

2、安裝
進入下載檔案所在資料夾,開啟終端:

#輸入下行命令開始安裝
[email protected]:~$ sh Anaconda3-2020.11-Linux-x86_64.sh 

Welcome to Anaconda3 2020.11
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
#按下回車繼續安裝

Copyright 2015-2020, Anaconda, Inc.
All rights reserved under the 3-clause BSD License:
This End User License Agreement (
the "Agreement") is a legal agreement between y ou and Anaconda, Inc. ("Anaconda") and governs your use of Anaconda Individual E dition (which was formerly known as Anaconda Distribution)... #按住回車直至協議顯示完畢 Do you accept the license terms? [yes|no] #輸入yes [/home/zhangman/anaconda3] >>
> #是否安裝到預設目錄/home/zhangman/anaconda3?直接回車安裝到預設目錄 WARNING: You currently have a PYTHONPATH environment variable set. This may cause unexpected behavior when running the Python interpreter in Anaconda3. For best results, please verify that your PYTHONPATH only points to directories of packages that are compatible with the Python interpreter in Anaconda3: /home/zhangman/anaconda3 Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] [no] >>> yes #warning是因為之前安裝的ROS已經有了一個python2.7版本,這裡警告說已經由python環境存在,建議使用anaconda3管理全部python版本,不管就ok #是否使用init講Anaconda新增到環境變數中,yes

3、環境設定

安裝Anaconda3後,開啟終端會自動進入Anaconda3環境,即開頭由(base),可通過以下程式碼控制開啟終端時是否自動啟用Anaconda環境:

#手動啟用Anaconda3環境
conda activate
#手動退出Anaconda3環境
conda deactivate
#配置開啟終端時候預設不啟用Anaconda環境:
conda config --set auto_activate_base false
#配置開啟終端時候預設啟用Anaconda環境:
conda config --set auto_activate_base true

4、測試

#進入Anaconda3環境,輸入python
(base) [email protected]:~$ python
Python 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[1]+  Stopped                 python
#python版本為Anaconda3對應版本,帶有Anaconda字樣,安裝成果
#退出Anaconda3環境
(base) [email protected]:~$ conda deactivate
#此時Python為系統Python版本,無Anaconda字樣
[email protected]:~$ python
Python 2.7.17 (default, Jul 20 2020, 15:37:01) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[2]+  Stopped                 python

三、安裝CUDA

CUDA是Nvida顯示卡通用平行計算架構,能夠使得GPU解決複雜的計算問題。其版本取決與安裝的顯示卡驅動,而CUDA的版本又決定了Cudnn的版本。

1、檢視顯示卡驅動對應的CUDA版本

[email protected]:~$ nvidia-smi
Thu Dec 17 22:50:05 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.66       Driver Version: 450.66       CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+

本次安裝顯示卡驅動對應CUDA版本為11.0

四、安裝CUDNN

https://developer.nvidia.com/rdp/cudnn-archive