本文共 4816 字,大约阅读时间需要 16 分钟。
git
通过 conda install keras
或 pip install keras
直接安装。(会默认的给你安装keras最新版本和所需要的theano)
因为windows版本的tensorflow刚刚才推出,所以目前支持性不太好。但是keras的backend 同时支持tensorflow和theano. 并且默认是tensorflow, 因此在win本上需要更改backend为theano才能运行。Linux中切换backend同理!
# Default backend: TensorFlow.#_BACKEND = 'tensorflow'_BACKEND = 'theano'
then, python-> import keras
{ "image_dim_ordering":"tf", "epsilon":1e-07, "floatx":"float32", "backend":"tensorflow" } { "image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "theano" }
如果你至少运行过一次Keras,你将在下面的目录下找到Keras的配置文件:
~/.keras/keras.json
如果该目录下没有该文件,你可以手动创建一个
文件的默认配置如下:
{"image_dim_ordering":"tf","epsilon":1e-07,"floatx":"float32","backend":"tensorflow"}
将backend字段的值改写为你需要使用的后端:theano或tensorflow,即可完成后端的切换
我们也可以通过定义环境变量KERAS_BACKEND来覆盖上面配置文件中定义的后端:
KERAS_BACKEND=tensorflow python -c "from keras import backend;"Using TensorFlow backend.
{ "image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"}
你可以更改以上~/.keras/keras.json中的配置
$ uname -m && cat /etc/*release
$ lspci | grep -i nvidia
就是安装C++开发环境,因为CUDA是基于C/C++开发的,当然现在也支持很多其他语言
$ sudo apt-get install gcc g++
$ sudo apt-get install linux-headers-$(uname -r)
$ sudo apt-get install build-essential
合并:
$ sudo apt-get install gcc g++ linux-headers-$(uname -r) build-essential -y
Installation Instructions:`sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb``sudo apt-get update``sudo apt-get install cuda`
3.6. Ubuntu
1. Perform the pre-installation actions. 2. Install repository meta-dataWhen using a proxy server with aptitude, ensure that wget is set up to use the
same proxy settings before installing the cuda-repo package.$ sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
$ sudo apt-get update
$ sudo apt-get install cuda
重启显卡
root@dluta914:/etc/network# systemctl status nvidia-persistenced.service
apt install software-properties-common
–> add-apt-repository ppa:graphics-drivers/ppa
(可选)
apt install ubuntu-drivers-common
–> ubuntu-drives list
–> ubuntu-drivers autoinstall
nvidia-detector
root@dluta914:/etc/network# nvidia-smiWed Mar 15 16:06:11 2017+-----------------------------------------------------------------------------+| NVIDIA-SMI 378.13 Driver Version: 378.13 ||-------------------------------+----------------------+----------------------+| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC || Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. ||===============================+======================+======================|| 0 Tesla K20c Off | 0000:03:00.0 Off | 0 || 40% 48C P0 57W / 225W | 0MiB / 4742MiB | 95% Default |+-------------------------------+----------------------+----------------------++-----------------------------------------------------------------------------+| Processes: GPU Memory || GPU PID Type Process name Usage ||=============================================================================|| No running processes found |+-----------------------------------------------------------------------------+
安装:
./cuda*.run
cd ~/NVIDIA_CUDA-8.0_Samples/
–> make all
cd ~/NVIDIA_CUDA-8.0_Samples/1_Utilities/deviceQuery
nvcc -I '../../common/inc/' deviceQuery.cpp -o deviceQuery
–> ./deviceQuery
nvcc -V
环境变量
vim /etc/bash.bashrc
export CUDA_HOME=/usr/local/cuda-8.0export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
vim ~/.bashrc
转载地址:http://xjoji.baihongyu.com/