中文文檔的描述:keras中文文檔,切換後端
後端切換:http://blog.csdn.net/tangwenbo124/article/details/52627774?locationNum=7
keras中文文檔:http://keras-cn.readthedocs.io/en/latest/getting_started/keras_linux/ (很不錯的學習keras資料)
Keras是一個簡約,高度模塊化的神經網絡庫。採用Python / Theano開發。
使用Keras如果你需要一個深度學習庫:
- 可以很容易和快速實現原型(通過總模塊化,極簡主義,和可擴展性)
- 同時支持卷積網絡(vision)和複發性的網絡(序列數據)。以及兩者的組合。
- 無縫地運行在CPU和GPU上。
鏡像的容器中使用:
1.keras.json: 在/root/.keras/裏面;
2.後端切換:修改keras.json文件,th=theano, tf=tensorflow
keras後端theano中使用GPU的方法:
來自官方的介紹How do I use keras with gpu
If you are running on the TensorFlow backend, your code will automatically run on GPU if any available GPU is detected. If you are running on the Theano backend, you can use one of the following methods:
Method 1: use Theano flags.
THEANO_FLAGS=device=gpu,floatX=float32python my_keras_script.py
The name ‘gpu’ might have to be changed depending on your device’s identifier (e.g. gpu0, gpu1, etc).Method 2: set up your .theanorc: Instructions (修改.theanorc.txt文件,如果沒有該文件,可以自己新建該文件,放到/root/.theano/下面)
sudo vim ~/.theanorc
add these content
[global]
device=gpu
floatX=float32Method 3: manually set theano.config.device, theano.config.floatX at the beginning of your code:
import theano
theano.config.device = ‘gpu’
theano.config.floatX = ‘float32’
.theanorc.txt文件:
[global] device=gpu floatX=float32 [dnn.conv] algo_bwd_filter = deterministic algo_bwd_data = deterministic [cuda] root=/usr/local/cuda-8.0 [lib] cnmem=0.3 [nvcc] fastmath = True optimizer_including=cudnn
備註 :
1.nvidia-smi :查看gpu的使用情況,GPU-Util:gpu使用率
2.查看theano的版本號:
python
import theano
theano.__version__
3. THEANO_FLAGS=device=gpu,floatX=float32 python train_model_zj.py ./data
跑GPU,GPU一直跑不通,原因theano的版本太低,
sudo pip install -U --pre theano
4. 報這個問題:Using gpu device 0: GeForce GTX 1080 (CNMeM is disabled, cuDNN 5105) 可以忽略
5.進程號: 數字PID,是英文ProcessIDentifier的縮寫
強制終止進程:kill -9 進程號
ps -aux //顯示所有包含其他使用者的進程
USER
smmsp 3521 0.0 0.7 65561616 ? Ss 20:40 0:00sendmail: Queue runner@01:00:00 f
名稱:ps
使用權限:所有使用者
使用方式:ps [options] [--help]
說明:顯示瞬間行程 (process) 的動態
參數:
ps 的參數非常多, 在此僅列出幾個常用的參數並大略介紹含義
-A 列出所有的行程
-w 顯示加寬可以顯示較多的資訊
-au 顯示較詳細的資訊
-aux 顯示所有包含其他使用者的行程
au(x) 輸出格式 :
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
USER: 行程擁有者
PID: pid
%CPU: 佔用的 CPU 使用率
%MEM: 佔用的記憶體使用率
VSZ: 佔用的虛擬記憶體大小
RSS: 佔用的記憶體大小
TTY: 終端的次要裝置號碼 (minor device number of tty)
STAT: 該行程的狀態:
D: 不可中斷的靜止
R: 正在執行中
S: 靜止狀態
T: 暫停執行
Z: 不存在但暫時無法消除
W: 沒有足夠的記憶體分頁可分配
<: 高優先序的行程
N: 低優先序的行程
L: 有記憶體分頁分配並鎖在記憶體內
START: 行程開始時間
TIME: 執行的時間
COMMAND:所執行的指令