起因:model.fit((1000,44,1),(1000,44),XXX)速度很慢
最后:
with tf.device('/gpu:0'): model1.fit(X2, Y2, epochs=150, verbose=2, steps_per_epoch=50, use_multiprocessing=True, workers=4)
配置过程:
gpu 4090,cuda:12.3,cudnn:xx
虚拟环境:
keras_gpu
coda create -n keras_gpu python==3.7
tensorflow-gpu:
pip install tensorflow-gpu==2.2.0 -i https://mirrors.ustc.edu.cn/pypi/web/simple
keras:2.3.1
pip install kereas==2.3.1 -i https://mirrors.ustc.edu.cn/pypi/web/simple
conda search cudatoolkit
选择10.1.168
conda install cudatoolkit==10.1.168
等一会速度很慢的话不行重开
conda search cudnn
选择7.6.5(看上去适配10.0,10.1,10.2)
conda install cudnn ==7.6.5
protube20报错就装19
如果cudart64_10.dll没有报错(下载:cudart64_101.dll 免费下载 | DLL‑files.com)
检测是配置成功:(输出1)
import tensorflow as tf1
print(len(tf1.config.experimental.list_physical_devices('GPU')))
单gpu配置:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
使用:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
参考: