我正在使用Tensorflow中的LSTM-RNN训练一些音乐数据,并遇到了一些我不理解的GPU内存分配问题:我遇到一个OOM,而实际上似乎还有足够的VRAM可用.一些背景:我正在研究Ubuntu Gnome 16.04,使用的是GTX1060 6GB,Intel Xeon E3-1231V3和8GB RAM.所以现在首先是我能理解的错误消息的一部分,并且我将在最后为可能要求它提供帮助的任何人添加整个错误消息:
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 8 Chunks of size 256 totalling 2.0KiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 1280 totalling 1.2KiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] 5 Chunks of size 44288 totalling 216.2KiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] 5 Chunks of size 56064 totalling 273.8KiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] 4 Chunks of size 154350080 totalling 588.80MiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] 3 Chunks of size 813400064 totalling 2.27GiB I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 1612612352 totalling 1.50GiB I tensorflow/core/common_runtime/bfc_allocator.cc:700] Sum Total of in-use chunks: 4.35GiB I tensorflow/core/common_runtime/bfc_allocator.cc:702] …
我曾尝试在Google Cloud Platform中创建GPU实例,但每次尝试创建实例时,它都会显示"您已达到0 GPU NVIDIA K80的限制".
我正在尝试使用4个vCPU,8-15 gb内存,1个GPU以及us-east1-c/us-west1-b创建一个实例.
请帮助以下.
我正在遵循TensorFlow Retraining for Poets 的说明。GPU 利用率似乎很低,因此我retrain.py按照使用 GPU 中的说明对脚本进行了检测。日志验证了 TF 图是在 GPU 上构建的。我正在重新训练大量的课程和图像。 请帮我调整 TF 中的参数和重新训练脚本以利用 GPU。
我知道这个问题,我应该减少批量大小。这个脚本的“批量大小”由什么构成并不明显。我有 60 个班级和 1MM 的训练图像。它首先制作 1MM 瓶颈文件。那部分是 CPU 并且很慢,我理解这一点。然后它以 4,000 个步骤进行训练,在该步骤中每次需要 100 张图像。这是批次吗?如果我减少每一步的图像数量,GPU 利用率会上升吗?
您的帮助将不胜感激!
我在尝试使用 CuDNNLSTM 而不是 keras.layers.LSTM 时遇到了一个问题。
这是我得到的错误:
无法使用模型配置调用 ThenRnnForward: [rnn_mode, rnn_input_mode, rnn_direction_mode]: 2, 0, 0 , [num_layers, input_size, num_units, dir_count, seq_length, batch_size]: [1, 300, 512, 5528] 1, [1, 1, 1, [{{node bidirectional_1/CudnnRNN_1}} = CudnnRNN[T=DT_FLOAT, _class=["loc:@train...NNBackprop"], direction="unidirectional", dropout=0, input_mode="linear_input", is_training=true , rnn_mode="lstm", seed=87654321, seed2=0, _device="/job:localhost/replica:0/task:0/device:GPU:0"](bidirectional_1/transpose_1, bidirectional_1/ExpandDims_1, bidirectional_1/ExpandDims_1 , bidirectional_1/concat_1)]] [[{{node loss/mul/_75}} = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device=" /job:localhost/replica:0/task:0/device:GPU:0",send_device_incarnation=1, tensor_name="edge_1209_loss/mul", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]
另外,我在其中一次运行中遇到了这个错误:
内部错误:GPU 同步失败
每次运行后内核都会死掉。
当我尝试使用 CuDNNLSTM 在谷歌云上的 VM 实例上运行它时,我才开始收到此错误。
我的代码是:
MAX_LEN = max(len(article) for article in X_train_tokens)
EMBEDDING_DIM=300
vocab_size = len(word_to_id)
classes = …Run Code Online (Sandbox Code Playgroud) 我有一些 GPU 测试软件,我正在尝试使用 python3 自动化,测试通常会运行 3 分钟,然后由用户使用 ctrl+c 取消,生成以下输出
使用 ctrl+c 退出后,可以再次运行测试,没有问题
当尝试使用子进程 popen 并发送 SIGINT 或 SIGTERM 来自动执行此操作时,我得到的结果与使用键盘输入时的结果不同。脚本突然退出,并且在后续运行中找不到 GPU(假设它没有正确卸载驱动程序)
from subprocess import Popen, PIPE
from signal import SIGINT
from time import time
def check_subproc_alive(subproc):
return subproc.poll() is None
def print_subproc(subproc, timer=True):
start_time = time()
while check_subproc_alive(subproc):
line = subproc.stdout.readline().decode('utf-8')
print(line, end="")
if timer and (time() - start_time) > 10:
break
subproc = Popen(['./gpu_test.sh', '-t', '1'], stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=False)
print_subproc(subproc)
subproc.send_signal(SIGINT)
print_subproc(subproc, False)
Run Code Online (Sandbox Code Playgroud)
如何将 ctrl+c 发送到子进程,就像用户键入它一样?
**更新
import subprocess …Run Code Online (Sandbox Code Playgroud) 我最近在计算机上安装了tensorflow 2.0,但是当我尝试在 GPU 上运行它时,Jupyter 或 Vitual Studio Code 上的函数tf.config.experimental.list_physical_devices('GPU')会返回一个空数组。你知道为什么吗 ?
我的设置:
电脑:微星
处理器:Intel(R) Core(TM) i7-8750H CPU @ 2.220GHz
GPU 0:英特尔(R) 超高清显卡 630
显卡:NVIDIA GeForce GTX 1060
Python:Ananconda 3 与 Python 3.7
Tensenflow 2.0 安装有pip install tensorflow
我的测试代码:
physical_devices = tf.config.experimental.list_physical_devices('GPU')
print(physical_devices)
if physical_devices:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
Run Code Online (Sandbox Code Playgroud)
提前致谢 !:)
我使用此脚本在安装并启用了 GPU 的机器上训练模型和预测,并且它似乎在预测阶段仅使用 CPU。
我在这.predict()部分看到的设备放置日志如下:
2020-09-01 06:08:19.085400: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op RangeDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.085617: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op RepeatDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.089558: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op MapDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.090003: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op PrefetchDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097064: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op FlatMapDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097647: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op TensorDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097802: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op RepeatDataset in device …Run Code Online (Sandbox Code Playgroud) Dataset如果我们使用和类的组合Dataloader(如下所示),我必须使用或显式地将数据加载到GPU上。有没有办法指示数据加载器自动/隐式执行此操作?.to().cuda()
理解/重现场景的代码:
from torch.utils.data import Dataset, DataLoader
import numpy as np
class DemoData(Dataset):
def __init__(self, limit):
super(DemoData, self).__init__()
self.data = np.arange(limit)
def __len__(self):
return self.data.shape[0]
def __getitem__(self, idx):
return (self.data[idx], self.data[idx]*100)
demo = DemoData(100)
loader = DataLoader(demo, batch_size=50, shuffle=True)
for i, (i1, i2) in enumerate(loader):
print('Batch Index: {}'.format(i))
print('Shape of data item 1: {}; shape of data item 2: {}'.format(i1.shape, i2.shape))
# i1, i2 = i1.to('cuda:0'), i2.to('cuda:0')
print('Device of data item 1: {}; …Run Code Online (Sandbox Code Playgroud) 我们有一个用霍夫曼编码编码的数据库.这里的目的是在GPU上复制它与相关的解码器; 然后在GPU上解码数据库,并在这个解码的数据库上执行操作,而无需将其复制回CPU上.
我远远不是霍夫曼专家,但我知道的少数人表明它似乎是一种基本上基于控制结构的算法.使用基本算法,恐怕会有很多序列化操作.
我的两个问题是:
我看到其他约束,但它们并不重要: - GPU处理树的效率不高:二叉树可以存储在经典数组中 - 工作量很难平衡:我们会看到
使用Gensim提供的Word2vec和Doc2vec方法,他们有一个使用BLAS,ATLAS等加速的分布式版本(详情请参见此处).但是,它支持GPU模式吗?如果使用Gensim,是否可以让GPU工作?
gpu ×10
python ×4
tensorflow ×4
keras ×2
python-3.x ×2
algorithm ×1
cloud ×1
gcp ×1
gensim ×1
gpgpu ×1
huffman-code ×1
linux ×1
lstm ×1
optimization ×1
pytorch ×1
vram ×1