Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4345523c
提交
4345523c
authored
5月 26, 2015
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a Theano flags to enable cumem
上级
4ae044bf
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
7 行删除
+17
-7
__init__.py
theano/sandbox/cuda/__init__.py
+8
-2
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+9
-5
没有找到文件。
theano/sandbox/cuda/__init__.py
浏览文件 @
4345523c
...
@@ -54,6 +54,12 @@ AddConfigVar('cublas.lib',
...
@@ -54,6 +54,12 @@ AddConfigVar('cublas.lib',
"""Name of the cuda blas library for the linker."""
,
"""Name of the cuda blas library for the linker."""
,
StrParam
(
'cublas'
))
StrParam
(
'cublas'
))
AddConfigVar
(
'lib.cumem'
,
"""Do we enable cumem or not."""
,
# We should not mix both allocator, so we can't override
BoolParam
(
False
,
allow_override
=
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
# nvcc_compiler module
# nvcc_compiler module
nvcc_compiler
.
is_nvcc_available
()
nvcc_compiler
.
is_nvcc_available
()
...
@@ -377,7 +383,7 @@ def use(device,
...
@@ -377,7 +383,7 @@ def use(device,
try
:
try
:
if
(
device
!=
'gpu'
)
and
not
pycuda_init_dev
:
if
(
device
!=
'gpu'
)
and
not
pycuda_init_dev
:
assert
isinstance
(
device
,
int
)
assert
isinstance
(
device
,
int
)
gpu_init
(
device
)
gpu_init
(
device
,
config
.
lib
.
cumem
)
use
.
device_number
=
device
use
.
device_number
=
device
assert
active_device_number
()
==
device
assert
active_device_number
()
==
device
else
:
else
:
...
@@ -390,7 +396,7 @@ def use(device,
...
@@ -390,7 +396,7 @@ def use(device,
cuda_ndarray
.
cuda_ndarray
.
CudaNdarray
.
zeros
((
2
,
3
))
cuda_ndarray
.
cuda_ndarray
.
CudaNdarray
.
zeros
((
2
,
3
))
use
.
device_number
=
active_device_number
()
use
.
device_number
=
active_device_number
()
# This is needed to initialize the cublas handle.
# This is needed to initialize the cublas handle.
gpu_init
(
use
.
device_number
)
gpu_init
(
use
.
device_number
,
config
.
lib
.
cumem
)
if
test_driver
:
if
test_driver
:
import
theano.sandbox.cuda.tests.test_driver
import
theano.sandbox.cuda.tests.test_driver
...
...
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
4345523c
...
@@ -71,7 +71,7 @@ void * device_malloc(size_t size)
...
@@ -71,7 +71,7 @@ void * device_malloc(size_t size)
}
}
///@TODO: thejaswi: link this option to a theano config variable?
///@TODO: thejaswi: link this option to a theano config variable?
static
bool
g_use_cumem
=
tru
e
;
static
bool
g_use_cumem
=
fals
e
;
static
const
int
g_max_devices
=
8
;
static
const
int
g_max_devices
=
8
;
int
initCumem
()
{
int
initCumem
()
{
static
bool
cumemInitialized
=
false
;
static
bool
cumemInitialized
=
false
;
...
@@ -3093,18 +3093,22 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
...
@@ -3093,18 +3093,22 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
static
int
cublas_init
();
static
int
cublas_init
();
static
void
cublas_shutdown
();
static
void
cublas_shutdown
();
// Initialize the gpu.
// Initialize the gpu.
// Takes
one optional parameter, the device number
.
// Takes
two optional parameters, the device number and if we should use cumem
.
// If provided, it sets that device to be the active device.
// If
the device number is
provided, it sets that device to be the active device.
// If not provided (usually just to test whether the gpu is available at all),
// If not provided (usually just to test whether the gpu is available at all),
// it does not set an active device.
// it does not set an active device.
// Raises EnvironmentError or ValueError (as appropriate) if the initialization failed.
// Raises EnvironmentError or ValueError (as appropriate) if the initialization failed.
// cumem is threaded like a bool. If converted to 0, don't use cumem. Otherwise, use it.
PyObject
*
PyObject
*
CudaNdarray_gpu_init
(
PyObject
*
_unused
,
PyObject
*
args
)
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
cumem
=
0
;
// 0 False, 1 True
PyArg_ParseTuple
(
args
,
"|i"
,
&
card_nb
);
// 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
,
"|ii"
,
&
card_nb
,
&
cumem
);
if
(
cumem
)
g_use_cumem
=
true
;
if
(
PyTuple_Size
(
args
)
==
0
)
{
if
(
PyTuple_Size
(
args
)
==
0
)
{
card_number_provided
=
0
;
card_number_provided
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论