Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b8e3cf3f
提交
b8e3cf3f
authored
4月 30, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change how we set the pycuda device to be sure we always have the good one initialized by Theano.
上级
32d12f3c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
21 行删除
+31
-21
pycuda_init.py
theano/misc/pycuda_init.py
+31
-21
没有找到文件。
theano/misc/pycuda_init.py
浏览文件 @
b8e3cf3f
import
os
import
os
import
warnings
import
theano
import
theano
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
cuda_ndarray
=
cuda
.
cuda_ndarray
.
cuda_ndarray
def
select_gpu_from_theano
():
def
set_gpu_from_theano
():
# Transfer the theano gpu binding to pycuda, for consistency
"""
theano_to_pycuda_device_map
=
{
"cpu"
:
"0"
,
This set the GPU used by PyCUDA to the same as the one used by Theano.
"gpu0"
:
"0"
,
"""
"gpu1"
:
"1"
,
#import pdb;pdb.set_trace()
"gpu2"
:
"2"
,
if
cuda
.
use
.
device_number
is
None
:
"gpu3"
:
"3"
}
cuda
.
use
(
"gpu"
,
dev
=
theano_to_pycuda_device_map
.
get
(
theano
.
config
.
device
,
"0"
)
force
=
False
,
if
theano
.
config
.
device
==
'gpu'
:
default_to_move_computation_to_gpu
=
False
,
dev
=
str
(
cuda
.
cuda_ndarray
.
cuda_ndarray
.
active_device_number
())
move_shared_float32_to_gpu
=
False
,
os
.
environ
[
"CUDA_DEVICE"
]
=
dev
enable_cuda
=
True
,
test_driver
=
True
)
select_gpu_from_theano
()
assert
cuda
.
use
.
device_number
==
cuda_ndarray
.
active_device_number
()
# os.environ["CUDA_DEVICE"] = str(cuda.use.device_number)
set_gpu_from_theano
()
pycuda_available
=
False
pycuda_available
=
False
try
:
if
True
:
# theano.sandbox.cuda.use.device_number is None:
import
pycuda
try
:
import
pycuda.autoinit
import
pycuda
pycuda_available
=
True
import
pycuda.autoinit
except
ImportError
:
pycuda_available
=
True
# presumably, the user wanted to use pycuda, else they wouldn't have
except
ImportError
:
# imported this module, so issue a warning that the import failed.
# presumably, the user wanted to use pycuda, else they wouldn't have
import
warnings
# imported this module, so issue a warning that the import failed.
warnings
.
warn
(
"PyCUDA import failed in theano.misc.pycuda_init"
)
warnings
.
warn
(
"PyCUDA import failed in theano.misc.pycuda_init"
)
else
:
warnings
.
warn
(
"theano.misc.pycuda_init must be imported before theano"
" init its GPU"
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论