Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
63b17b09
提交
63b17b09
authored
3月 25, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
'use a new way to init pycuda to work correctly with newer version of Theano and Pycuda.'
上级
f608b307
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
30 行增加
和
6 行删除
+30
-6
pycuda_example.py
theano/misc/pycuda_example.py
+5
-3
pycuda_init.py
theano/misc/pycuda_init.py
+21
-0
test_pycuda.py
theano/misc/tests/test_pycuda.py
+4
-3
没有找到文件。
theano/misc/pycuda_example.py
浏览文件 @
63b17b09
...
@@ -22,13 +22,15 @@ from theano.sandbox.cuda import GpuElemwise, CudaNdarrayType
...
@@ -22,13 +22,15 @@ from theano.sandbox.cuda import GpuElemwise, CudaNdarrayType
from
theano.sandbox.cuda.basic_ops
import
as_cuda_ndarray_variable
,
gpu_contiguous
from
theano.sandbox.cuda.basic_ops
import
as_cuda_ndarray_variable
,
gpu_contiguous
from
theano.sandbox.cuda.opt
import
gpu_seqopt
from
theano.sandbox.cuda.opt
import
gpu_seqopt
import
pycuda_init
if
not
pycuda_init
.
pycuda_available
:
raise
Exception
(
"No pycuda available. You can't load pycuda_example.py"
)
import
pycuda
from
pycuda.elementwise
import
ElementwiseKernel
from
pycuda.elementwise
import
ElementwiseKernel
from
pycuda.compiler
import
SourceModule
from
pycuda.compiler
import
SourceModule
from
pycuda.gpuarray
import
splay
from
pycuda.tools
import
VectorArg
from
pycuda.tools
import
VectorArg
import
pycuda.autoinit
def
theano_parse_c_arg
(
c_arg
):
def
theano_parse_c_arg
(
c_arg
):
c_arg
=
c_arg
.
replace
(
'npy_float32'
,
'float'
)
c_arg
=
c_arg
.
replace
(
'npy_float32'
,
'float'
)
c_arg
=
c_arg
.
replace
(
'npy_float64'
,
'double'
)
c_arg
=
c_arg
.
replace
(
'npy_float64'
,
'double'
)
...
...
theano/misc/pycuda_init.py
0 → 100644
浏览文件 @
63b17b09
import
os
import
theano
def
select_gpu_from_theano
():
# Transfer the theano gpu binding to pycuda, for consistency
theano_to_pycuda_device_map
=
{
"cpu"
:
"0"
,
"gpu0"
:
"0"
,
"gpu1"
:
"1"
,
"gpu2"
:
"2"
,
"gpu3"
:
"3"
}
os
.
environ
[
"CUDA_DEVICE"
]
=
theano_to_pycuda_device_map
.
get
(
theano
.
config
.
device
,
"0"
)
select_gpu_from_theano
()
pycuda_available
=
False
try
:
import
pycuda
import
pycuda.autoinit
pycuda_available
=
True
except
ImportError
:
pass
theano/misc/tests/test_pycuda.py
浏览文件 @
63b17b09
import
numpy
import
numpy
try
:
import
theano
import
pycuda
import
theano.misc.pycuda_init
except
ImportError
:
if
not
theano
.
misc
.
pycuda_init
.
pycuda_available
:
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
raise
SkipTest
(
"Pycuda not installed. Skip test of theano op with pycuda code."
)
raise
SkipTest
(
"Pycuda not installed. Skip test of theano op with pycuda code."
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论