Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ed1fca7a
提交
ed1fca7a
authored
7月 23, 2015
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update lib.cnmem to be a float with new definition
上级
840f1011
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
15 行删除
+31
-15
__init__.py
theano/sandbox/cuda/__init__.py
+9
-7
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+22
-8
没有找到文件。
theano/sandbox/cuda/__init__.py
浏览文件 @
ed1fca7a
...
@@ -14,7 +14,7 @@ from theano.gof import EquilibriumDB, SequenceDB
...
@@ -14,7 +14,7 @@ from theano.gof import EquilibriumDB, SequenceDB
from
theano.gof.cmodule
import
get_lib_extension
from
theano.gof.cmodule
import
get_lib_extension
from
theano.gof.compilelock
import
get_lock
,
release_lock
from
theano.gof.compilelock
import
get_lock
,
release_lock
from
theano.configparser
import
(
from
theano.configparser
import
(
config
,
AddConfigVar
,
BoolParam
,
In
tParam
,
StrParam
)
config
,
AddConfigVar
,
BoolParam
,
Floa
tParam
,
StrParam
)
from
.
import
nvcc_compiler
from
.
import
nvcc_compiler
# ignore_newtrees is to speed the optimization as this is the pattern
# ignore_newtrees is to speed the optimization as this is the pattern
...
@@ -56,16 +56,18 @@ AddConfigVar('cublas.lib',
...
@@ -56,16 +56,18 @@ AddConfigVar('cublas.lib',
StrParam
(
'cublas'
))
StrParam
(
'cublas'
))
AddConfigVar
(
'lib.cnmem'
,
AddConfigVar
(
'lib.cnmem'
,
"""Do we enable CNMeM or not (a faster memory allocator).
"""Do we enable CNMeM or not (a faster
CUDA
memory allocator).
The number (in MB) represent the start size of the memory pool.
The parameter represent the start size (in MB or
%
of
total GPU memory) of the memory pool.
0: not enabled.
0: not enabled.
-1: use half GPU memory.
0 < N <= 1:
%
of the total GPU memory (clipped to .985 for driver memory)
>0: use that number of MB of memory."""
,
> 0: use that number of MB of memory.
"""
,
# We should not mix both allocator, so we can't override
# We should not mix both allocator, so we can't override
# BoolParam(False, allow_override=False),
FloatParam
(
0
,
lambda
i
:
i
>=
0
,
allow_override
=
False
),
IntParam
(
0
,
lambda
i
:
i
>=
0
or
i
==
-
1
,
allow_override
=
False
),
in_c_key
=
False
)
in_c_key
=
False
)
# is_nvcc_available called here to initialize global vars in
# is_nvcc_available called here to initialize global vars in
...
...
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
ed1fca7a
...
@@ -3141,9 +3141,9 @@ CudaNdarray_gpu_init(PyObject* _unused, PyObject* args)
...
@@ -3141,9 +3141,9 @@ CudaNdarray_gpu_init(PyObject* _unused, PyObject* args)
{
{
int
card_nb
=
0
;
int
card_nb
=
0
;
int
card_number_provided
=
1
;
int
card_number_provided
=
1
;
int
cnmem
=
0
;
// start qt memory in MB.
float
cnmem
=
0
;
// Theano flag lib.cnmem
// if we're given something wildly invalid, this will throw a TypeError
// if we're given something wildly invalid, this will throw a TypeError
PyArg_ParseTuple
(
args
,
"|i
i
"
,
&
card_nb
,
&
cnmem
);
PyArg_ParseTuple
(
args
,
"|i
f
"
,
&
card_nb
,
&
cnmem
);
if
(
cnmem
)
if
(
cnmem
)
g_use_cnmem
=
true
;
g_use_cnmem
=
true
;
...
@@ -3202,13 +3202,27 @@ CudaNdarray_gpu_init(PyObject* _unused, PyObject* args)
...
@@ -3202,13 +3202,27 @@ CudaNdarray_gpu_init(PyObject* _unused, PyObject* args)
}
}
if
(
card_number_provided
&&
g_use_cnmem
)
{
if
(
card_number_provided
&&
g_use_cnmem
)
{
size_t
mem
=
0
;
size_t
mem
=
0
;
if
(
cnmem
>
0
)
if
(
cnmem
>
1
)
mem
=
cnmem
*
1024
*
1024
;
mem
=
cnmem
*
1024
*
1024
;
else
if
(
cnmem
!=
-
1
){
else
{
return
PyErr_Format
(
// Clip to 98.5% to let memory for the driver.
PyExc_EnvironmentError
,
if
(
cnmem
>
.985
){
"CNMeM init: The config flag must be 0 (disabled),"
cnmem
=
.985
;
" -1: use half the GPU memory, > 0: that memory in MB."
);
}
size_t
free
=
0
,
total
=
0
;
cudaError_t
err
=
cudaMemGetInfo
(
&
free
,
&
total
);
if
(
err
!=
cudaSuccess
){
// Clear the error flag, cudaMemGetInfo doesn't do it.
// Currently this returns the same thing as err, but if in future
// it returns something else I still don't see why we should ignore
// it. All we want to do here is reset the flag.
cudaGetLastError
();
PyErr_Format
(
PyExc_RuntimeError
,
"Error while getting memory info about the gpu: %s"
,
cudaGetErrorString
(
err
));
return
NULL
;
}
mem
=
total
*
cnmem
;
}
}
if
(
initCnmem
(
card_number_provided
,
card_nb
,
mem
)
==
-
1
){
if
(
initCnmem
(
card_number_provided
,
card_nb
,
mem
)
==
-
1
){
return
NULL
;
return
NULL
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论