Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ff120e15
提交
ff120e15
authored
12月 01, 2016
作者:
Arnaud Bergeron
提交者:
Frederic Bastien
12月 22, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Now that we have dicts on GpuContext get rid of the horrible prop hack.
上级
f7596c63
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
64 行删除
+39
-64
__init__.py
theano/gpuarray/__init__.py
+33
-36
dnn.py
theano/gpuarray/dnn.py
+6
-8
type.py
theano/gpuarray/type.py
+0
-20
没有找到文件。
theano/gpuarray/__init__.py
浏览文件 @
ff120e15
...
...
@@ -27,7 +27,7 @@ except ImportError:
# This is for documentation not to depend on the availability of pygpu
from
.type
import
(
GpuArrayType
,
GpuArrayVariable
,
GpuArrayConstant
,
GpuArraySharedVariable
,
gpuarray_shared_constructor
,
reg_context
,
get_context
,
ContextNotDefined
,
_get_props
)
reg_context
,
get_context
,
ContextNotDefined
)
from
.basic_ops
import
as_gpuarray_variable
from
.
import
fft
,
dnn
,
opt
,
nerv
,
extra_ops
,
multinomial
,
reduction
...
...
@@ -50,50 +50,32 @@ def init_dev(dev, name=None):
# This is for the C headers API
if
pygpu
.
gpuarray
.
api_version
()[
0
]
<
0
:
raise
ValueError
(
"Your installed libgpuarray is too old, please update"
)
need_preallocate
=
False
if
dev
not
in
init_dev
.
devmap
:
ctx
=
pygpu
.
init
(
dev
,
disable_alloc_cache
=
config
.
gpuarray
.
preallocate
<
0
,
single_stream
=
config
.
gpuarray
.
single_stream
,
sched
=
config
.
gpuarray
.
sched
)
init_dev
.
devmap
[
dev
]
=
ctx
if
config
.
gpuarray
.
preallocate
<
0
:
print
(
"Disabling allocation cache on
%
s"
%
(
dev
,))
elif
config
.
gpuarray
.
preallocate
>
0
:
need_preallocate
=
True
context
=
init_dev
.
devmap
[
dev
]
# This will map the context name to the real context object.
reg_context
(
name
,
context
)
if
config
.
print_active_device
:
try
:
pcibusid
=
context
.
pcibusid
except
pygpu
.
gpuarray
.
UnsupportedException
:
pcibusid
=
'(unsupported for device
%
s)'
%
dev
print
(
"Mapped name
%
s to device
%
s:
%
s"
%
(
name
,
dev
,
context
.
devname
),
file
=
sys
.
stderr
)
print
(
"PCI Bus ID:"
,
pcibusid
,
file
=
sys
.
stderr
)
pygpu_activated
=
True
ctx_props
=
_get_props
(
name
)
ctx_props
[
'dev'
]
=
dev
if
dev
.
startswith
(
'cuda'
):
if
'cudnn_version'
not
in
ctx_props
:
if
init_dev
.
dnn_version
is
None
and
dev
.
startswith
(
'cuda'
):
try
:
ctx_props
[
'cudnn_version'
]
=
dnn
.
version
()
init_dev
.
dnn_version
=
dnn
.
version
()
# 5200 should not print warning with cudnn 5.1 final.
if
ctx_props
[
'cudnn_version'
]
>=
5200
:
if
init_dev
.
dnn_version
>=
5200
:
warnings
.
warn
(
"Your cuDNN version is more recent than "
"Theano. If you encounter problems, try "
"updating Theano or downgrading cuDNN to "
"version 5.1."
)
if
config
.
print_active_device
:
print
(
"Using cuDNN version
%
d on context
%
s"
%
(
ctx_props
[
'cudnn_version'
],
name
),
file
=
sys
.
stderr
)
ctx_props
[
'cudnn_handle'
]
=
dnn
.
_make_handle
(
context
)
print
(
"Using cuDNN version
%
d"
%
(
init_dev
.
dnn_version
,
name
),
file
=
sys
.
stderr
)
except
Exception
:
pass
if
need_preallocate
:
if
dev
not
in
init_dev
.
devmap
:
ctx
=
pygpu
.
init
(
dev
,
disable_alloc_cache
=
config
.
gpuarray
.
preallocate
<
0
,
single_stream
=
config
.
gpuarray
.
single_stream
,
sched
=
config
.
gpuarray
.
sched
)
ctx
.
dev
=
dev
init_dev
.
devmap
[
dev
]
=
ctx
if
dev
.
startswith
(
'cuda'
):
ctx
.
cudnn_handle
=
dnn
.
_make_handle
(
ctx
)
if
config
.
gpuarray
.
preallocate
<
0
:
print
(
"Disabling allocation cache on
%
s"
%
(
dev
,))
elif
config
.
gpuarray
.
preallocate
>
0
:
MB
=
(
1024
*
1024
)
if
config
.
gpuarray
.
preallocate
<=
1
:
gmem
=
min
(
config
.
gpuarray
.
preallocate
,
0.95
)
*
context
.
total_gmem
...
...
@@ -110,8 +92,23 @@ def init_dev(dev, name=None):
(
gmem
//
MB
,
ctx
.
total_gmem
//
MB
,
gmem
/
ctx
.
total_gmem
,
dev
),
file
=
sys
.
stderr
)
context
=
init_dev
.
devmap
[
dev
]
# This will map the context name to the real context object.
reg_context
(
name
,
context
)
if
config
.
print_active_device
:
try
:
pcibusid
=
'('
+
context
.
pcibusid
+
')'
except
pygpu
.
gpuarray
.
UnsupportedException
:
pcibusid
=
''
print
(
"Mapped name
%
s to device
%
s:
%
s
%
s"
%
(
name
,
dev
,
context
.
devname
,
pcibusid
),
file
=
sys
.
stderr
)
pygpu_activated
=
True
# This maps things like 'cuda0' to the context object on that device.
init_dev
.
devmap
=
{}
init_dev
.
dnn_version
=
None
if
pygpu
:
try
:
...
...
theano/gpuarray/dnn.py
浏览文件 @
ff120e15
...
...
@@ -30,7 +30,7 @@ from theano.tensor.signal.pool import (
Pool
,
MaxPoolGrad
,
AveragePoolGrad
)
from
.
import
pygpu
from
.type
import
(
get_context
,
gpu_context_type
,
list_contexts
,
get_prop
,
set_prop
,
GpuArraySharedVariable
)
GpuArraySharedVariable
)
from
.basic_ops
import
(
as_gpuarray_variable
,
infer_context_name
,
gpu_contiguous
,
gpu_alloc_empty
,
empty_like
,
GpuArrayType
)
...
...
@@ -209,14 +209,12 @@ class DnnBase(COp):
return
node
.
outputs
[
0
]
.
type
.
context_name
def
get_params
(
self
,
node
):
try
:
return
get_prop
(
self
.
dnn_context
(
node
),
'cudnn_handle_param'
)
except
KeyError
:
pass
ptr
=
get_prop
(
self
.
dnn_context
(
node
),
'cudnn_handle'
)
.
value
ctx
=
self
.
dnn_context
(
node
)
if
not
hasattr
(
ctx
,
'cudnn_handle_param'
):
ptr
=
ctx
.
cudnn_handle
.
value
res
=
handle_type
.
make_value
(
ptr
)
set_prop
(
self
.
dnn_context
(
node
),
'cudnn_handle_param'
,
res
)
return
res
ctx
.
cudnn_handle_param
=
res
return
ctx
.
cudnn_handle_param
def
__init__
(
self
,
files
=
None
,
c_func
=
None
):
if
files
is
None
:
...
...
theano/gpuarray/type.py
浏览文件 @
ff120e15
...
...
@@ -97,26 +97,6 @@ def list_contexts():
"""
return
_context_reg
.
keys
()
# Mappings of properties to contexts. Please never use this if you
# can avoid it.
# This is basically a way to store "global" variables that depend on
# the context.
_props_map
=
{}
def
_get_props
(
name
):
ctx
=
get_context
(
name
)
return
_props_map
[
ctx
]
def
get_prop
(
name
,
k
):
return
_get_props
(
name
)[
k
]
def
set_prop
(
name
,
k
,
v
):
_get_props
(
name
)[
k
]
=
v
# Private method
def
_name_for_ctx
(
ctx
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论