【深度學習004】環境搭建 install tensorflow-gpu=1.13 + anaconda + python3.6

安裝過程

  1. 安裝 anaconda ,注意安裝的版本號。https://blog.csdn.net/qq_39782872/article/details/89335574

  2. 創建一個虛擬環境 conda create -n 自定義名字 pip python=3.6 // python版本也可以定製

  3. 激活環境 : source activate 名字

  4. 安裝tensorflow :conda install tensorflow-gpu //也可指定版本號

  5. 檢測安裝結果


操作實錄:


li@li-System-Product-Name:~$ conda --version
conda 4.5.4
li@li-System-Product-Name:~$ echo $PATH
/home/li/anaconda3/bin:/usr/local/cuda-10.0/bin:/usr/local/cuda-10.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
   $ conda create -n tensorflow pip python=3.6       # select python version
li@li-System-Product-Name:~$ source activate tensorflow
(tensorflow) li@li-System-Product-Name:~$ ls
anaconda3         Documents         Music                     Public
cudnn_samples_v7  Downloads         NVIDIA_CUDA-10.0_Samples  Templates
Desktop           examples.desktop  Pictures                  Videos

(tensorflow) li@li-System-Product-Name:~$ conda install tensorflow-gpu
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.5.4
  latest version: 4.6.14

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: /home/li/anaconda3/envs/tensorflow

  added / updated specs: 
    - tensorflow-gpu


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    keras-applications-1.0.7   |             py_0          33 KB
    astor-0.7.1                |           py36_0          43 KB
    cupti-10.0.130             |                0         1.8 MB
    _tflow_select-2.1.0        |              gpu           2 KB
    grpcio-1.16.1              |   py36hf8bcb03_1         1.1 MB
    keras-preprocessing-1.0.9  |             py_0          35 KB
    mkl_fft-1.0.12             |   py36ha843d7b_0         172 KB
    pbr-5.1.3                  |             py_0          74 KB
    numpy-1.16.3               |   py36h7e9f1db_0          49 KB
    tensorboard-1.13.1         |   py36hf484d3e_0         3.3 MB
    protobuf-3.7.1             |   py36he6710b0_0         656 KB
    gast-0.2.2                 |           py36_0         138 KB
    c-ares-1.15.0              |       h7b6447c_1          98 KB
    tensorflow-gpu-1.13.1      |       h0d30ee6_0           2 KB
    mock-2.0.0                 |           py36_0         104 KB
    libgfortran-ng-7.3.0       |       hdf63c60_0         1.3 MB
    cudnn-7.3.1                |       cuda10.0_0       385.1 MB
    cudatoolkit-10.0.130       |                0       380.0 MB
    h5py-2.9.0                 |   py36h7918eee_0         1.2 MB
    mkl-2019.3                 |              199       203.3 MB
    six-1.12.0                 |           py36_0          22 KB
    scipy-1.2.1                |   py36h7c811a0_0        17.7 MB
    absl-py-0.7.1              |           py36_0         157 KB
    tensorflow-1.13.1          |gpu_py36h3991807_0           4 KB
    mkl_random-1.0.2           |   py36hd81dba3_0         407 KB
    hdf5-1.10.4                |       hb1b8bf9_0         5.3 MB
    werkzeug-0.15.2            |             py_0         263 KB
    tensorflow-estimator-1.13.0|             py_0         205 KB
    libprotobuf-3.7.1          |       hd408876_0         4.7 MB
    markdown-3.1               |           py36_0         113 KB
    numpy-base-1.16.3          |   py36hde5b4d6_0         4.4 MB
    tensorflow-base-1.13.1     |gpu_py36h8d69cac_0       293.8 MB
    intel-openmp-2019.3        |              199         886 KB
    termcolor-1.1.0            |           py36_1           7 KB
    ------------------------------------------------------------
                                           Total:        1.28 GB

The following NEW packages will be INSTALLED:

    _tflow_select:        2.1.0-gpu                
    absl-py:              0.7.1-py36_0             
    astor:                0.7.1-py36_0             
    blas:                 1.0-mkl                  
    c-ares:               1.15.0-h7b6447c_1        
    cudatoolkit:          10.0.130-0               
    cudnn:                7.3.1-cuda10.0_0         
    cupti:                10.0.130-0               
    gast:                 0.2.2-py36_0             
    grpcio:               1.16.1-py36hf8bcb03_1    
    h5py:                 2.9.0-py36h7918eee_0     
    hdf5:                 1.10.4-hb1b8bf9_0        
    intel-openmp:         2019.3-199               
    keras-applications:   1.0.7-py_0               
    keras-preprocessing:  1.0.9-py_0               
    libgfortran-ng:       7.3.0-hdf63c60_0         
    libprotobuf:          3.7.1-hd408876_0         
    markdown:             3.1-py36_0               
    mkl:                  2019.3-199               
    mkl_fft:              1.0.12-py36ha843d7b_0    
    mkl_random:           1.0.2-py36hd81dba3_0     
    mock:                 2.0.0-py36_0             
    numpy:                1.16.3-py36h7e9f1db_0    
    numpy-base:           1.16.3-py36hde5b4d6_0    
    pbr:                  5.1.3-py_0               
    protobuf:             3.7.1-py36he6710b0_0     
    scipy:                1.2.1-py36h7c811a0_0     
    six:                  1.12.0-py36_0            
    tensorboard:          1.13.1-py36hf484d3e_0    
    tensorflow:           1.13.1-gpu_py36h3991807_0
    tensorflow-base:      1.13.1-gpu_py36h8d69cac_0
    tensorflow-estimator: 1.13.0-py_0              
    tensorflow-gpu:       1.13.1-h0d30ee6_0        
    termcolor:            1.1.0-py36_1             
    werkzeug:             0.15.2-py_0              

