1. 下載最新的 tensorflow
根據自己電腦的系統和Python版本下載tensorflow,注意cpu與GPU,電腦顯卡不行的,就下cpu版本。
一些安裝機制需要TensorFlow Python軟件包的URL。您指定的值取決於您的Python版本。
版 |
網址 |
的Linux |
|
Python 2.7 GPU支持 |
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp27-cp27mu-manylinux2010_x86_64.whl |
僅Python 2.7 CPU |
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp27-cp27mu-manylinux2010_x86_64.whl |
Python 3.5 GPU支持 |
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp35-cp35m-manylinux2010_x86_64.whl |
僅限Python 3.5 CPU |
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp35-cp35m-manylinux2010_x86_64.whl |
Python 3.6 GPU支持 |
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl |
僅Python 3.6 CPU |
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl |
Python 3.7 GPU支持 |
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl |
僅Python 3.7 CPU |
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl |
macOS(僅CPU) |
|
Python 2.7 |
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp27-cp27m-macosx_10_9_x86_64.whl |
Python 3.5 |
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp35-cp35m-macosx_10_6_intel.whl |
Python 3.6 |
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp36-cp36m-macosx_10_9_x86_64.whl |
Python 3.7 |
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl |
視窗 |
|
Python 3.5 GPU支持 |
https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.1.0-cp35-cp35m-win_amd64.whl |
僅限Python 3.5 CPU |
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.1.0-cp35-cp35m-win_amd64.whl |
Python 3.6 GPU支持 |
https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.1.0-cp36-cp36m-win_amd64.whl |
僅Python 3.6 CPU |
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.1.0-cp36-cp36m-win_amd64.whl |
Python 3.7 GPU支持 |
https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-2.1.0-cp37-cp37m-win_amd64.whl |
僅Python 3.7 CPU |
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-win_amd64.whl |
Raspberry PI(僅CPU) |
|
Python 3,Pi0或Pi1 |
https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-2.1.0-cp35-none-linux_armv6l.whl |
Python 3,Pi2或Pi3 |
https://storage.googleapis.com/tensorflow/raspberrypi/tensorflow-2.1.0-cp35-none-linux_armv7l.whl |
下載之後,放到一個文件夾下面。
2. 修改pip源地址
爲什麼要修改pip源呢?安裝時候,需要下載一些包,官方的源比較慢。
(1):在windows文件管理器中,輸入 %APPDATA%
(2):會定位到一個新的目錄下,在該目錄下新建pip文件夾,然後到pip文件夾裏面去新建個pip.ini文件
(3):在新建的pip.ini文件中輸入以下內容,搞定文件路徑:"C:\Users\Administrator\AppData\Roaming\pip\pip.ini"
Pip.ini文件內容:
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
上述使用的是清華的源鏡像,還可以使用以下的國內源鏡像:(強烈建議使用清華源,其它有些坑)
V2EX:http://pypi.v2ex.com/simple
豆瓣:http://pypi.douban.com/simple
中國科學技術大學:http://pypi.mirrors.ustc.edu.cn/simple
清華:https://pypi.tuna.tsinghua.edu.cn/simple
3. 升級安裝
由於我的電腦已經安裝了tensorflow1.8,所以按照下圖所示升級,會出現不兼容的問題。
pip3 install --upgrade tensorflow_cpu-2.1.0-cp36-cp36m-win_amd64.whl
安裝最後出現錯誤:
(1)tensorflow1.8與2.1不兼容,升級2.1之前,需要手動卸載1.8
pip uninstall tensorflow
(2)cmd命令的權限不夠,需要管理員權限
卸載tensorflow1.8以後,重新安裝。
pip3 install --upgrade tensorflow_cpu-2.1.0-cp36-cp36m-win_amd64.whl
中間有些錯誤,主要是幾個包版本不對,根據紅色字體的需求,安裝相應的包即可。
安裝之後,輸入: import tensorflow, 沒有錯誤說明安裝OK
白浪介紹:
(1)關於射頻、微波、天線、無線通信、智能硬件、軟件編程、滲透安全、人工智能、區塊鏈,Java、Android、C/C++、python等綜合能力的培養提升。
(2)各種學習資料、學習軟件分享。
1.掃碼關注公衆號(Geekxiaobai)
2. 如在後臺發送“Python高級編程”“Python Graphics”或者“2003”,即可免費獲得電子書籍。僅供學習之用。
3. 掃碼關注後,查看往期內容,會有更多資料驚喜等着你來拿哦
想要更多相關學習資料,可以在文章後面留言哦。
========******=========******========******=========******==========