为什么Tensorflow-gpu仍在使用cpu [英] why Tensorflow-gpu is still using cpu
问题描述
我在后端使用带有tensorflow-gpu的Keras,我没有安装tensorflow(CPU-版本),所有输出均显示GPU已选择,但tf正在使用CPU和系统内存
I am using Keras with tensorflow-gpu in backend, I don't have tensorflow (CPU - version) installed, all the outputs show GPU selected but tf is using CPU and system memory
运行代码时,输出为:输出代码
when i run my code the output is: output_code
我什至运行了device_lib.list_local_device(),输出为: list_local_devices_output
I even ran device_lib.list_local_device() and the output is: list_local_devices_output
运行代码后,我尝试nvidia-smi查看gpu的用法,输出为: nvidia-smi输出
After running the code I tried nvidia-smi to see the usage of gpu and the output is: nvidia-smi output
Tensorflow-gpu = "1.12.0"
CUDA toolkit = "9.0"
cuDNN = "7.4.1.5"
环境变量包含:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
D:\Anaconda3;D:\Anaconda3\Library\mingw-w64\bin
D:\Anaconda3\Library\usr\bin;
D:\Anaconda3\Library\bin;
D:\Anaconda3\Scripts;D:\ffmpeg\bin\;
但是当我在任务管理器中检查内存使用情况时,输出仍然是
But still when i check for memory usage in task manager the output is
CPU利用率51%,RAM利用率86% GPU利用率1%,GPU-RAM利用率0% Task_manager_Output 因此,我认为它仍在使用CPU而不是GPU.
CPU utilization 51%, RAM utilization 86% GPU utilization 1%, GPU-RAM utilization 0% Task_manager_Output So, I think it is still using CPU instead of GPU.
系统配置:
Windows-10 64 bit; IDE: Liclipse; Python: 3.6.5
推荐答案
它正在使用GPU,如您在日志中所见. 问题是,在GPU上无法完成很多事情,并且只要您的数据很小并且复杂度很低,您最终将只能使用低GPU.
It is using the the GPU, as you can see in the logs. The problem is, that a lot of things can not be done on the GPU and as long your data is small and your complexity is low, you will end up with low GPU usage.
- 也许batch_size很小->增加直到遇到OOM错误
- 您的数据加载消耗大量时间,您的GPU必须等待(IO读取)
- 您的RAM不足,应用程序使用磁盘作为后备
- 预加工会变慢.如果您要处理图片,请尝试将所有内容作为生成器或gpu进行计算
- 您正在使用某些操作,这些操作不是GPU加速的