機器學習 1) 環境安裝

2021-08-16 15:11:49 字數 2625 閱讀 1335

先嘗試嘗試tensorflow

1. 修改/etc/hosts/ 加入如下行

#tensorflow start 

64.233.188.121 www.tensorflow.org

#tensorflow end

2. 進入官網後有這些選項

選擇anaconda install

3. anaconda 安裝

進入清華映象

執行

chmod +x anaconda2-5.1.0-linux-x86_64.sh
./anaconda2-5.1.0-linux-x86_64.sh
加入conda源

conda config --add channels 

conda config --add channels

conda config --set show_channel_urls yes

3. 安裝tensorflow

建立tensorflow虛擬環境

conda create -n tensorflow python=2.7

因為要使用gpu,使用pip進行安裝

$ source activate tensorflow

(tensorflow)$ # your prompt should change

設定binary安裝路徑

# ubuntu/linux 64-bit, gpu enabled, python 2.7

# requires cuda toolkit 8.0 and cudnn v5. for other versions, see "installing from sources" below.

(tensorflow)$ export tf_binary_url=

安裝 test flow

# python 2

(tensorflow)$ pip install --ignore-installed --upgrade $tf_binary_url

3. 啟用gpu support

1. 安裝gtx 1060的驅動

參照:
2. 安裝cuda

`sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb`

`sudo apt-get update`

`sudo apt-get install cuda`

3.download cudnn 5.0

tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz

sudo cp -p cuda/include/cudnn.h /usr/local/cuda/include

sudo cp -p cuda/lib64/libcudnn* /usr/local/cuda/lib64

sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

4. 新增如下的引數到.profile檔案中

export ld_library_path="$ld_library_path:/usr/local/cuda/lib64:/usr/local/cuda/extras/cupti/lib64"

export cuda_home=/usr/local/cuda

4. 測試

啟用tesorflow環境

source activate tensorflow
hello world!

$ python

...>>> import tensorflow as tf

>>> hello = tf.constant('hello, tensorflow!')

>>> sess = tf.session()

>>> print(sess.run(hello))

hello, tensorflow!

>>> a = tf.constant(10)

>>> b = tf.constant(32)

>>> print(sess.run(a + b))

42>>>

手寫識別

進入下面這個命令的執行結果的目錄

$ python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'

執行

python -m tensorflow.models.image.mnist.convolutional

機器學習 1) 環境安裝

先嘗試嘗試tensorflow 1.修改 etc hosts 加入如下行 tensorflow start 64.233.188.121 www.tensorflow.org tensorflow end 2.進入官網後有這些選項 選擇anaconda install 3.anaconda 安裝 進...

Dart 入門學習(1) 環境安裝

寫在前面 最近同事介紹說flutter不錯,想學習一下,於是就看了看。flutter 使用 dart 寫的,所以需要先學習一下dart 語言。環境安裝 我是用的mac,所以這裡記錄下mac 安裝的方法。1.安裝dart sdk 使用homebrew,執行命令 brew tap dart lang d...

機器學習筆記(一) 環境安裝

同時推薦乙個很好地python資源庫,可以幫助大家找到很多適合自己電腦環境的模組檔案 我的電腦環境 win10,64bit 配置步驟 1 將安裝目錄下的d anaconda和d anaconda scripts放到電腦環境變數中。2 安裝mingw用於提供c語言編譯需要安裝的模組,在cmd裡面直接輸...