Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7509e8a5
提交
7509e8a5
authored
6月 13, 2016
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add stuff about how to interact with pycuda.
上级
d4f7d749
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
0 行删除
+39
-0
extending_theano_gpu.txt
doc/extending/extending_theano_gpu.txt
+39
-0
没有找到文件。
doc/extending/extending_theano_gpu.txt
浏览文件 @
7509e8a5
...
@@ -154,3 +154,42 @@ An example calling the above kernel would be::
...
@@ -154,3 +154,42 @@ An example calling the above kernel would be::
err = GpuKernel_call(&%(kname)s, 1, &ls, &gs, 0, args);
err = GpuKernel_call(&%(kname)s, 1, &ls, &gs, 0, args);
// ...
// ...
Wrapping exisiting libraries
============================
PyCUDA
------
For things in PyCUDA (or things wrapped with PyCUDA), we usually need
to create a PyCUDA context. This can be done with the following
code::
with gpuarray_cuda_context:
pycuda_context = pycuda.driver.Context.attach()
If you don't need to create a context, because the library doesn't
require it, you can also just use the pygpu context and a `with`
statement like above for all your code which will make the context the
current context on the cuda stack.
GpuArray objects are compatible with PyCUDA and will expose the
necessary interface so that they can be used in most things. One
notable exception is PyCUDA kernels which require native objects. If
you need to convert a pygpu GpuArray to a PyCUDA GPUArray, this code
should do the trick::
assert pygpu_array.flags['IS_C_CONTIGUOUS']
pycuda_array = pycuda.gpuarray.GPUArray(pygpu_array.shape,
pygpu_array.dtype,
base=pygpu_array,
gpudata=(pygpu_array.gpudata +
pygpu_array.offset))
As long as the computations happen on the NULL stream there are no
special considerations to watch for with regards to synchronization.
Otherwise, you will have to make sure that you synchronize the pygpu
objects by calling the `.sync()` method before scheduling any work and
synchronize with the work that happends in the library after all the
work is scheduled.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论