Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cc574b89
提交
cc574b89
authored
5月 07, 2013
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1366 from nouiz/unuse_gpu
Add theano.sandbox.cuda.unuse()
上级
59cb7198
67e55088
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
40 行增加
和
8 行删除
+40
-8
optdb.py
theano/gof/optdb.py
+10
-0
__init__.py
theano/sandbox/cuda/__init__.py
+30
-8
没有找到文件。
theano/gof/optdb.py
浏览文件 @
cc574b89
...
@@ -66,6 +66,16 @@ multiple time in a DB. Tryed to register "%s" again under the new name "%s".
...
@@ -66,6 +66,16 @@ multiple time in a DB. Tryed to register "%s" again under the new name "%s".
obj
,
tag
)
obj
,
tag
)
self
.
__db__
[
tag
]
.
add
(
obj
)
self
.
__db__
[
tag
]
.
add
(
obj
)
def
remove_tags
(
self
,
name
,
*
tags
):
obj
=
self
.
__db__
[
name
]
assert
len
(
obj
)
==
1
obj
=
obj
.
copy
()
.
pop
()
for
tag
in
tags
:
if
tag
in
self
.
_names
:
raise
ValueError
(
'The tag of the object collides with a name.'
,
obj
,
tag
)
self
.
__db__
[
tag
]
.
remove
(
obj
)
def
__query__
(
self
,
q
):
def
__query__
(
self
,
q
):
if
not
isinstance
(
q
,
Query
):
if
not
isinstance
(
q
,
Query
):
raise
TypeError
(
'Expected a Query.'
,
q
)
raise
TypeError
(
'Expected a Query.'
,
q
)
...
...
theano/sandbox/cuda/__init__.py
浏览文件 @
cc574b89
...
@@ -383,11 +383,6 @@ def use(device,
...
@@ -383,11 +383,6 @@ def use(device,
" the Theano mailing list to tell us about"
" the Theano mailing list to tell us about"
" this new GPU as we don't know any with"
" this new GPU as we don't know any with"
" this property"
)
" this property"
)
if
move_shared_float32_to_gpu
:
handle_shared_float32
(
True
)
if
enable_cuda
:
cuda_enabled
=
True
if
config
.
print_active_device
:
if
config
.
print_active_device
:
print
>>
sys
.
stderr
,
"Using gpu device
%
d:
%
s"
%
(
print
>>
sys
.
stderr
,
"Using gpu device
%
d:
%
s"
%
(
...
@@ -412,11 +407,17 @@ def use(device,
...
@@ -412,11 +407,17 @@ def use(device,
" No fallback to the cpu or other gpu device."
),)
" No fallback to the cpu or other gpu device."
),)
raise
raise
elif
use
.
device_number
!=
device
:
elif
use
.
device_number
!=
device
and
device
!=
'gpu'
:
_logger
.
warning
((
"Ignoring call to use(
%
s), GPU number
%
i "
_logger
.
warning
((
"Ignoring call to use(
%
s), GPU number
%
i "
"is already in use."
),
"is already in use."
),
str
(
device
),
use
.
device_number
)
str
(
device
),
use
.
device_number
)
if
move_shared_float32_to_gpu
:
handle_shared_float32
(
True
)
if
enable_cuda
:
cuda_enabled
=
True
if
default_to_move_computation_to_gpu
:
if
default_to_move_computation_to_gpu
:
optdb
.
add_tags
(
'gpu_opt'
,
optdb
.
add_tags
(
'gpu_opt'
,
'fast_run'
,
'fast_run'
,
...
@@ -437,15 +438,36 @@ def use(device,
...
@@ -437,15 +438,36 @@ def use(device,
use
.
device_number
=
None
use
.
device_number
=
None
def
unuse
():
"""
This undo what was done by the call to
use('gpu[0-9]', default_to_move_computation_to_gpu=True,
move_shared_float32_to_gpu=True,
enable_cuda=True)
This is used in Pylearn2 tests to enable/disable the GPU when needed.
After this call, the rest of Theano think the GPU shouldn't be used by default.
"""
global
cuda_enabled
cuda_enabled
=
False
handle_shared_float32
(
False
)
optdb
.
remove_tags
(
'gpu_opt'
,
'fast_run'
,
'inplace'
)
optdb
.
remove_tags
(
'gpu_after_fusion'
,
'fast_run'
,
'inplace'
)
def
handle_shared_float32
(
tf
):
def
handle_shared_float32
(
tf
):
"""Set the default shared type for float32 tensor to CudaNdarrayType
"""Set the default shared type for float32 tensor to CudaNdarrayType
This function is intended to be called from use(gpu_index), not directly.
This function is intended to be called from use(gpu_index), not directly.
"""
"""
if
tf
:
if
tf
:
import
theano.compile
theano
.
compile
.
shared_constructor
(
float32_shared_constructor
)
theano
.
compile
.
shared_constructor
(
float32_shared_constructor
)
else
:
else
:
theano
.
compile
.
shared_constructor
(
float32_shared_constructor
,
True
)
theano
.
compile
.
shared_constructor
(
float32_shared_constructor
,
True
)
assert
(
float32_shared_constructor
not
in
assert
(
float32_shared_constructor
not
in
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论