dawncc / TensorFlowTest

0 stars 0 forks source link

windows上安装tensorflow #4

Open dawncc opened 7 years ago

dawncc commented 7 years ago

Anaconda

Anaconda是由Python提供支持的领先的开放数据科学平台。 Anaconda的开源版本是Python和R的高性能分发版本,包括超过100个用于数据科学的最流行的Python,R和Scala软件包。

操作说明:

1. Managing conda

conda --version
conda update conda

2. Managing environments

Create and activate an environment

conda create --name snowflakes biopython

This will create a new environment named /envs/snowflakes with the program Biopython.

Activate the new environment:

Create a second environment

conda create --name bunnies python=3 astroid babel

This will create a second new environment named /envs/bunnies with Python 3 and Astroid and Babel installed.

List all environments

conda info --envs

Switch to another environment (activate/deactivate)

3. Managing Python

Check Python versions

conda search --full-name python

Install a different version of Python

conda create --name snakes python=3

4. Managing packages

View a list of packages and versions installed in an environment

conda list

Search for a package

conda search beautifulsoup4

Install a new package

conda install --name bunnies beautifulsoup4

Install a package from Anaconda.org

conda install --channel https://conda.anaconda.org/pandas bottleneck

Install a package with pip

pip install see
dawncc commented 7 years ago

安装tensorflow

目前tensorflow对python3.5支持友好

1. 创建名为tensorflow的环境

conda create --name tensorflow python=3.5

image

2. 激活环境

activate tensorflow

3. 安装tensorflow gpu版本包

-- CPU版本
pip install tensorflow
-- GPU版本
pip install tensorflow-gpu  
dawncc commented 7 years ago

安装CUDA

不安装CUDA Driver会出现如下错误:

ImportError: No module named '_pywrap_tensorflow_internal'

安装CUDA Tools

image

安装cuDNN

注意:需要下载5.1版本,6.0版本不可用 image image

Cudnn解压后将bin,include,lib三个文件夹里面的内容覆盖至Cuda安装目录下,默认路径为C:\Program Files\NVIDIA GPUComputing Toolkit\CUDA\v8.0(记住不是替换,是把Cudnn文件里的.dll文件添加到Cuda里面)

接下来,检验Cuda是否安装成功: 进入cuda路径,默认C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\demo_suite执行里面的deviceQuery.exe文件

image

dawncc commented 7 years ago

No module named 'matplotlib'

conda install matplotlib

image Anaconda上查看 image

dawncc commented 7 years ago

第一个tensorflow程序

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline
a = tf.random_normal([2, 20])
sess = tf.Session()
out = sess.run(a)
x, y = out

plt.scatter(x,y)
plt.show()

image