Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2b07fc48
提交
2b07fc48
authored
12月 21, 2016
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8 long line
上级
68f46980
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
10 行删除
+17
-10
__init__.py
theano/gpuarray/__init__.py
+17
-10
没有找到文件。
theano/gpuarray/__init__.py
浏览文件 @
2b07fc48
...
@@ -46,10 +46,12 @@ def init_dev(dev, name=None):
...
@@ -46,10 +46,12 @@ def init_dev(dev, name=None):
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."
)
if
(
pygpu
.
version
.
major
,
pygpu
.
version
.
minor
)
<
(
0
,
6
):
if
(
pygpu
.
version
.
major
,
pygpu
.
version
.
minor
)
<
(
0
,
6
):
raise
ValueError
(
"Your installed version of pygpu is too old, please upgrade to 0.6 or later"
)
raise
ValueError
(
"Your installed version of pygpu is too old, please upgrade to 0.6 or later"
)
# This is for the C headers API
# This is for the C headers API
if
pygpu
.
gpuarray
.
api_version
()[
0
]
<
0
:
if
pygpu
.
gpuarray
.
api_version
()[
0
]
<
0
:
raise
ValueError
(
"Your installed libgpuarray is too old, please update"
)
raise
ValueError
(
"Your installed libgpuarray is too old, please update"
)
if
init_dev
.
dnn_version
is
None
and
dev
.
startswith
(
'cuda'
):
if
init_dev
.
dnn_version
is
None
and
dev
.
startswith
(
'cuda'
):
try
:
try
:
init_dev
.
dnn_version
=
dnn
.
version
()
init_dev
.
dnn_version
=
dnn
.
version
()
...
@@ -65,10 +67,11 @@ def init_dev(dev, name=None):
...
@@ -65,10 +67,11 @@ def init_dev(dev, name=None):
except
Exception
:
except
Exception
:
pass
pass
if
dev
not
in
init_dev
.
devmap
:
if
dev
not
in
init_dev
.
devmap
:
context
=
pygpu
.
init
(
dev
,
context
=
pygpu
.
init
(
disable_alloc_cache
=
config
.
gpuarray
.
preallocate
<
0
,
dev
,
single_stream
=
config
.
gpuarray
.
single_stream
,
disable_alloc_cache
=
config
.
gpuarray
.
preallocate
<
0
,
sched
=
config
.
gpuarray
.
sched
)
single_stream
=
config
.
gpuarray
.
single_stream
,
sched
=
config
.
gpuarray
.
sched
)
context
.
dev
=
dev
context
.
dev
=
dev
init_dev
.
devmap
[
dev
]
=
context
init_dev
.
devmap
[
dev
]
=
context
if
dev
.
startswith
(
'cuda'
):
if
dev
.
startswith
(
'cuda'
):
...
@@ -82,14 +85,16 @@ def init_dev(dev, name=None):
...
@@ -82,14 +85,16 @@ def init_dev(dev, name=None):
else
:
else
:
gmem
=
config
.
gpuarray
.
preallocate
*
MB
gmem
=
config
.
gpuarray
.
preallocate
*
MB
if
gmem
>
context
.
free_gmem
-
50
*
MB
:
if
gmem
>
context
.
free_gmem
-
50
*
MB
:
print
(
"WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly"
)
print
(
"WARNING: Preallocating too much memory can prevent cudnn and cublas from working properly"
)
# This will allocate and immediatly free an object of size gmem
# This will allocate and immediatly free an object of size gmem
# which will reserve that amount of memory on the GPU.
# which will reserve that amount of memory on the GPU.
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
/
context
.
total_gmem
,
dev
),
(
gmem
//
MB
,
context
.
total_gmem
//
MB
,
gmem
/
context
.
total_gmem
,
dev
),
file
=
sys
.
stderr
)
file
=
sys
.
stderr
)
context
=
init_dev
.
devmap
[
dev
]
context
=
init_dev
.
devmap
[
dev
]
...
@@ -122,7 +127,8 @@ if pygpu:
...
@@ -122,7 +127,8 @@ if pygpu:
elif
(
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
elif
(
config
.
init_gpu_device
.
startswith
(
'cuda'
)
or
config
.
init_gpu_device
.
startswith
(
'opencl'
)):
config
.
init_gpu_device
.
startswith
(
'opencl'
)):
if
config
.
device
!=
'cpu'
:
if
config
.
device
!=
'cpu'
:
raise
ValueError
(
'you must set device=cpu to use init_gpu_device.'
)
raise
ValueError
(
'you must set device=cpu to use init_gpu_device.'
)
if
config
.
contexts
!=
''
:
if
config
.
contexts
!=
''
:
print
(
"Using contexts will make init_gpu_device act like device and move all computations by default, which might not be what you want."
)
print
(
"Using contexts will make init_gpu_device act like device and move all computations by default, which might not be what you want."
)
init_dev
(
config
.
init_gpu_device
)
init_dev
(
config
.
init_gpu_device
)
...
@@ -150,4 +156,5 @@ else:
...
@@ -150,4 +156,5 @@ else:
config
.
device
.
startswith
(
'opencl'
)
or
config
.
device
.
startswith
(
'opencl'
)
or
config
.
device
.
startswith
(
'cuda'
)
or
config
.
device
.
startswith
(
'cuda'
)
or
config
.
contexts
!=
''
):
config
.
contexts
!=
''
):
error
(
"pygpu was configured but could not be imported or is too old (version 0.6 or higher required)"
,
exc_info
=
True
)
error
(
"pygpu was configured but could not be imported or is too old (version 0.6 or higher required)"
,
exc_info
=
True
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论