Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7203d33f
提交
7203d33f
authored
7月 25, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test if g++ support openmp or not.
EPD on windows don't have openmp files.
上级
ba2610d4
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
99 行增加
和
36 行删除
+99
-36
__init__.py
theano/__init__.py
+3
-0
configdefaults.py
theano/configdefaults.py
+2
-36
configdefaults_late.py
theano/configdefaults_late.py
+94
-0
没有找到文件。
theano/__init__.py
浏览文件 @
7203d33f
...
@@ -106,6 +106,9 @@ if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
...
@@ -106,6 +106,9 @@ if config.device.startswith('gpu') or config.init_gpu_device.startswith('gpu'):
import
theano.sandbox.cuda.tests.test_driver
import
theano.sandbox.cuda.tests.test_driver
theano
.
sandbox
.
cuda
.
tests
.
test_driver
.
test_nvidia_driver1
()
theano
.
sandbox
.
cuda
.
tests
.
test_driver
.
test_nvidia_driver1
()
import
configdefaults_late
# Use config.numpy to call numpy.seterr
# Use config.numpy to call numpy.seterr
import
numpy
import
numpy
if
config
.
numpy
.
seterr_all
==
'None'
:
if
config
.
numpy
.
seterr_all
==
'None'
:
...
...
theano/configdefaults.py
浏览文件 @
7203d33f
...
@@ -16,42 +16,6 @@ AddConfigVar('floatX',
...
@@ -16,42 +16,6 @@ AddConfigVar('floatX',
EnumStr
(
'float64'
,
'float32'
),
EnumStr
(
'float64'
,
'float32'
),
)
)
#http://pyprocessing.berlios.de/
#True if the environment variable OMP_NUM_THREADS!=1 or
#if we detect more then 1 CPU core. Otherwise False.
default_openmp
=
True
var
=
os
.
getenv
(
'OMP_NUM_THREADS'
,
None
)
if
var
:
try
:
int
(
var
)
except
ValueError
:
raise
TypeError
(
"The environment variable OMP_NUM_THREADS"
" should be a number, got '
%
s'."
%
var
)
else
:
default_openmp
=
not
int
(
var
)
==
1
else
:
count
=
cpuCount
()
if
count
==
-
1
:
_logger
.
warning
(
"We are not able to detect the number of CPU cores."
" We disable openmp by default. To remove this"
" warning, set the environment variable"
" OMP_NUM_THREADS to the number of threads you"
" want theano to use."
)
default_openmp
=
count
>
1
AddConfigVar
(
'openmp'
,
"Enable (or not) parallel computation on the CPU with OpenMP. "
"This is the default value used when creating an Op that "
"supports OpenMP parallelization. It is preferable to define it "
"via the Theano configuration file ~/.theanorc or with the "
"environment variable THEANO_FLAGS. Parallelization is only "
"done for some operations that implement it, and even for "
"operations that implement parallelism, each operation is free "
"to respect this flag or not."
,
BoolParam
(
default_openmp
),
in_c_key
=
False
,
)
AddConfigVar
(
'cast_policy'
,
AddConfigVar
(
'cast_policy'
,
"Rules for implicit type casting"
,
"Rules for implicit type casting"
,
EnumStr
(
'custom'
,
'numpy+floatX'
,
EnumStr
(
'custom'
,
'numpy+floatX'
,
...
@@ -123,6 +87,7 @@ AddConfigVar('mode',
...
@@ -123,6 +87,7 @@ AddConfigVar('mode',
'FAST_COMPILE'
,
'PROFILE_MODE'
,
'DEBUG_MODE'
),
'FAST_COMPILE'
,
'PROFILE_MODE'
,
'DEBUG_MODE'
),
in_c_key
=
False
)
in_c_key
=
False
)
gxx_avail
=
True
# Test whether or not g++ is present: disable C code if it is not.
# Test whether or not g++ is present: disable C code if it is not.
# Using the dummy file descriptor below is a workaround for a crash experienced
# Using the dummy file descriptor below is a workaround for a crash experienced
# in an unusual Python 2.4.4 Windows environment with the default stdin=None.
# in an unusual Python 2.4.4 Windows environment with the default stdin=None.
...
@@ -148,6 +113,7 @@ except OSError:
...
@@ -148,6 +113,7 @@ except OSError:
'optimized C-implementations (for both CPU and GPU) and will '
'optimized C-implementations (for both CPU and GPU) and will '
'default to Python implementations. Performance will be severely '
'default to Python implementations. Performance will be severely '
'degraded.'
)
'degraded.'
)
gxx_avail
=
False
del
dummy_stdin
del
dummy_stdin
...
...
theano/configdefaults_late.py
0 → 100644
浏览文件 @
7203d33f
"""
This file define Theano flags, but we define them later in the import order.
This is needed as we need to have parsed the previous
"""
import
os
import
logging
import
subprocess
import
theano
from
theano.configparser
import
(
AddConfigVar
,
BoolParam
,
ConfigParam
,
EnumStr
,
IntParam
,
TheanoConfigParser
)
from
theano.misc.cpucount
import
cpuCount
_logger
=
logging
.
getLogger
(
'theano.configdefaults_late'
)
config
=
TheanoConfigParser
()
#http://pyprocessing.berlios.de/
#True if the environment variable (OMP_NUM_THREADS!=1 or
#if we detect more then 1 CPU core) and g++ support OpenMP
#Otherwise False.
default_openmp
=
True
#Test if the env variable is set
var
=
os
.
getenv
(
'OMP_NUM_THREADS'
,
None
)
if
var
:
try
:
int
(
var
)
except
ValueError
:
raise
TypeError
(
"The environment variable OMP_NUM_THREADS"
" should be a number, got '
%
s'."
%
var
)
else
:
default_openmp
=
not
int
(
var
)
==
1
else
:
#Check the number of cores availables.
count
=
cpuCount
()
if
count
==
-
1
:
_logger
.
warning
(
"We are not able to detect the number of CPU cores."
" We disable openmp by default. To remove this"
" warning, set the environment variable"
" OMP_NUM_THREADS to the number of threads you"
" want theano to use."
)
default_openmp
=
count
>
1
dummy_stdin
=
open
(
os
.
devnull
)
if
default_openmp
and
theano
.
configdefaults
.
gxx_avail
:
#check if g++ support openmp. We need to compile a file as the EPD
#version have openmp enabled in the specs file but do not include
#the OpenMP files.
try
:
code
=
"""
#include <omp.h>
int main( int argc, const char* argv[] )
{
int res[10];
for(int i=0; i < 10; i++){
res[i] = i;
}
}
"""
p
=
os
.
path
.
join
(
config
.
compiledir
,
'test_omp.c'
)
f
=
open
(
p
,
'w'
)
f
.
write
(
code
)
f
.
close
()
p
=
subprocess
.
Popen
([
'g++'
,
'-fopenmp'
,
p
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stdin
=
dummy_stdin
.
fileno
())
p
.
wait
()
if
p
.
returncode
!=
0
:
default_openmp
=
False
except
OSError
,
e
:
default_openmp
=
False
del
dummy_stdin
AddConfigVar
(
'openmp'
,
"Enable (or not) parallel computation on the CPU with OpenMP. "
"This is the default value used when creating an Op that "
"supports OpenMP parallelization. It is preferable to define it "
"via the Theano configuration file ~/.theanorc or with the "
"environment variable THEANO_FLAGS. Parallelization is only "
"done for some operations that implement it, and even for "
"operations that implement parallelism, each operation is free "
"to respect this flag or not."
,
BoolParam
(
default_openmp
),
in_c_key
=
False
,
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论