1. 程式人生 > >安裝Python3.5和Tensorflow中遇到的問題

安裝Python3.5和Tensorflow中遇到的問題

1.安裝Python3.5

在cmd中輸入conda create --name python35 python=3.5 ,如果一次不成功可以多試幾次


如圖所示:

輸入activate python35進入Python3.5環境中

輸入deactivate退出

查詢conda環境

conda info --envs


2.安裝TensorFlow

如上圖所示,安裝過程出現錯誤

使用指令pip install --upgrade tensorflow

還會有錯誤


仔細看報錯資訊:

socket.timeout:the read operation timed out

出現超時錯誤,則需要設定超時時間

輸入指令:

pip --default-timeout=100 install -U tensorflow

或pip --default-timeout=100 install --upgrade tensorflow

最後則可以安裝成功


測試一下Tensorflow能不能使用:


可以使用但是報了一行提醒:

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

這個是什麼意思呢?

Modern CPUs provide a lot of low-level instructions, besides the usual arithmetic and logic, known as extensions, e.g. SSE2, SSE4, AVX, etc. From the 

Wikipedia:

Advanced Vector Extensions (AVX) are extensions to the x86 instruction set architecture for microprocessors from Intel and AMD proposed by Intel in March 2008 and first supported by Intel with the Sandy Bridge processor shipping in Q1 2011 and later on by AMD with the Bulldozer processor shipping in Q3 2011. AVX provides new features, new instructions and a new coding scheme.

In particular, AVX introduces fused multiply-accumulate (FMA) operations, which speed up linear algebra computation, namely dot-product, matrix multiply, convolution, etc. Almost every machine-learning training involves a great deal of these operations, hence will be faster on a CPU that supports AVX and FMA (up to 300%). The warning states that your CPU does support AVX (hooray!).

I'd like to stress here: it's all about CPU only.

Why isn't it used then?

Because tensorflow default distribution is built without CPU extensions, such as SSE4.1, SSE4.2, AVX, AVX2, FMA, etc. The default builds (ones from pip install tensorflow) are intended to be compatible with as many CPUs as possible. Another argument is that even with these extensions CPU is a lot slower than a GPU, and it's expected for medium- and large-scale machine-learning training to be performed on a GPU.

What should you do?

If you have a GPU, you shouldn't care about AVX support, because most expensive ops will be dispatched on a GPU device (unless explicitly set not to). In this case, you can simply ignore this warning by

# Just disables the warning, doesn't enable AVX/FMA
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

... or by setting export TF_CPP_MIN_LOG_LEVEL=2 if you're on Unix. Tensorflow is working fine anyway, but you won't see these annoying warnings.

If you don't have a GPU and want to utilize CPU as much as possible, you should build tensorflow from the source optimized for your CPU with AVX, AVX2, and FMA enabled if your CPU supports them. It's been discussed in this question and also this GitHub issue. Tensorflow uses an ad-hoc build system called bazel and building it is not that trivial, but is certainly doable. After this, not only will the warning disappear, tensorflow performance should also improve.

或者還有一種解決方法,還沒有嘗試:

相關推薦

安裝Python3.5Tensorflow遇到的問題

1.安裝Python3.5在cmd中輸入conda create --name python35 python=3.5 ,如果一次不成功可以多試幾次如圖所示:輸入activate python35進入Python3.5環境中輸入deactivate退出查詢conda環境con

解決已安裝python2.7 來安裝python3.5的共存安裝問題及Anoconda安裝及搭建:cpu的TensorFlow,Keras

首先背景win10的64位,我已經安裝python2.7.10在C盤,而且我這個是裝cpu版本的tensorflow 介紹一下pycharm可以支援2.7和3.5 Anoconda僅支援3.5 python3.5自帶pip不用下載,不用python2.7這麼麻煩 /我這個方法和別人不一樣,不

解決已安裝python2.7 來安裝python3.5的共存安裝問題及Anoconda安裝及搭建:TensorFlow、Keras

首先背景win10的64位,我已經安裝python2.7.10在C盤 介紹一下pycharm可以支援2.7和3.5 Anoconda僅支援3.5 python3.5自帶pip不用下載,不用python2.7這麼麻煩 /我這個方法和別人不一樣,不刪除任何東西,py

CentOS7安裝Python3.5

1.下載 2.上傳到伺服器 3. 安裝相關依賴 yum install gcc openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel 4. 解壓

