层面1: 针对各个虚拟环境: 修改~/.virtualenv/YOUR_VENV/bin/postactivate, 在末尾添加行export CUDA_VISIBLE_DEVICES="1"即可.
~/.virtualenv/YOUR_VENV/bin/postactivate
export CUDA_VISIBLE_DEVICES="1"
层面2: 针对系统用户: 同上修改~/.bashrc即可.
~/.bashrc
tensorflow-gpu+"Failed to create session"
原文:http://www.cnblogs.com/ZhengPeng7/p/7833352.html