天天看点

TensorFlow错题集

TensorFlow指定GPU使用及监控GPU占用情况 nvidia-smi -l 定时更新 在终端执行程序时指定GPU     CUDA_VISIBLE_DEVICES=1   python  your_file.py 这样在跑你的网络之前,告诉程序只能看到1号GPU,其他的GPU它不可见 可用的形式如下: CUDA_VISIBLE_DEVICES=1           Only device 1 will be seen CUDA_VISIBLE_DEVICES=0,1         Devices 0 and 1 will be visible CUDA_VISIBLE_DEVICES="0,1"       Same as above, quotation marks are optional CUDA_VISIBLE_DEVICES=0,2,3       Devices 0, 2, 3 will be visible; device 1 is masked CUDA_VISIBLE_DEVICES=""          No GPU will be visible 在Python代码中指定GPU import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0" 设置定量的GPU使用量 config = tf.ConfigProto()  config.gpu_options.per_process_gpu_memory_fraction = 0.9 # 占用GPU90%的显存  session = tf.Session(config=config) 设置最小的GPU使用量 config = tf.ConfigProto()  config.gpu_options.allow_growth = True  session = tf.Session(config=config)

------------------------------------------------------------------------ 单词删除 dw 删除到下一个单词开头 de 删除到本单词末尾dE 删除到本单词末尾包括标点在内 db 删除到前一个单词dB 删除到前一个单词包括标点在内 很明显,d是delete的缩写,而上面的x则是老式的清除意思 这里e表示往前删除一个单词,b表示往后删除一个单词,第一节中移动写的很清楚 要注意的是e b会忽略标点,如don't,它们会把这当做三个单词don、‘ 和 t 来删除 而大写的E B则不会

d0 删除到行首 d$ 删除光标之后的该行剩余部分。

TensorFlow指定GPU使用及监控GPU占用情况 nvidia-smi -l 定时更新 在终端执行程序时指定GPU     CUDA_VISIBLE_DEVICES=1   python  your_file.py 这样在跑你的网络之前,告诉程序只能看到1号GPU,其他的GPU它不可见 可用的形式如下: CUDA_VISIBLE_DEVICES=1           Only device 1 will be seen CUDA_VISIBLE_DEVICES=0,1         Devices 0 and 1 will be visible CUDA_VISIBLE_DEVICES="0,1"       Same as above, quotation marks are optional CUDA_VISIBLE_DEVICES=0,2,3       Devices 0, 2, 3 will be visible; device 1 is masked CUDA_VISIBLE_DEVICES=""          No GPU will be visible 在Python代码中指定GPU import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "0" 设置定量的GPU使用量 config = tf.ConfigProto()  config.gpu_options.per_process_gpu_memory_fraction = 0.9 # 占用GPU90%的显存  session = tf.Session(config=config) 设置最小的GPU使用量 config = tf.ConfigProto()  config.gpu_options.allow_growth = True  session = tf.Session(config=config)

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

继续阅读