Linux安裝python3.6第三方庫

res mod 是否 cif nload 可能 sql curses start Linux中安裝python3.6和第三方庫 如果本機安裝了python2,盡量不要管他,使用python3運行python腳本就好,因為可能有程序依賴目前的python2環境,比如yum!

Linux 下 pip 升級遇到的問題 python3.5 安裝 python pip

You are using pip version 8.1.1, however version 9.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' com

win10_64位下安裝anaconda+python3.5.2+tensorflow-gpu

步驟簡介: 安裝CUDA : CUDA8_win10 版本 安裝cuDNN : cuDNN6.0_win10 版本 安裝Anaconda最新版 安裝python3.5.2 安裝tensorFlow : 1.3 版本 安裝過程: 1、安裝CUDA和cuDNN

ubuntu安裝python3.5+pycharm+anaconda+keras(theano+tensorflow)(非GPU)

一,切換python版本為3.5 裝好ubuntu,python版本是2.7的 我自己安裝並更改開啟為python3.5 sudo apt-get install python3.5 設定優先順序和預設環境: sudo update-alternatives -

在 ubuntu 安裝 python3.5、 tornado、 pymysql

手動 目錄 dea 2.7 本地 pro lin ubunt data- 一、在 ubuntu 中安裝 python3.5 1、首先,在系統中是自帶python2.7的。不要卸載,因為一些系統的東西是需要這個的。python2.7和python3.5是可以共存的。 命

Centos7安裝python3.5

python3.5CentOS 7自帶的Python版本為2.7,首先需要升級到3.5版本。由於舊版本的Python已被深度依賴,所以不能卸載原有的Python,只能全新安裝。1、下載Python3.5wget -P /usr/local/src https://www.python.org/ftp/pyth

Linux下安裝Python3.x第三方庫

方便 tls libpcap 輸入 zlib cert ase $path pip安裝 如果本機安裝了python2,盡量不要管他,使用python3運行python腳本就好,因為可能有程序依賴目前的python2環境, 比如yum!!!!! 不要動現有的python2環境

Linux下安裝Python3.6第三方庫

python安裝一、安裝Python-3.6.2.tgz安裝依賴環境最小化安裝Redhat6.4環境下yum -y install gcc make zlib-devel bzip2-devel ncurses-devel readline-devel(yum -y install gcc mak

ubuntu12.04下安裝Python3.5.2

.py http image clas ubuntu body eas conf inf 1 下載源碼包 (https://www.python.org/downloads/release/python-352/) 2 解壓Python-3.5.2.tar.xz 3 s

python3.5python3.6關於json模塊的區別

code rac 數據 ast lin not std cal __init__ python3.5中   無法反序列化bytes數據必須decode成str才可以 >>> import json >>> a = b‘{"usernam

linux----安裝Python3.5

src div 目錄 bin 數字 我的linux python的安裝 完成後 無法 一、從官網下載Python的安裝包。 下載地址:https://www.python.org/ftp/python/3.5.0/ 下載軟件:Python-3.5.0.tgz 備註:具體的安

ubuntu14.04安裝python3.6pip9.0.1

系統 efi 歐洲 clas 折騰 span 解壓縮 pytho col 前提: ubuntu14.04自帶python2.7和python3.4,如下: 要想安裝python3.6,建議不要動之前的2.7和3.6(血一般的教訓) 下面我們切入正題: 安裝python3

騰訊雲centos安裝python3.6pip

ubunt tmp pen -- 教程 ots pip pan 更改 不知道騰訊雲的centos和阿裏雲的centos一不一樣,反正兩個雲平臺的Ubuntu系統是不一樣的,照著同樣的教程敲,往往掉坑裏。 安裝一些centos依賴庫: 這一步很關鍵,很多報錯往往都因為少了

Linux下安裝Python3.5.2、Django、paramiko

roo help 更新 pip3 sim egg pan man inf 1,安裝依賴文件: yum install zlib zlib-devel openssl openssl-devel 2,下載Python3.5.2: 安全連接時,要增加:--no-chec

CentOS安裝python3.5.0

prefix == ica build kernel pip3 ack ffi pen 1安裝編譯工具yum install zlib-devel bzip2-devel openssl-devel python-devel kernel-devel libffi-deve

centos7安裝python3.5後文件不相容問題

原始碼安裝python3.5           1.      準備環境                 &nbs