1. 程式人生 > >【01】win10 python3 安裝 Tensorflow-gpu 問題及解決

【01】win10 python3 安裝 Tensorflow-gpu 問題及解決

準備工作: win10 下, python3.7 安裝完成

問題#1 :需要升級pip

C:\> pip install tensorflow
Collecting tensorflow
  Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

升級pip

C:\> python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 96kB/s
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1

問題#2 版本資訊不匹配?

C:\> pip3 install --upgrade tensorflow-gpu
Collecting tensorflow-gpu
  Could not find a version that satisfies the requirement tensorflow-gpu (from versions: )
No matching distribution found for tensorflow-gpu

 分析:

從 https://pypi.org/project/tensorflow-gpu/#files 查詢的結果分析,tensorflow-gpu 相關 python 版本為 cp27, cp33, cp34, cp35, cp36  當前所安裝的版本為37,沒有提供!    解除安裝 python3.7;安裝 python 3.6.7 併為其升級pip  

問題#3  pip 下載 tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl 失敗?

C:\Users\lsq> pip install tensorflow-gpu
Collecting tensorflow-gpu
  Downloading https://files.pythonhosted.org/packages/3d/a0/60f72b76915a7c83e336e7f9ccf3a08305c30c7262cd15fedde44e026c3f/tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl (74.9MB)
    2% |▌                               | 1.5MB 136kB/s eta 0:08:59
 

手動下載 tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl :https://pypi.org/project/tensorflow-gpu/#files

本地安裝 tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl 

D:\> pip install tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl

問題#4 pip 下載 numpy-1.15.3-cp36-none-win_amd64.whl 失敗?

D:\> pip install tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl
Processing d:\tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl
Collecting six>=1.10.0 (from tensorflow-gpu==1.11.0)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting numpy>=1.13.3 (from tensorflow-gpu==1.11.0)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:830: The handshake operation timed out',))': /packages/10/b6/feaabbe393afe1ad4c803cdd7c2ada688613448e0987b016a3980b2f08c6/numpy-1.15.3-cp36-none-win_amd64.whl
  Downloading https://files.pythonhosted.org/packages/10/b6/feaabbe393afe1ad4c803cdd7c2ada688613448e0987b016a3980b2f08c6/numpy-1.15.3-cp36-none-win_amd64.whl (13.5MB)
    0% |                                | 61kB 3.7kB/s eta 1:00:02Exception:
Traceback (most recent call last):
  File "d:\programfiles\python36\lib\site-packages\pip\_vendor\urllib3\response.py", line 331, in _error_catcher
    yield

手動下載 numpy-1.15.3-cp36-none-win_amd64.whl

本地安裝 numpy : 

pip install numpy-1.15.3-cp36-none-win_amd64.whl

完成後,繼續安裝 tensorflow-gpu :

pip install tensorflow_gpu-1.11.0-cp36-cp36m-win_amd64.whl

OK!

下個問題,如何檢驗 tensorflow-gpu 是否安裝正確?