CUDA编程指南的内容如下:
warp一次执行一条通用指令,因此,当warp的所有32个线程都同意它们的执行路径时,就可以实现充分的效率。如果warp的线程通过依赖于数据的条件分支发散,则warp会串行执行所采用的每个分支路径,从而禁用不在该路径上的线程,并且当所有路径完成时,这些线程会聚回到同一执行路径。
由于一次常见的指示,我正在考虑步调一致。
我的Cuda程序获得了显着的性能提升(平均),具体取决于块的大小和块数; 其中"线程"的总数保持不变.(我不确定线程是否是正确的术语......但我将在这里使用它;每个内核的总线程数是(块数)*(块大小)).我制作了一些图表来说明我的观点.
但首先让我先解释一下我的算法是什么,但我不确定它是多么相关,因为我认为这适用于所有GPGPU程序.但也许我错了.
基本上我会遇到逻辑上被视为2D数组的大型数组,其中每个线程从数组中添加一个元素,并将该值的平方添加到另一个变量,然后在最后将值写入另一个数组,其中每个读取所有线程都以某种方式移位.这是我的内核代码:
__global__ void MoveoutAndStackCuda(const float* __restrict__ prestackTraces, float* __restrict__ stackTracesOut,
float* __restrict__ powerTracesOut, const int* __restrict__ sampleShift,
const unsigned int samplesPerT, const unsigned int readIns,
const unsigned int readWidth, const unsigned int defaultOffset) {
unsigned int globalId = ((blockIdx.x * blockDim.x) + threadIdx.x); // Global ID of this thread, starting from 0 to total # of threads
unsigned int jobNum = (globalId / readWidth); // Which array within the overall program this thread works on …Run Code Online (Sandbox Code Playgroud) 我需要使用CUDA计算2D数组的平均值,但我不知道如何继续.我开始做列减少之后,我将得到结果数组的总和,并在最后一步我将计算平均值.
要做到这一点,我需要立即在设备上完成整个工作?或者我只是一步一步地做,每一步都需要来回和来自CPU和GPU.
我正在尝试按照以下说明安装 xgboost gpu 支持版本。xgboost-gpu-support
我使用 windows 10,visual studio 2017。不支持 GPU 的版本工作正常。但是对于支持 gpu 的版本?当我从 Visual Studio 释放模式时,它输出错误链接:致命错误 LNK1181:无法打开输入文件“Release\gpuxgboost.lib”。
在前面的步骤中,一切都进行得很好。我怎样才能解决这个问题?提前致谢。
(我的项目是D:\Software\xgboost\xgboost\build\ALL_BUILD.vcxproj,没有空间。所以这个解决方案不起作用。lnk1181-error-message-when-you-build-a-manag
我怎样才能让tensorflow使用特定的gpu进行推断?
部分源代码
std::unique_ptr<tensorflow::Session> session;
Status const load_graph_status = LoadGraph(graph_path, &session);
if (!load_graph_status.ok()) {
LOG(ERROR) << "LoadGraph ERROR!!!!"<< load_graph_status;
return -1;
}
std::vector<Tensor> resized_tensors;
Status const read_tensor_status = ReadTensorFromImageFile(image_path, &resized_tensors);
if (!read_tensor_status.ok()) {
LOG(ERROR) << read_tensor_status;
return -1;
}
std::vector<Tensor> outputs;
Status run_status = session->Run({{input_layer, resized_tensor}},
output_layer, {}, &outputs);
Run Code Online (Sandbox Code Playgroud)
到目前为止一切都很好,但是当我执行Run时,tensorflow总是选择相同的gpu,我是否有办法指定要执行的gpu?
如果您需要完整的源代码,我将它们放在pastebin上
编辑:看起来options.config.mutable_gpu_options()-> set_visible_device_list(“ 0”)工作,但我不确定。
一直在网上搜索数小时,没有任何结果,所以我想在这里问。
我正在尝试按照Sentdex的教程制作自动驾驶汽车,但是在运行模型时,会遇到很多致命错误。我已经在整个互联网上搜索了解决方案,许多似乎都遇到了同样的问题。但是,我发现的所有解决方案(包括此Stack-post)都不适合我。
这是我的软件:
硬件:
这是崩溃日志:
2018-02-04 16:29:33.606903: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_blas.cc:444] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2018-02-04 16:29:33.608872: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_blas.cc:444] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2018-02-04 16:29:33.609308: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_blas.cc:444] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2018-02-04 16:29:35.145249: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_dnn.cc:385] could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED
2018-02-04 16:29:35.145563: E C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\stream_executor\cuda\cuda_dnn.cc:352] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2018-02-04 16:29:35.149896: F C:\tf_jenkins\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\kernels\conv_ops.cc:717] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms)
这是我的代码:
import tensorflow …Run Code Online (Sandbox Code Playgroud) 我在fedora 27上安装了cuda和tensorflow-gpu。但是要构建tensorflow的二进制文件,它需要gcc和版本低于6的g ++。Fedora随附已安装的gcc和版本7.3.1的g ++。谁能帮助我安装旧版本的gcc和g ++?我已经尝试过:
sudo dnf install compat-gcc-<version>
Run Code Online (Sandbox Code Playgroud)
但这没用。
我想写一个函数来告诉我一个指针是主机指针还是设备指针。这本质上是一个包装器cudaPointerGetAttributes(),如果指针用于设备,则返回 1 或 0。
我无法理解的是,为什么cudaPointerGetAttributes在测试主机指针时返回无效参数会导致错误检查失败。下面提供了一个示例。
#include <stdio.h>
#include <stdlib.h>
#define CUDA_ERROR_CHECK(fun) \
do{ \
cudaError_t err = fun; \
if(err != cudaSuccess) \
{ \
fprintf(stderr, "Cuda error %d %s:: %s\n", __LINE__, __func__, cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
}while(0);
int is_device_pointer(const void *ptr)
{
int is_device_ptr = 0;
cudaPointerAttributes attributes;
CUDA_ERROR_CHECK(cudaPointerGetAttributes(&attributes, ptr));
if(attributes.devicePointer != NULL)
{
is_device_ptr = 1;
}
return is_device_ptr;
}
int main()
{
int *host_ptr, x = 0;
int is_dev_ptr;
host_ptr = …Run Code Online (Sandbox Code Playgroud) 我阅读了D3D11用法页面并来自CUDA背景我想知道标记为D3D11_USAGE_STAGING存储的纹理会是什么样的内存.
我想在CUDA中它会固定页面锁定的零拷贝内存.我测量了从ID3D11Texture2Dwith D3D11_USAGE_STAGING到分配的主机缓冲区的传输时间,malloc花了将近7毫秒(在流媒体/游戏中相当多),我认为这将是从GPU全局内存到内存区域所需的时间.
我的任何假设都是正确的吗?什么D3D11_USAGE_STAGING用作GPU内存?
cuda ×4
gpu ×3
tensorflow ×3
gpgpu ×2
python ×2
c++ ×1
directx ×1
directx-11 ×1
fedora ×1
linux ×1
lnk ×1
pandas ×1
performance ×1
python-3.x ×1
windows ×1
xgboost ×1