天天看點

Anaconda+Opencv+Tensorflow安裝 (Ubuntu/Windows) (cpu/gpu)

安裝Anaconda 4.2 + OpenCV 3.1

1. 下載下傳并安裝Anaconda4.2.0 

所有的Anaconda版本,Linux選Anaconda3-4.2.0-Linux-x86_64.sh

Windows選Anaconda3-4.2.0-Windows-x86_64.exe

注意系統是64位,Tensorflow隻支援windows64位。

(https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/)

2. 打開cmd,然後執行(這個網站可能位址不穩定,多試幾次)

conda install -c https://conda.anaconda.org/menpo opencv3

3.  打開Spyder測試一下代碼.

import cv2

print(cv2.__version__)

安裝CPU/GPU版TensorFlow

1. 安裝Anaconda4.2版( )

2. 建立conda環境:使用管理者權限打開cmd,執行指令conda create -n tensorflow

Anaconda+Opencv+Tensorflow安裝 (Ubuntu/Windows) (cpu/gpu)

3. 激活conda環境:執行指令activate tensorflow (ubuntu為Source activate tensorflow)

Anaconda+Opencv+Tensorflow安裝 (Ubuntu/Windows) (cpu/gpu)

4. 在tensorflow環境下,使用pip安裝CPU版TensorFlow,執行指令

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl

Anaconda+Opencv+Tensorflow安裝 (Ubuntu/Windows) (cpu/gpu)

測試TensorFlow

1. 使用管理者權限打開cmd

2. 激活conda環境,執行activate tensorflow

3. 打開python,執行python               

Anaconda+Opencv+Tensorflow安裝 (Ubuntu/Windows) (cpu/gpu)

4. 執行以下代碼

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')

sess = tf.Session()

print(sess.run(hello))

再次使用的時候再激活 :-)

$ source activate tensorflow

(tensorflow)$  # Your prompt should change.

# Run Python programs that use TensorFlow.

...

# When you are done using TensorFlow, deactivate the environment.

(tensorflow)$ source deactivate

繼續閱讀