我的个人博客:zhang0peter的个人博客
win 10 anaconda python3.7 安装keras tensorflow-gpu
pytorch的安装参考这篇文章:windows anaconda python 3.7 安装 pytorch-gpu
-6-1:清华更新源已经关闭了
先添加清华源:
进入安装:
conda install keras-gpu
注意:在安装keras-gpu的时候一般会顺便把tensorflow-gpu也安装了,所以不需要额外安装tensorflow-gpu
WARNING: The pat module is deprecated and will be removed in a future release.Collecting package metadata: doneSolving environment: done## Package Plan ##environment location: C:\Users\peter\Anaconda3added / updated specs:- keras-gpuThe following packages will be downloaded:package| build---------------------------|-----------------_tflow_select-2.1.0 | gpu 3 KB https://mirrors.tuna./anaconda/pkgs/mainabsl-py-0.7.0 | py37_0 157 KB https://mirrors.tuna./anaconda/pkgs/mainastor-0.7.1| py37_044 KB https://mirrors.tuna./anaconda/pkgs/mainca-certificates-.1.23 |0 158 KB https://mirrors.tuna./anaconda/pkgs/maincertifi-.3.9 | py37_0 155 KB https://mirrors.tuna./anaconda/pkgs/mainconda-4.6.11| py37_0 1.7 MB https://mirrors.tuna./anaconda/pkgs/maincudatoolkit-10.0.130 |0 371.0 MB https://mirrors.tuna./anaconda/pkgs/maincudnn-7.3.1| cuda10.0_0 199.1 MB https://mirrors.tuna./anaconda/pkgs/maingast-0.2.2 | py37_0 138 KB https://mirrors.tuna./anaconda/pkgs/maingrpcio-1.16.1 | py37h351948d_1 947 KB https://mirrors.tuna./anaconda/pkgs/mainkeras-applications-1.0.7 | py_033 KB https://mirrors.tuna./anaconda/pkgs/mainkeras-base-2.2.4 | py37_0 489 KB https://mirrors.tuna./anaconda/pkgs/mainkeras-gpu-2.2.4 |0 5 KB https://mirrors.tuna./anaconda/pkgs/mainkeras-preprocessing-1.0.9 | py_035 KB https://mirrors.tuna./anaconda/pkgs/mainlibprotobuf-3.6.1| h7bd577a_0 1.9 MB https://mirrors.tuna./anaconda/pkgs/mainmarkdown-3.0.1 | py37_0 125 KB https://mirrors.tuna./anaconda/pkgs/mainmock-2.0.0 | py37_0 104 KB https://mirrors.tuna./anaconda/pkgs/mainopenssl-1.1.1b | he774522_1 5.7 MB https://mirrors.tuna./anaconda/pkgs/mainpbr-5.1.3 | py_074 KB https://mirrors.tuna./anaconda/pkgs/mainprotobuf-3.6.1 | py37h33f27b4_0 514 KB https://mirrors.tuna./anaconda/pkgs/maintensorboard-1.13.1 | py37h33f27b4_0 3.3 MB https://mirrors.tuna./anaconda/pkgs/maintensorflow-1.13.1|gpu_py37h83e5d6a_0 4 KB https://mirrors.tuna./anaconda/pkgs/maintensorflow-base-1.13.1|gpu_py37h871c8ca_0 218.5 MB https://mirrors.tuna./anaconda/pkgs/maintensorflow-estimator-1.13.0| py_0 205 KB https://mirrors.tuna./anaconda/pkgs/maintensorflow-gpu-1.13.1| h0d30ee6_0 2 KB https://mirrors.tuna./anaconda/pkgs/maintermcolor-1.1.0 | py37_1 7 KB https://mirrors.tuna./anaconda/pkgs/main------------------------------------------------------------Total: 804.4 MBThe following NEW packages will be INSTALLED:_tflow_selectanaconda/pkgs/main/win-64::_tflow_select-2.1.0-gpuabsl-py anaconda/pkgs/main/win-64::absl-py-0.7.0-py37_0astor anaconda/pkgs/main/win-64::astor-0.7.1-py37_0cudatoolkit anaconda/pkgs/main/win-64::cudatoolkit-10.0.130-0cudnn anaconda/pkgs/main/win-64::cudnn-7.3.1-cuda10.0_0gastanaconda/pkgs/main/win-64::gast-0.2.2-py37_0grpcio anaconda/pkgs/main/win-64::grpcio-1.16.1-py37h351948d_1keras-applications anaconda/pkgs/main/noarch::keras-applications-1.0.7-py_0keras-base anaconda/pkgs/main/win-64::keras-base-2.2.4-py37_0keras-gpuanaconda/pkgs/main/win-64::keras-gpu-2.2.4-0keras-preprocessi~ anaconda/pkgs/main/noarch::keras-preprocessing-1.0.9-py_0libprotobuf anaconda/pkgs/main/win-64::libprotobuf-3.6.1-h7bd577a_0markdown anaconda/pkgs/main/win-64::markdown-3.0.1-py37_0mockanaconda/pkgs/main/win-64::mock-2.0.0-py37_0pbranaconda/pkgs/main/noarch::pbr-5.1.3-py_0protobuf anaconda/pkgs/main/win-64::protobuf-3.6.1-py37h33f27b4_0tensorboard anaconda/pkgs/main/win-64::tensorboard-1.13.1-py37h33f27b4_0tensorflow anaconda/pkgs/main/win-64::tensorflow-1.13.1-gpu_py37h83e5d6a_0tensorflow-base anaconda/pkgs/main/win-64::tensorflow-base-1.13.1-gpu_py37h871c8ca_0tensorflow-estima~ anaconda/pkgs/main/noarch::tensorflow-estimator-1.13.0-py_0tensorflow-gpuanaconda/pkgs/main/win-64::tensorflow-gpu-1.13.1-h0d30ee6_0termcoloranaconda/pkgs/main/win-64::termcolor-1.1.0-py37_1The following packages will be SUPERSEDED by a higher-priority channel:ca-certificates pkgs/main --> anaconda/pkgs/maincertifi pkgs/main --> anaconda/pkgs/mainconda pkgs/main --> anaconda/pkgs/mainopenssl pkgs/main --> anaconda/pkgs/mainProceed ([y]/n)?
测试:
import tensorflow as tf# Creates a graph.a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')c = tf.matmul(a, b)# Creates a session with log_device_placement set to True.sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))# Runs the op.print(sess.run(c))
结果如下:
-04-09 09:43:51.546292: I tensorflow/core/platform/:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2-04-09 09:43:51.774686: I tensorflow/core/common_runtime/gpu/:1433] Found device 0 with properties:name: GeForce GTX 960M major: 5 minor: 0 memoryClockRate(GHz): 1.176pciBusID: 0000:01:00.0totalMemory: 4.00GiB freeMemory: 3.34GiB-04-09 09:43:51.785557: I tensorflow/core/common_runtime/gpu/:1512] Adding visible gpu devices: 0-04-09 09:43:53.083262: I tensorflow/core/common_runtime/gpu/:984] Device interconnect StreamExecutor with strength 1 edge matrix:-04-09 09:43:53.092130: I tensorflow/core/common_runtime/gpu/:990]0-04-09 09:43:53.096845: I tensorflow/core/common_runtime/gpu/:1003] 0: N-04-09 09:43:53.102709: I tensorflow/core/common_runtime/gpu/:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3050 MB memory) -> physical GPU (device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0, compute capability: 5.0)Device mapping:/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0, compute capability: 5.0-04-09 09:43:53.121080: I tensorflow/core/common_runtime/:317] Device mapping:/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0, compute capability: 5.0MatMul: (MatMul): /job:localhost/replica:0/task:0/device:GPU:0-04-09 09:43:53.134660: I tensorflow/core/common_runtime/:1059] MatMul: (MatMul)/job:localhost/replica:0/task:0/device:GPU:0a: (Const): /job:localhost/replica:0/task:0/device:GPU:0-04-09 09:43:53.141017: I tensorflow/core/common_runtime/:1059] a: (Const)/job:localhost/replica:0/task:0/device:GPU:0b: (Const): /job:localhost/replica:0/task:0/device:GPU:0-04-09 09:43:53.149598: I tensorflow/core/common_runtime/:1059] b: (Const)/job:localhost/replica:0/task:0/device:GPU:0[[22. 28.][49. 64.]]
安装完成