Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f38289c9
提交
f38289c9
authored
4月 13, 2017
作者:
Pascal Lamblin
提交者:
GitHub
4月 13, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5735 from abergeron/disk_cache
Disk cache option for gpuarray
上级
00935985
e7582189
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
44 行增加
和
43 行删除
+44
-43
config.txt
doc/library/config.txt
+8
-0
configdefaults.py
theano/configdefaults.py
+10
-28
cmodule.py
theano/gof/cmodule.py
+3
-0
__init__.py
theano/gpuarray/__init__.py
+23
-15
没有找到文件。
doc/library/config.txt
浏览文件 @
f38289c9
...
@@ -431,6 +431,7 @@ import theano and print the config variable, as in:
...
@@ -431,6 +431,7 @@ import theano and print the config variable, as in:
automatically to get more memory. But this can cause
automatically to get more memory. But this can cause
fragmentation, see note above.
fragmentation, see note above.
.. attribute:: config.gpuarray.sched
.. attribute:: config.gpuarray.sched
String value: ``'default'``, ``'multi'``, ``'single'``
String value: ``'default'``, ``'multi'``, ``'single'``
...
@@ -462,6 +463,13 @@ import theano and print the config variable, as in:
...
@@ -462,6 +463,13 @@ import theano and print the config variable, as in:
performance, check both options.
performance, check both options.
.. attribute:: config.gpuarray.cache_path
Default: ``config.compiledir``/gpuarray_kernels
Directory to cache pre-compiled kernels for the gpuarray backend.
.. attribute:: linker
.. attribute:: linker
String value: ``'c|py'``, ``'py'``, ``'c'``, ``'c|py_nogc'``
String value: ``'c|py'``, ``'py'``, ``'c'``, ``'c|py_nogc'``
...
...
theano/configdefaults.py
浏览文件 @
f38289c9
...
@@ -491,33 +491,6 @@ AddConfigVar(
...
@@ -491,33 +491,6 @@ AddConfigVar(
EnumStr
(
'warn'
,
'raise'
,
'pdb'
,
'ignore'
),
EnumStr
(
'warn'
,
'raise'
,
'pdb'
,
'ignore'
),
in_c_key
=
False
)
in_c_key
=
False
)
def
safe_no_home
(
home
):
"""
Make sure the user is not attempting to use `config.home`.
This config option was removed in Thenao 0.5 since it was redundant with
`config.base_compiledir`. This filter function ensures people who were
setting the location of their compilation directory through `config.home`
switch to `config.basecompiledir` instead, by raising an error when
`config.home` is used.
"""
if
home
:
raise
RuntimeError
(
'The `config.home` option has been removed and should not be '
'used anymore. Please set the `config.base_compiledir` option '
'instead (for instance to:
%
s)'
%
os
.
path
.
join
(
home
,
'.theano'
))
return
True
AddConfigVar
(
'home'
,
"This config option was removed in 0.5: do not use it!"
,
ConfigParam
(
''
,
allow_override
=
False
,
filter
=
safe_no_home
),
in_c_key
=
False
)
AddConfigVar
(
AddConfigVar
(
'nocleanup'
,
'nocleanup'
,
"Suppress the deletion of code files that did not compile cleanly"
,
"Suppress the deletion of code files that did not compile cleanly"
,
...
@@ -1708,13 +1681,22 @@ def default_compiledir():
...
@@ -1708,13 +1681,22 @@ def default_compiledir():
AddConfigVar
(
AddConfigVar
(
'compiledir'
,
'compiledir'
,
"platform-dependent cache directory for compiled modules"
,
"platform-dependent cache directory for compiled modules"
,
ConfigParam
(
ConfigParam
(
default_compiledir
,
default_compiledir
,
filter
=
filter_compiledir
,
filter
=
filter_compiledir
,
allow_override
=
False
),
allow_override
=
False
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'gpuarray.cache_path'
,
'Directory to cache pre-compiled kernels for the gpuarray backend.'
,
ConfigParam
(
lambda
:
os
.
path
.
join
(
config
.
compiledir
,
'gpuarray_kernels'
),
filter
=
filter_base_compiledir
,
allow_override
=
False
),
in_c_key
=
False
)
# Check if there are remaining flags provided by the user through THEANO_FLAGS.
# Check if there are remaining flags provided by the user through THEANO_FLAGS.
for
key
in
THEANO_FLAGS_DICT
.
keys
():
for
key
in
THEANO_FLAGS_DICT
.
keys
():
warnings
.
warn
(
'Theano does not recognise this flag: {0}'
.
format
(
key
))
warnings
.
warn
(
'Theano does not recognise this flag: {0}'
.
format
(
key
))
theano/gof/cmodule.py
浏览文件 @
f38289c9
...
@@ -750,6 +750,9 @@ class ModuleCache(object):
...
@@ -750,6 +750,9 @@ class ModuleCache(object):
if
subdirs_elem
==
'lock_dir'
:
if
subdirs_elem
==
'lock_dir'
:
continue
continue
root
=
os
.
path
.
join
(
self
.
dirname
,
subdirs_elem
)
root
=
os
.
path
.
join
(
self
.
dirname
,
subdirs_elem
)
# Don't delete the gpuarray kernel cache
if
root
==
config
.
gpuarray
.
cache_path
:
continue
key_pkl
=
os
.
path
.
join
(
root
,
'key.pkl'
)
key_pkl
=
os
.
path
.
join
(
root
,
'key.pkl'
)
if
key_pkl
in
self
.
loaded_key_pkl
:
if
key_pkl
in
self
.
loaded_key_pkl
:
continue
continue
...
...
theano/gpuarray/__init__.py
浏览文件 @
f38289c9
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
sys
import
sys
import
os
import
logging
import
logging
import
sys
import
warnings
import
warnings
import
theano
import
theano
...
@@ -31,6 +31,7 @@ from .type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
...
@@ -31,6 +31,7 @@ from .type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
from
.basic_ops
import
as_gpuarray_variable
from
.basic_ops
import
as_gpuarray_variable
from
.
import
fft
,
dnn
,
opt
,
nerv
,
extra_ops
,
multinomial
,
reduction
from
.
import
fft
,
dnn
,
opt
,
nerv
,
extra_ops
,
multinomial
,
reduction
def
transfer
(
x
,
target
):
def
transfer
(
x
,
target
):
try
:
try
:
get_context
(
target
)
get_context
(
target
)
...
@@ -41,7 +42,7 @@ def transfer(x, target):
...
@@ -41,7 +42,7 @@ def transfer(x, target):
register_transfer
(
transfer
)
register_transfer
(
transfer
)
def
init_dev
(
dev
,
name
=
None
):
def
init_dev
(
dev
,
name
=
None
,
preallocate
=
None
):
global
pygpu_activated
global
pygpu_activated
if
not
config
.
cxx
:
if
not
config
.
cxx
:
raise
RuntimeError
(
"The new gpu-backend need a c++ compiler."
)
raise
RuntimeError
(
"The new gpu-backend need a c++ compiler."
)
...
@@ -53,9 +54,13 @@ def init_dev(dev, name=None):
...
@@ -53,9 +54,13 @@ def init_dev(dev, name=None):
raise
ValueError
(
raise
ValueError
(
"Your installed libgpuarray is not in sync, please make sure to have the appropriate version"
)
"Your installed libgpuarray is not in sync, please make sure to have the appropriate version"
)
if
dev
not
in
init_dev
.
devmap
:
if
dev
not
in
init_dev
.
devmap
:
if
config
.
gpuarray
.
cache_path
!=
''
:
os
.
environ
[
'GPUARRAY_CACHE_PATH'
]
=
config
.
gpuarray
.
cache_path
if
preallocate
is
None
:
preallocate
=
config
.
gpuarray
.
preallocate
context
=
pygpu
.
init
(
context
=
pygpu
.
init
(
dev
,
dev
,
disable_alloc_cache
=
config
.
gpuarray
.
preallocate
<
0
,
disable_alloc_cache
=
preallocate
<
0
,
single_stream
=
config
.
gpuarray
.
single_stream
,
single_stream
=
config
.
gpuarray
.
single_stream
,
sched
=
config
.
gpuarray
.
sched
)
sched
=
config
.
gpuarray
.
sched
)
context
.
dev
=
dev
context
.
dev
=
dev
...
@@ -73,14 +78,14 @@ def init_dev(dev, name=None):
...
@@ -73,14 +78,14 @@ def init_dev(dev, name=None):
else
:
else
:
print
(
"Can not use cuDNN on context
%
s:
%
s"
%
(
name
,
dnn
.
dnn_available
.
msg
),
print
(
"Can not use cuDNN on context
%
s:
%
s"
%
(
name
,
dnn
.
dnn_available
.
msg
),
file
=
sys
.
stderr
)
file
=
sys
.
stderr
)
if
config
.
gpuarray
.
preallocate
<
0
:
if
preallocate
<
0
:
print
(
"Disabling allocation cache on
%
s"
%
(
dev
,))
print
(
"Disabling allocation cache on
%
s"
%
(
dev
,))
elif
config
.
gpuarray
.
preallocate
>
0
:
elif
preallocate
>
0
:
MB
=
(
1024
*
1024
)
MB
=
(
1024
*
1024
)
if
config
.
gpuarray
.
preallocate
<=
1
:
if
preallocate
<=
1
:
gmem
=
min
(
config
.
gpuarray
.
preallocate
,
0.95
)
*
context
.
total_gmem
gmem
=
min
(
preallocate
,
0.95
)
*
context
.
total_gmem
else
:
else
:
gmem
=
config
.
gpuarray
.
preallocate
*
MB
gmem
=
preallocate
*
MB
if
gmem
>
context
.
free_gmem
-
50
*
MB
:
if
gmem
>
context
.
free_gmem
-
50
*
MB
:
print
(
print
(
"WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly"
)
"WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly"
)
...
@@ -90,8 +95,8 @@ def init_dev(dev, name=None):
...
@@ -90,8 +95,8 @@ def init_dev(dev, name=None):
pygpu
.
empty
((
gmem
,),
dtype
=
'int8'
,
context
=
context
)
pygpu
.
empty
((
gmem
,),
dtype
=
'int8'
,
context
=
context
)
if
config
.
print_active_device
:
if
config
.
print_active_device
:
print
(
"Preallocating
%
d/
%
d Mb (
%
f) on
%
s"
%
print
(
"Preallocating
%
d/
%
d Mb (
%
f) on
%
s"
%
(
gmem
//
MB
,
context
.
total_gmem
//
MB
,
(
gmem
//
MB
,
context
.
total_gmem
//
MB
,
gmem
/
context
.
total_gmem
,
dev
),
gmem
/
context
.
total_gmem
,
dev
),
file
=
sys
.
stderr
)
file
=
sys
.
stderr
)
# Initialise the blas kernels. We do this after the
# Initialise the blas kernels. We do this after the
...
@@ -122,7 +127,8 @@ init_dev.devmap = {}
...
@@ -122,7 +127,8 @@ init_dev.devmap = {}
def
use
(
device
,
def
use
(
device
,
force
=
False
,
force
=
False
,
default_to_move_computation_to_gpu
=
True
,
default_to_move_computation_to_gpu
=
True
,
move_shared_to_gpu
=
True
):
move_shared_to_gpu
=
True
,
preallocate
=
None
):
"""
"""
Error and warning about CUDA should be displayed only when this
Error and warning about CUDA should be displayed only when this
function is called. We need to be able to load this module only
function is called. We need to be able to load this module only
...
@@ -140,17 +146,20 @@ def use(device,
...
@@ -140,17 +146,20 @@ def use(device,
computations to the gpu.
computations to the gpu.
move_shared_to_gpu
move_shared_to_gpu
If gpu init succeeded, put new shared variables on the gpu.
If gpu init succeeded, put new shared variables on the gpu.
preallocate
If specified, will use this value for preallocation instead of
gpuarray.preallocate.
"""
"""
if
force
:
if
force
:
if
not
device
.
startswith
(
'cuda'
):
if
not
(
device
.
startswith
(
'cuda'
)
or
device
.
startswith
(
'opencl'
)
):
raise
Exception
(
"forced the init and bad device provided: "
+
raise
Exception
(
"forced the init and bad device provided: "
+
device
)
device
)
else
:
else
:
# If we force, the device should not already be initialized.
# If we force, the device should not already be initialized.
assert
device
not
in
init_dev
.
devmap
assert
device
not
in
init_dev
.
devmap
if
device
:
if
device
:
init_dev
(
device
)
init_dev
(
device
,
preallocate
=
preallocate
)
if
default_to_move_computation_to_gpu
:
if
default_to_move_computation_to_gpu
:
optdb
.
add_tags
(
'gpuarray_opt'
,
'fast_run'
,
'fast_compile'
)
optdb
.
add_tags
(
'gpuarray_opt'
,
'fast_run'
,
'fast_compile'
)
optdb
.
add_tags
(
'gpua_scanOp_make_inplace'
,
'fast_run'
)
optdb
.
add_tags
(
'gpua_scanOp_make_inplace'
,
'fast_run'
)
...
@@ -183,8 +192,7 @@ if pygpu:
...
@@ -183,8 +192,7 @@ if pygpu:
from
.basic_ops
import
(
GpuAlloc
,
GpuAllocEmpty
,
GpuContiguous
,
GpuEye
,
from
.basic_ops
import
(
GpuAlloc
,
GpuAllocEmpty
,
GpuContiguous
,
GpuEye
,
GpuFromHost
,
GpuJoin
,
GpuReshape
,
GpuSplit
,
GpuFromHost
,
GpuJoin
,
GpuReshape
,
GpuSplit
,
HostFromGpu
)
HostFromGpu
,
host_from_gpu
)
from
.basic_ops
import
host_from_gpu
,
GpuFromHost
from
.elemwise
import
GpuElemwise
from
.elemwise
import
GpuElemwise
from
.subtensor
import
(
GpuSubtensor
,
GpuIncSubtensor
,
from
.subtensor
import
(
GpuSubtensor
,
GpuIncSubtensor
,
GpuAdvancedIncSubtensor1
)
GpuAdvancedIncSubtensor1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论