windows10+python3.6+tensorflow-gpu+keras+pytorch(原生态和anaconda两种环境安装)详细安装

当前环境描述:Win10 64位,Python3.6


1、下载安装Cuda9.0

网址:

https://developer.nvidia.com/cuda-90-download-archive?target_os=Windows&target_arch=x86_64&target_version=10

注意:搜索CUDA进入下载界面默认下载最新的9.1版本,不要下这个版本

步骤:搜索cuda9,进入后点击下载,下载完成直接安装即可

安装完成后 在shell窗口下,输入命令nvcc -V

即可查看版本信息


测试安装是否成功:


C:\Users\ZX>nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation

Built onFri_Sep__1_21:08:32_Central_Daylight_Time_2017

Cuda compilation tools, release 9.0,V9.0.176


2、下载安装Cudnn9.0、添加进path

网址:https://developer.nvidia.com/rdp/cudnn-download

注意:下载Cudnn会需要注册,并且完成问卷调查

步骤:下载完成后为安装包形式,解压后,将文件夹下面的bin目录添加到系统path变量里面


cudnn下载后应该是一个压缩文件,解压完是一个cuda的文件夹,然后cuda文件夹下有bin,lib,include三个文件夹。


然后将这三个文件夹内的文件分别加入到cuda安装目录下的 bin,lib,include三个文件夹中




3、安装tensorFlow

在windows cmd窗口输入:

pip install --ignore-installed --upgradetensorflow-gpu==1.6.0

即可安装1.6.0版本的tensorflow,注意1.6版本的tensorflow必须安装9.0的cuda以及对应的cudnn,别的版本需要看tensorflow给的报错提示


Collecting tensorflow-gpu==1.6.0

 Downloadinghttps://files.pythonhosted.org/packages/89/65/73b33592e53ad205582cc800b72083012fb8335830bb3ac1533739db2983/tensorflow_gpu-1.6.0-cp36-cp36m-win_amd64.whl(85.9MB)

   100% |████████████████████████████████| 85.9MB 56kB/s

