我的 GPU 没有被 Keras/TensorFlow 使用。
为了让我的 GPU 与 tensorflow 一起工作,我通过 pip 安装了 tensorflow-gpu(我在 Windows 上使用 Anaconda)
我有英伟达 1080ti
print(tf.test.is_gpu_available())
True
Run Code Online (Sandbox Code Playgroud)
print(tf.config.experimental.list_physical_devices())
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),
PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
Run Code Online (Sandbox Code Playgroud)
我绑
physical_devices = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(physical_devices[0], True)
Run Code Online (Sandbox Code Playgroud)
但它没有帮助
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
print(sess)
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1
<tensorflow.python.client.session.Session object at 0x000001A2A3BBACF8>
Run Code Online (Sandbox Code Playgroud)
来自 tf 的唯一警告:
W tensorflow/stream_executor/cuda/redzone_allocator.cc:312] Internal: Invoking ptxas not supported on Windows
Run Code Online (Sandbox Code Playgroud)
整个日志:
2019-10-18 20:06:26.094049: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll …
Run Code Online (Sandbox Code Playgroud) 我将统一缓冲区传递给 vulkan 中的计算着色器。缓冲区包含 49 个浮点数的数组(高斯矩阵)。一切都很好,但是当我在着色器中读取数组时,它只给出了 13 个值,其他都是 0 或垃圾,它们对应于初始数组的 0、4、8 等。我认为它是某种对齐问题
着色器布局是
struct Pixel
{
vec4 value;
};
layout(push_constant) uniform params_t
{
int width;
int height;
} params;
layout(std140, binding = 0) buffer buf
{
Pixel imageData[];
};
layout (binding = 1) uniform sampler2D inputTex;
layout (binding = 2) uniform unf_t
{
float gauss[SAMPLE_SIZE*SAMPLE_SIZE];
};
Run Code Online (Sandbox Code Playgroud)
绑定 0 会影响绑定 2 吗?如果是这样,我如何将数组复制到所需对齐的缓冲区?目前我使用
vkCmdUpdateBuffer(a_cmdBuff, a_uniform, 0, a_gaussSize, (const uint32_t *)gauss)
Run Code Online (Sandbox Code Playgroud)
或者分成不同的集合可能会更好?
编辑:通过扩展缓冲区和数组,我设法以 16 的对齐方式传递它,一切都很好,但它看起来像是浪费内存。如何将浮点数对齐 4?