Proceed ([y]/n)? y


Downloading and Extracting Packages
keras-applications-1 |   33 KB | #################################################### | 100% 
astor-0.7.1          |   43 KB | #################################################### | 100% 
cupti-10.0.130       |  1.8 MB | #################################################### | 100% 
_tflow_select-2.1.0  |    2 KB | #################################################### | 100% 
grpcio-1.16.1        |  1.1 MB | #################################################### | 100% 
keras-preprocessing- |   35 KB | #################################################### | 100% 
mkl_fft-1.0.12       |  172 KB | #################################################### | 100% 
pbr-5.1.3            |   74 KB | #################################################### | 100% 
numpy-1.16.3         |   49 KB | #################################################### | 100% 
tensorboard-1.13.1   |  3.3 MB | #################################################### | 100% 
protobuf-3.7.1       |  656 KB | #################################################### | 100% 
gast-0.2.2           |  138 KB | #################################################### | 100% 
c-ares-1.15.0        |   98 KB | #################################################### | 100% 
tensorflow-gpu-1.13. |    2 KB | #################################################### | 100% 
mock-2.0.0           |  104 KB | #################################################### | 100% 
libgfortran-ng-7.3.0 |  1.3 MB | #################################################### | 100% 
cudnn-7.3.1          | 385.1 MB | ################################################### | 100% 
cudatoolkit-10.0.130 | 380.0 MB | ################################################### | 100% 
h5py-2.9.0           |  1.2 MB | #################################################### | 100% 
mkl-2019.3           | 203.3 MB | ################################################### | 100% 
six-1.12.0           |   22 KB | #################################################### | 100% 
scipy-1.2.1          | 17.7 MB | #################################################### | 100% 
absl-py-0.7.1        |  157 KB | #################################################### | 100% 
tensorflow-1.13.1    |    4 KB | #################################################### | 100% 
mkl_random-1.0.2     |  407 KB | #################################################### | 100% 
hdf5-1.10.4          |  5.3 MB | #################################################### | 100% 
werkzeug-0.15.2      |  263 KB | #################################################### | 100% 
tensorflow-estimator |  205 KB | #################################################### | 100% 
libprotobuf-3.7.1    |  4.7 MB | #################################################### | 100% 
markdown-3.1         |  113 KB | #################################################### | 100% 
numpy-base-1.16.3    |  4.4 MB | #################################################### | 100% 
tensorflow-base-1.13 | 293.8 MB | ################################################### | 100% 
intel-openmp-2019.3  |  886 KB | #################################################### | 100% 
termcolor-1.1.0      |    7 KB | #################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(tensorflow) li@li-System-Product-Name:~$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> a = tf.constant([1.0,2.0],name="a")
>>> b = tf.constant([2.0,3.0],name="b")
>>> result = a+b
>>> sess = tf.Session()
2019-05-01 21:35:22.615921: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
2019-05-01 21:35:22.647831: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3600000000 Hz
2019-05-01 21:35:22.649415: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x561225cebce0 executing computations on platform Host. Devices:
2019-05-01 21:35:22.649464: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): <undefined>, <undefined>
2019-05-01 21:35:22.894973: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x561224f9fab0 executing computations on platform CUDA. Devices:
2019-05-01 21:35:22.895041: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): GeForce RTX 2080 Ti, Compute Capability 7.5
2019-05-01 21:35:22.895940: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: 
name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.635
pciBusID: 0000:65:00.0
totalMemory: 10.73GiB freeMemory: 10.51GiB
2019-05-01 21:35:22.895984: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
2019-05-01 21:35:22.898182: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-05-01 21:35:22.898210: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 
2019-05-01 21:35:22.898225: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N 
2019-05-01 21:35:22.898974: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10222 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:65:00.0, compute capability: 7.5)
>>> sess.run(result)
array([3., 5.], dtype=float32)
>>> 
[1]+  Stopped                 python
(tensorflow) li@li-System-Product-Name:~$ 

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