⑥安装GPU版的TensorFlow。从TensorFlow官网下载最新的GPU版本,通过在命令行窗口输入
pipinstalltensorflow_gpu-1.7.0-cp36-cp36m-win_amd64.whl
安装所需的GPU版TensorFlow。
这里tensorflow_gpu-1.7.0-cp36-cp36m-win_amd64.whl是下载的文件名,其中的1.7.0是版本号,版本不同会有所区别。
某些情况下可能需要更新pip,这可以通过如下命令实现
python -mpipinstall –upgradepip
图7-6显示的就是安装TensorFlow的过程。
图7-6 安装GPU版TensorFlow
⑦接下来通过下述方式查看TensorFlow是否安装完成。
In[45]:.clientimportdevice_libas
_device_lib
In[46]:local_device_protos=_device_lib.list_local
_devices()
In[47]:local_device_protos
Out[47]:
[name:"/device:CPU:0"
device_type:"CPU"
memory_limit:268435456
locality {}
incarnation:1987868172902998319,name:"/device:GPU:0"
device_type:"GPU"
memory_limit:4980893286
locality {
bus_id:1
links {}
}
incarnation:16631691530492819808
physical_device_desc:"device:0,name:GeForceGTX1060,pci
busid:0000:02:00.0,computecapability:6.1"]
如果显示了类似的显卡配置,则说明安装顺利完成。
⑧查看TensorFlow是否已经支持GPU计算。可以通过如下命令在命令行窗口输出的结果中查看是否已经支持GPU计算(图7-7)。
importTensorFlowastf
a=tf.random_normal((100,100))
b=tf.random_normal((100,500))
c=(a,b)
sess=()
(c)
图7-7TensorFlow计算体验
⑨安装完TensorFlow后,在命令行窗口使用如下命令
pipinstallkeras
安装完Keras,整个Keras环境就构建完毕了。