Collecting gast>=0.2.0 (fromtensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/5c/78/ff794fcae2ce8aa6323e789d1f8b3b7765f601e7702726f430e814822b96/gast-0.2.0.tar.gz

Collecting numpy>=1.13.3 (fromtensorflow-gpu==1.6.0)

 Downloading https://files.pythonhosted.org/packages/af/e4/7d7107bdfb5c33f6cf33cdafea8c27d1209cf0068a6e3e3d3342be6f3578/numpy-1.14.3-cp36-none-win_amd64.whl(13.4MB)

   100% |████████████████████████████████| 13.4MB 81kB/s

Collecting absl-py>=0.1.6 (fromtensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/90/6b/ba04a9fe6aefa56adafa6b9e0557b959e423c49950527139cb8651b0480b/absl-py-0.2.0.tar.gz(82kB)

   100% |████████████████████████████████| 92kB 101kB/s

Collecting six>=1.10.0 (fromtensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl

Collecting protobuf>=3.4.0 (fromtensorflow-gpu==1.6.0)

 Downloading https://files.pythonhosted.org/packages/32/cf/6945106da76db9b62d11b429aa4e062817523bb587018374c77f4b63200e/protobuf-3.5.2.post1-cp36-cp36m-win_amd64.whl(958kB)

   100% |████████████████████████████████| 962kB 162kB/s

Collecting tensorboard<1.7.0,>=1.6.0(from tensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/b0/67/a8c91665987d359211dcdca5c8b2a7c1e0876eb0702a4383c1e4ff76228d/tensorboard-1.6.0-py3-none-any.whl(3.0MB)

   100% |████████████████████████████████| 3.1MB 170kB/s

Collecting termcolor>=1.1.0 (fromtensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz

Collecting grpcio>=1.8.6 (fromtensorflow-gpu==1.6.0)

 Downloading https://files.pythonhosted.org/packages/80/7e/d5ee3ef92822b01e3a274230200baf2454faae64e3d7f436b093ff771a17/grpcio-1.11.0-cp36-cp36m-win_amd64.whl(1.4MB)

   100% |████████████████████████████████| 1.4MB 114kB/s

Collecting wheel>=0.26 (fromtensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/1b/d2/22cde5ea9af055f81814f9f2545f5ed8a053eb749c08d186b369959189a8/wheel-0.31.0-py2.py3-none-any.whl(41kB)

   100% |████████████████████████████████| 51kB 136kB/s

Collecting astor>=0.6.0 (from tensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/b2/91/cc9805f1ff7b49f620136b3a7ca26f6a1be2ed424606804b0fbcf499f712/astor-0.6.2-py2.py3-none-any.whl

Collecting setuptools (fromprotobuf>=3.4.0->tensorflow-gpu==1.6.0)

 Downloading https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl(566kB)

   100% |████████████████████████████████| 573kB 148kB/s

Collecting werkzeug>=0.11.10 (fromtensorboard<1.7.0,>=1.6.0->tensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl(322kB)

   100% |████████████████████████████████| 327kB 193kB/s

Collecting bleach==1.5.0 (fromtensorboard<1.7.0,>=1.6.0->tensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl

Collecting markdown>=2.6.8 (fromtensorboard<1.7.0,>=1.6.0->tensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl(78kB)

   100% |████████████████████████████████| 81kB 163kB/s

Collecting html5lib==0.9999999 (fromtensorboard<1.7.0,>=1.6.0->tensorflow-gpu==1.6.0)

 Downloadinghttps://files.pythonhosted.org/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz(889kB)

   100% |████████████████████████████████| 890kB 216kB/s

Installing collected packages: gast, numpy,six, absl-py, setuptools, protobuf, werkzeug, html5lib, bleach, markdown,wheel, tensorboard, termcolor, grpcio, astor, tensorflow-gpu

 Running setup.py install for gast ... done

 Running setup.py install for absl-py ... done

 Running setup.py install for html5lib ... done

  Thescript markdown_py.exe is installed in 'd:\study\python_3.6.4_install\Scripts'which is not on PATH.

 Consider adding this directory to PATH or, if you prefer to suppressthis warning, use --no-warn-script-location.

  Thescript wheel.exe is installed in 'd:\study\python_3.6.4_install\Scripts' whichis not on PATH.

 Consider adding this directory to PATH or, if you prefer to suppressthis warning, use --no-warn-script-location.

  Thescript tensorboard.exe is installed in 'd:\study\python_3.6.4_install\Scripts'which is not on PATH.

 Consider adding this directory to PATH or, if you prefer to suppressthis warning, use --no-warn-script-location.

 Running setup.py install for termcolor ... done

  Thescripts freeze_graph.exe, saved_model_cli.exe, tensorboard.exe, toco.exe andtoco_from_protos.exe are installed in 'd:\study\python_3.6.4_install\Scripts'which is not on PATH.

 Consider adding this directory to PATH or, if you prefer to suppressthis warning, use --no-warn-script-location.

Successfully installed absl-py-0.2.0astor-0.6.2 bleach-1.5.0 gast-0.2.0 grpcio-1.11.0 html5lib-0.9999999markdown-2.6.11 numpy-1.14.3 protobuf-3.5.2.post1 setuptools-39.1.0 six-1.11.0tensorboard-1.6.0 tensorflow-gpu-1.6.0 termcolor-1.1.0 werkzeug-0.14.1wheel-0.31.0


4、测试

进入python的交互式界面

依次输入

import tensorflow as tf

a = tf.random_normal((100, 100))
b = tf.random_normal((100, 500))
c = tf.matmul(a, b)
sess = tf.InteractiveSession()
sess.run(c)


如果出现这样的界面就说明tensorflow运行正常,安装已经完成了


5、安装keras

Keras是Python语言中基于原始深度学习框架Tensorflow或Theano的封装框架。那么如果准备使用Keras首先必须准备安装Tensorflow或Theano

pip install theano

pip install keras

安装成功后,(有坑)

import keras

可能会出错,

ImportError: cannot import name 'NUMPY_MKL'

我们需要下载 二进制文件进行安装(和自己匹配的版本)

pip install"numpy-1.14.3+mkl-cp36-cp36m-win_amd64.whl"





当前环境描述:Win10 64位,anaconda3

1、安装anaconda3

官网下载:https://www.anaconda.com/download/


安装完成后,创建虚拟环境aipython36

C:\Users\ZX>condacreate --name aipython36 python=3.6

Solving environment: done


激活虚拟环境aipython36

C:\Users\ZX>activateaipython36


2、安装tensorflow-gpu

(aipython36) C:\Users\ZX>pip installtensorflow-gpu

Collecting tensorflow-gpu

 Downloadinghttps://files.pythonhosted.org/packages/42/a8/4c96a2b4f88f5d6dfd70313ebf38de1fe4d49ba9bf2ef34dc12dd198ab9a/tensorflow_gpu-1.8.0-cp36-cp36m-win_amd64.whl(88.9MB)

    100% |████████████████████████████████|88.9MB 127kB/s

Collecting astor>=0.6.0 (fromtensorflow-gpu)

 Using cachedhttps://files.pythonhosted.org/packages/b2/91/cc9805f1ff7b49f620136b3a7ca26f6a1be2ed424606804b0fbcf499f712/astor-0.6.2-py2.py3-none-any.whl

Collecting six>=1.10.0 (fromtensorflow-gpu)

 Using cachedhttps://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl

Collecting termcolor>=1.1.0 (fromtensorflow-gpu)

Collecting numpy>=1.13.3 (fromtensorflow-gpu)

 Using cachedhttps://files.pythonhosted.org/packages/af/e4/7d7107bdfb5c33f6cf33cdafea8c27d1209cf0068a6e3e3d3342be6f3578/numpy-1.14.3-cp36-none-win_amd64.whl

Collecting tensorboard<1.9.0,>=1.8.0(from tensorflow-gpu)

 Downloadinghttps://files.pythonhosted.org/packages/59/a6/0ae6092b7542cfedba6b2a1c9b8dceaf278238c39484f3ba03b03f07803c/tensorboard-1.8.0-py3-none-any.whl(3.1MB)

   100% |████████████████████████████████| 3.1MB 453kB/s

Collecting grpcio>=1.8.6 (fromtensorflow-gpu)

 Using cachedhttps://files.pythonhosted.org/packages/80/7e/d5ee3ef92822b01e3a274230200baf2454faae64e3d7f436b093ff771a17/grpcio-1.11.0-cp36-cp36m-win_amd64.whl

Requirement already satisfied:wheel>=0.26 in d:\study\anaconda_install\envs\aipython36\lib\site-packages(from tensorflow-gpu) (0.31.0)

Collecting protobuf>=3.4.0 (fromtensorflow-gpu)

 Using cachedhttps://files.pythonhosted.org/packages/32/cf/6945106da76db9b62d11b429aa4e062817523bb587018374c77f4b63200e/protobuf-3.5.2.post1-cp36-cp36m-win_amd64.whl

Collecting absl-py>=0.1.6 (fromtensorflow-gpu)

Collecting gast>=0.2.0 (fromtensorflow-gpu)

Collecting bleach==1.5.0 (fromtensorboard<1.9.0,>=1.8.0->tensorflow-gpu)

 Using cached https://files.pythonhosted.org/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl

Collecting werkzeug>=0.11.10 (fromtensorboard<1.9.0,>=1.8.0->tensorflow-gpu)

 Using cachedhttps://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl

Collecting html5lib==0.9999999 (fromtensorboard<1.9.0,>=1.8.0->tensorflow-gpu)

Collecting markdown>=2.6.8 (fromtensorboard<1.9.0,>=1.8.0->tensorflow-gpu)

 Using cached https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl

Requirement already satisfied: setuptoolsin d:\study\anaconda_install\envs\aipython36\lib\site-packages (fromprotobuf>=3.4.0->tensorflow-gpu) (39.1.0)

Installing collected packages: astor, six,termcolor, numpy, html5lib, bleach, werkzeug, protobuf, markdown, tensorboard,grpcio, absl-py, gast, tensorflow-gpu

Successfully installed absl-py-0.2.0astor-0.6.2 bleach-1.5.0 gast-0.2.0 grpcio-1.11.0 html5lib-0.9999999markdown-2.6.11 numpy-1.14.3 protobuf-3.5.2.post1 six-1.11.0 tensorboard-1.8.0tensorflow-gpu-1.8.0 termcolor-1.1.0 werkzeug-0.14.1


成功安装tensorflow-gpu后,开始测试

(aipython36) C:\Users\ZX>python

Python 3.6.5 |Anaconda, Inc.| (default, Mar29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32

Type "help","copyright", "credits" or "license" for moreinformation.

>>> import tensorflow as tf

>>> import tensorflow as tf

>>> 

>>> a = tf.random_normal((100,100))

>>> b = tf.random_normal((100,500))

>>> c = tf.matmul(a, b)

>>> sess = tf.InteractiveSession()

2018-05-06 21:27:03.230234: IT:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:140]Your CPU supports instructions that this TensorFlow binary was not compiled touse: AVX2

2018-05-06 21:27:03.958281: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1356]Found device 0 with properties:

name: GeForce GTX 965M major: 5 minor: 2memoryClockRate(GHz): 1.15

pciBusID: 0000:01:00.0

totalMemory: 4.00GiB freeMemory: 3.33GiB

2018-05-06 21:27:03.968773: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1435]Adding visible gpu devices: 0

2018-05-06 21:27:04.967407: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:923]Device interconnect StreamExecutor with strength 1 edge matrix:

2018-05-06 21:27:04.972995: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:929]      0

2018-05-06 21:27:04.975793: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:942]0:   N

2018-05-06 21:27:04.979312: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1053]Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with3068 MB memory) -> physical GPU (device: 0, name: GeForce GTX 965M, pci busid: 0000:01:00.0, compute capability: 5.2)

>>> sess.run(c)

array([[ -9.958246 ,   9.637983 , -4.3460045, ...,  -5.829875 ,

         0.8854151, -12.419309 ],

      [-29.704847 , -20.443985 ,   1.661859, ...,   0.4999833,

        -0.9629812,  -2.8892303],

      [ -8.47146  ,   0.968585 , -2.6810174, ..., -24.770336 ,

         3.2682698,  -5.056379 ],

      ...,

      [  1.2603626,   7.689101 , -1.9029416, ...,  -4.6293073,

         2.248897 ,  -6.8074994],

      [ 10.781097 , -11.991552 ,  4.9216685, ...,  -6.5297775,

         2.161653 ,  12.668329 ],

      [-21.099367 ,   3.5344698,   6.654699 , ...,   5.902811 ,

        -4.652902 ,   5.8104954]],dtype=float32)

>>> exit()


出现如上所示,表示安装成功



2、安装keras

Keras是Python语言中基于原始深度学习框架Tensorflow或Theano的封装框架。那么如果准备使用Keras首先必须准备安装Tensorflow或Theano

命令:conda install theano

(aipython36) C:\Users\ZX>conda install theano

Solving environment: done

 

## Package Plan ##

 

 environment location: D:\study\anaconda_install\envs\aipython36

 

 added / updated specs:

    -theano

 

 

The following packages will be downloaded:

 

   package                    |            build

   ---------------------------|-----------------

    m2w64-bzip2-1.0.6          |                6         100 KB

   theano-1.0.1               |           py36_0         3.8 MB

   libpython-2.1              |           py36_0        39.2 MB

   m2w64-gcc-fortran-5.3.0    |                6        10.3 MB

    scipy-1.0.1                |   py36hce232c7_0        13.1 MB

   m2w64-headers-git-5.0.0.4636.c0ad18a|                2         5.6 MB

   m2w64-isl-0.16.1           |                2         655 KB

   mkl-2018.0.2               |                1       176.6 MB

   intel-openmp-2018.0.0      |                8         1.4 MB

   m2w64-windows-default-manifest-6.4|                3           3 KB

   m2w64-gcc-5.3.0            |                6        41.1 MB

   m2w64-gcc-objc-5.3.0       |                6       15.1 MB

   m2w64-binutils-2.25.1      |                5        44.3 MB

   m2w64-gcc-ada-5.3.0        |                6        33.5 MB

   ------------------------------------------------------------

                                          Total:       384.7 MB

 

The following NEW packages will beINSTALLED:

 

   icc_rt:                        2017.0.4-h97af966_0

   intel-openmp:                  2018.0.0-8

   libgpuarray:                   0.7.5-hfa6e2cd_0

   libpython:                     2.1-py36_0

   m2w64-binutils:                2.25.1-5

   m2w64-bzip2:                   1.0.6-6

   m2w64-crt-git:                 5.0.0.4636.2595836-2

   m2w64-gcc:                     5.3.0-6

   m2w64-gcc-ada:                 5.3.0-6

   m2w64-gcc-fortran:             5.3.0-6

   m2w64-gcc-libgfortran:         5.3.0-6

   m2w64-gcc-libs:                5.3.0-7

   m2w64-gcc-libs-core:           5.3.0-7

   m2w64-gcc-objc:                5.3.0-6

   m2w64-gmp:                     6.1.0-2

   m2w64-headers-git:             5.0.0.4636.c0ad18a-2

   m2w64-isl:                     0.16.1-2

   m2w64-libiconv:                1.14-6

   m2w64-libmangle-git:           5.0.0.4509.2e5a9a2-2

   m2w64-libwinpthread-git:       5.0.0.4634.697f757-2

   m2w64-make:                    4.1.2351.a80a8b8-2

   m2w64-mpc:                     1.0.3-3

   m2w64-mpfr:                    3.1.4-4

   m2w64-pkg-config:              0.29.1-2

   m2w64-toolchain:               5.3.0-7

   m2w64-tools-git:               5.0.0.4592.90b8472-2

   m2w64-windows-default-manifest: 6.4-3

   m2w64-winpthreads-git:         5.0.0.4634.697f757-2

   m2w64-zlib:                    1.2.8-10

   mako:                           1.0.7-py36he15cdb7_0

   markupsafe:                    1.0-py36h0e26971_1

   mkl:                           2018.0.2-1

   mkl-service:                   1.1.2-py36h57e144c_4

   mkl_fft:                       1.0.1-py36h452e1ab_0

   mkl_random:                    1.0.1-py36h9258bd6_0

   msys2-conda-epoch:             20160418-1

   numpy:                         1.14.2-py36h5c71026_1

   pygpu:                         0.7.5-py36hfa6e2cd_0

   scipy:                          1.0.1-py36hce232c7_0

   six:                           1.11.0-py36h4db2310_1

   theano:                        1.0.1-py36_0

 

Proceed ([y]/n)? y

 

 

Downloading and Extracting Packages

m2w64-bzip21.0.6##############################################################################################| 100%

theano1.0.1###################################################################################################| 100%

libpython2.1##################################################################################################| 100%

m2w64-gcc-fortran5.3.0########################################################################################| 100%

scipy1.0.1####################################################################################################| 100%

m2w64-headers-git5.0.0.4636.c0ad18a###########################################################################| 100%

m2w64-isl0.16.1###############################################################################################| 100%

mkl2018.0.2###################################################################################################| 100%

intel-openmp2018.0.0##########################################################################################| 100%

m2w64-windows-default-manifest6.4#############################################################################| 100%

m2w64-gcc5.3.0################################################################################################| 100%

m2w64-gcc-objc 5.3.0###########################################################################################| 100%

m2w64-binutils2.25.1##########################################################################################| 100%

m2w64-gcc-ada5.3.0############################################################################################| 100%

Preparing transaction: done

Verifying transaction: done

Executing transaction: done


验证:theano是否安装成功

import theano

报错   :nvcc fatal  : Cannot find compiler 'cl.exe' in PATH

错误解决:将Microsoft Visual Studio 安装路径下的VC\bin的目录加入到环境变量


之后在个人主文件夹下新建一个“.theanorc.txt”的文档。个人主文件夹就是打开命令行后所显示的文件夹路径

打开.theanorc.txt写入以下信息:

[global]

openmp=False

device = gpu

optimizer_including=cudnn

floatX = float32

allow_input_downcast=True

[lib]

cnmem = 0.8

[blas]

ldflags=

[gcc]

cxxflags=D:\study\anaconda_install\envs\aipython36\MinGW

[nvcc]

--flags = D:\study\anaconda_install\envs\aipython36\libs

--compiler_bindir = D:\study\vs安装\VC\bin

注意:cxxflags=   。。。 换成你的Anaconda3MinGW的位置

          把flags =。。。换为你的Anaconda3libs的位置

         把compiler_bindir =。。。换为你的VSVC\bin的位置






安装keras

命令:pip install keras

(aipython36) C:\Users\ZX>pip installkeras

Collecting keras

 Using cached https://files.pythonhosted.org/packages/54/e8/eaff7a09349ae9bd40d3ebaf028b49f5e2392c771f294910f75bb608b241/Keras-2.1.6-py2.py3-none-any.whl

Collecting h5py (from keras)

 Using cachedhttps://files.pythonhosted.org/packages/b6/3c/524e9f49cf56e7aa284e3be0604d619997a07ff513a80ede3fbc08f2d06c/h5py-2.7.1-cp36-cp36m-win_amd64.whl

Requirement already satisfied:scipy>=0.14 in d:\study\anaconda_install\envs\aipython36\lib\site-packages(from keras) (1.0.1)

Requirement already satisfied:numpy>=1.9.1 in d:\study\anaconda_install\envs\aipython36\lib\site-packages(from keras) (1.14.3)

Collecting pyyaml (from keras)

Requirement already satisfied:six>=1.9.0 in d:\study\anaconda_install\envs\aipython36\lib\site-packages(from keras) (1.11.0)

mkl-random 1.0.1 requires cython, which isnot installed.

mkl-fft 1.0.0 requires cython, which is notinstalled.

Installing collected packages: h5py,pyyaml, keras

Successfully installed h5py-2.7.1keras-2.1.6 pyyaml-3.12


安装完成后进行验证

>>> import keras

D:\study\anaconda_install\envs\aipython36\lib\site-packages\h5py\__init__.py:36:FutureWarning: Conversion of the second argument of issubdtype from `float` to`np.floating` is deprecated. In future, it will be treated as `np.float64 ==np.dtype(float).type`.

 from ._conv import register_converters as _register_converters

Using TensorFlow backend.



安装pytorch

换清华大学的源(速度飞起):

(conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/


(aipython36) D:\study\python_package>condainstall pytorch cuda90

Solving environment: done

 

## Package Plan ##

 

 environment location: D:\study\anaconda_install\envs\aipython36

 

 added / updated specs:

    -cuda90

    -pytorch

 

 

The following packages will be downloaded:

 

   package                    |            build

   ---------------------------|-----------------

   cuda90-1.0                 |       h4c72538_0           4 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123

   pytorch-0.3.1              |py36_cuda90_cudnn7he774522_2       434.8 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123

   ------------------------------------------------------------

                                          Total:       434.8 MB

 

The following NEW packages will beINSTALLED:

 

   cuda90:  1.0-h4c72538_0                    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123

   pytorch: 0.3.1-py36_cuda90_cudnn7he774522_2https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123 [cuda90]

 

The following packages will be UPDATED:

 

   mkl:     2017.0.3-0                        https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free        --> 2018.0.2-1            defaults

   numpy:   1.13.1-py36_0                      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free        --> 1.14.2-py36h5c71026_1 defaults

   scipy:   0.19.1-np113py36_0                https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free        --> 1.0.1-py36hce232c7_0  defaults

 

Proceed ([y]/n)? y

 

 

Downloading and Extracting Packages

cuda901.0#############################################################################################################################| 100%

pytorch0.3.1##########################################################################################################################| 100%

Preparing transaction: done

Verifying transaction: done

Executing transaction: done


验证 pytorch是否安装成功

(aipython36) D:\study\python_package>python

Python 3.6.5 |Anaconda, Inc.| (default, Mar29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32

Type "help","copyright", "credits" or "license" for moreinformation.

>>> import torch

>>> import torch

>>> x = torch.Tensor([1.0])

>>> xx = x.cuda()

>>> print(xx)

 

 1

[torch.cuda.FloatTensor of size 1 (GPU 0)]

 

>>> from torch.backends importcudnn

>>> print(cudnn.is_acceptable(xx))

True

 

出现如上所示,表示已经安装成功



































  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装TensorFlowKerasAnaconda中,请按照以下步骤进行操作: 1. 首先,从Anaconda官网下载并安装Anaconda。请确保选择适用于你操作系统的版本。 2. 打开Anaconda Prompt(Windows)或命令行终端(Mac和Linux)。 3. 创建一个新的Python环境,可以使用以下命令: ``` conda create -n your_env_name python=X.X ``` 将`your_env_name`替换为你想要的环境名称,`X.X`替换为你想要的Python版本号(例如2.7或3.6)。 4. 激活新创建的环境,使用以下命令: ``` conda activate your_env_name ``` 5. 安装TensorFlowKeras,可以使用以下命令: ``` conda install tensorflow-gpu keras ``` 这将安装TensorFlow GPU版本和Keras。 6. 安装完成后,你可以使用以下命令来验证安装: ``` conda list tensorflow-gpu keras ``` 这将显示已安装TensorFlowKeras的版本号。 7. 如果你想在Jupyter Notebook中使用新创建的环境,请确保在激活环境的状态下安装Jupyter Notebook,并在激活环境的状态下启动Jupyter Notebook。 ``` conda install jupyter jupyter notebook ``` 这将启动Jupyter Notebook,并在默认浏览器中打开它。 请注意,这里提供的步骤仅适用于Anaconda环境安装TensorFlowKeras。确保按照上述步骤进行操作,以便正确安装所需的库和环境。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [手把手 Ubuntu16.04+cuda9.0+cudnn 7.1+Anaconda+tensorflow-gpu+keras-附件资源](https://download.csdn.net/download/weixin_42185419/15595517)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Anaconda安装Tensorflow+keras](https://blog.csdn.net/daodanxiansheng/article/details/88132980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [【避坑指南】Windows10中使用Anaconda安装tensorflow+keras](https://blog.csdn.net/hutianle/article/details/126426446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值