GitHub上找到的案例一般会说明环境依赖,最好新建环境,按照说明搭建环境,不要用自己原来的环境乱改。(比如发现自己原来环境的TensorFlow根本就不是GPU版本)
这将安装一个套间!没有必要单独添加东西!
[En]
This will install a suite! There is no need to add things separately!
而pip install tensorflow_gpu==1.15
pip只会安装单独的包,不会装依赖!!!
检查自己的环境支不支持GPU
Tensorflow中查看GPU是否可用:
import tensorflow as tf
tf.test.is_gpu_available()
如果报错Resource exhausted: OOM when allocating tensor with shape[768,768] and type float on /j
TensorFlow指定GPU运行程序
这条命令适用于命令行运行tensorflow程序的时候,指定gpu.
只需要在命令之前设置环境变量,简单来说比如原本程序是命令行运行pythontrain.py
假定这里gpu总共有八块,通过nvidia-smi查看发现5,6,7是空闲的(从0开始编号)
则运行命令修改为:
CUDA_VISIBLE_DEVICES=5,6,7 python train.py
1、尝试重启机器,有可能好。
Original: https://blog.csdn.net/qq_43525676/article/details/124056521
Author: 不二当码农
Title: 安装TensorFlow_gpu后仍然不能使用GPU
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/496705/
转载文章受原作者版权保护。转载请注明原作者出处!