docker 使用gpu启动及tf限额

1、docker启动:

 docker run --rm --gpus 0 -p5005:5005 bert:latest

docker run --rm --gpus all -p5005:5005 bert:latest

--gpus 卡号或者all

查看卡号:nvidia-smi

 

 2、tf限额

# 自适应增长
# config = tf.compat.v1.ConfigProto()
# config.gpu_options.allow_growth = True
# sess = tf.compat.v1.Session(config=config)

# 指定使用比例
config = tf.compat.v1.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.1
session = tf.compat.v1.Session(config=config)

 

posted @ 2021-11-08 11:39  liown  阅读(315)  评论(0编辑  收藏  举报