问题标签 [curand]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
482 浏览

random - CUDA 的 Mersenne Twister 用于任意数量的线程

CUDA 对Mersenne Twister( MT) 随机数生成器的实现仅限于线程/块256200块/网格的最大数量,即最大线程数是51200

因此,无法启动使用 MT 的内核

在哪里

是线程的n总数。

MT使用for的最佳方式是threads > 51200什么?

我的方法是否为 and 使用常量值blocksPerGridthreadsPerBlock例如<<<128,128>>>并在内核代码中使用以下内容:

我不确定这是否是正确的方式,或者它是否会以不希望的方式影响 MT 状态?

谢谢你。

0 投票
1 回答
349 浏览

cuda - cuRAND 内核中随机数生成器的类型

问题How to generate random number inside pyCUDA kernel?,即

使用这个经典示例,激活的随机数生成器是什么(XORWOWMTGP32、其他)?

如何从内核中更改随机数生成器?

0 投票
0 回答
262 浏览

c# - ManagedCuda 内核找不到 curand.h

我正在尝试使用ManagedCuda编译使用currand library的内核。但是,我找不到告诉 CudaRuntimeCompiler 如何找到 curand.h 的方法。

如果我删除 ' #include <curand.h>' 行,一切正常。但是有了它,我得到:

使用完全限定的 include ( #include <C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include\curand.h>) 让我更进一步,所以这显然只是告诉编译器在哪里查找的一个例子。

我尝试将文件夹添加到路径中,但无济于事。

谁知道这个可以在哪里设置?(或者知道 ManagedCuda 的替代包?)

下面的所有代码。

C#代码:

内核.c

从 NuGet 安装 MangedCuda-100 (10.0.31) 和 ManagedCuda-NVRTC (10.0.31)。

0 投票
1 回答
3821 浏览

cuda - curandState*的PyCUDA非法内存访问

我正在研究入侵物种的传播,并尝试使用 XORWOW 随机数生成器在 PyCUDA 内核中生成随机数。我需要能够在研究中用作输入的矩阵非常大(高达 8,000 x 8,000)。

get_random_number索引curandState*XORWOW 生成器时,错误似乎发生在内部。该代码在较小的矩阵上执行没有错误并产生正确的结果。我在 2 个 NVidia Tesla K20X GPU 上运行我的代码。

内核代码和设置:

数据设置:

内核调用:

我希望能够为最大 (8,000 x 8,000) 的矩阵生成范围 (0,1] 内的随机数,但是在大型矩阵上执行我的代码会导致非法内存访问错误。

我索引curandState*不正确get_random_number吗?如果不是,还有什么可能导致此错误?

0 投票
1 回答
162 浏览

python - 如何在 PyCuda 的内核中初始化和运行 Mersenne Twister Random Generator

我想在 pyCuda 内核中使用 Mersenne Twister 随机生成器进行数值实验。通过互联网,我没有找到如何做到这一点的简单示例,因此,我尝试从 Cuda 文档和 pyCuda 示例(下面的 pyCuda 代码)构建一些东西。

如何正确完成?

谢谢你。

0 投票
1 回答
378 浏览

random - cuRAND performs much worse than thrust when generating random numbers inside CUDA kernels

I am trying to generate "random" numbers from a uniform distribution inside a CUDA __global__ kernel using two different approaches. The first is using the cuRAND device API, and the second is using thrust. For each approach I have created a different class.

Here is my cuRAND solution:

And here is my thrust solution:

The way I use them is the following:

Both of them work but the cuRAND solution is much slower (more than 3 times slower). If I set the second parameter of curand_init (sequence number) to 0, then the performance is the same as that of the thrust solution, but the random numbers are "bad". I can see patterns and artefacts in the resulting distribution.

Here are my two questions:

  • Can someone explain to me why the cuRAND solution with a non-zero sequence is slower?
  • How can thrust be as fast as cuRAND with zero sequence, but also generate good random numbers?
  • While searching on Google, I noticed that most people use cuRAND, and very few use thrust to generate random numbers inside device code. Is there something I should be aware of? Am I misusing thrust?

Thank you.

0 投票
1 回答
174 浏览

python - PyCUDA 中的内存分配顺序是否重要?

我在 CUDA 统一内存 [ 2 ] 上使用 PyCUDA 的接口 [ 1 ]。在某些时候,我添加了随机数生成器 [ 3 ] 并盯着 Jupyter Notebook 中的死内核: 内核似乎已经死了

我将问题缩小到创建随机数生成器。或者,准确地说,到我这样做的那一刻:

上面的代码在没有任何错误消息的情况下失败,但是如果我将gpu_generator = ...行放在更高或更低的一行,它似乎可以正常工作

我相信 PyCUDA 可能会以某种方式无法执行preparecall,这归结为这个内核:

知道可能是什么问题吗?

0 投票
1 回答
907 浏览

cuda - 在抛出 'thrust::system::system_error' 的实例后调用终止 what(): parallel_for failed: cudaErrorInvalidValue: invalid argument

我正在尝试计算 curand_uniform() 返回 1.0 的次数。但是我似乎无法让以下代码为我工作:

我收到终端错误(在 linux 上):

我正在这样编译:

我不明白这个错误信息。

0 投票
0 回答
42 浏览

cuda - 为什么我的代码在多次调用 curand 时会失败?

当我将 numPaths 增加到 1000000 时,下面的 Monte-Carlo 代码失败(“进程以代码 -2147483645 退出”,价格函数的输出不会被打印),除非我同时减少 numSteps。如果我删除对 curand 的所有引用并使用固定数字,代码总是有效,所以我认为问题与生成太多随机数有关。我尝试使用每个线程的新种子而不是新的子序列来调用 curand_init,但它没有解决问题。

另外,我在使用 Thrust 而不是 curand 生成随机数时遇到了同样的问题。

有人可以帮忙吗?