Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_77200941
mindspore
提交
aeb833f2
M
mindspore
项目概览
2301_77200941
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aeb833f2
编写于
9月 04, 2020
作者:
L
lizhenyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
search nvcc in entire PATH
上级
bc4c5afc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
57 deletion
+15
-57
mindspore/ccsrc/runtime/device/gpu/cuda_env_checker.cc
mindspore/ccsrc/runtime/device/gpu/cuda_env_checker.cc
+13
-51
mindspore/ccsrc/runtime/device/gpu/cuda_env_checker.h
mindspore/ccsrc/runtime/device/gpu/cuda_env_checker.h
+2
-6
未找到文件。
mindspore/ccsrc/runtime/device/gpu/cuda_env_checker.cc
浏览文件 @
aeb833f2
...
...
@@ -28,9 +28,9 @@ bool CudaEnvChecker::CheckNvccInPath() {
return
find_nvcc_
;
}
auto
checker
=
[](
const
std
::
string
&
cuda_
path
)
{
auto
checker
=
[](
const
std
::
string
&
path
)
{
bool
find_nvcc
=
false
;
DIR
*
dir
=
opendir
(
cuda_
path
.
c_str
());
DIR
*
dir
=
opendir
(
path
.
c_str
());
if
(
dir
==
nullptr
)
{
return
find_nvcc
;
}
...
...
@@ -46,23 +46,23 @@ bool CudaEnvChecker::CheckNvccInPath() {
return
find_nvcc
;
};
auto
cuda_paths
=
GetCudaRealPaths
();
find_nvcc_
=
std
::
any_of
(
cuda_paths
.
begin
(),
cuda_paths
.
end
(),
checker
);
std
::
set
<
std
::
string
>
paths
;
GetRealPaths
(
&
paths
);
find_nvcc_
=
std
::
any_of
(
paths
.
begin
(),
paths
.
end
(),
checker
);
already_check_nvcc_
=
true
;
return
find_nvcc_
;
}
std
::
vector
<
std
::
string
>
CudaEnvChecker
::
GetCudaRealPaths
()
const
{
std
::
vector
<
std
::
string
>
res
;
void
CudaEnvChecker
::
GetRealPaths
(
std
::
set
<
std
::
string
>
*
paths
)
const
{
auto
env_paths_ptr
=
std
::
getenv
(
kPathEnv
);
if
(
env_paths_ptr
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"Please export env
:
PATH"
;
return
res
;
MS_LOG
(
ERROR
)
<<
"Please export env
ironment variable
PATH"
;
return
;
}
std
::
string
env_paths
=
env_paths_ptr
;
if
(
env_paths
.
empty
())
{
MS_LOG
(
ERROR
)
<<
"
env PATH is empty
"
;
return
res
;
MS_LOG
(
ERROR
)
<<
"
Empty environment variable PATH
"
;
return
;
}
std
::
string
cur_path
;
...
...
@@ -71,52 +71,14 @@ std::vector<std::string> CudaEnvChecker::GetCudaRealPaths() const {
cur_path
+=
ch
;
continue
;
}
auto
real_path_pair
=
IsCudaRealPath
(
cur_path
);
if
(
real_path_pair
.
second
)
{
res
.
push_back
(
real_path_pair
.
first
);
if
(
!
cur_path
.
empty
())
{
(
void
)
paths
->
insert
(
cur_path
);
}
cur_path
.
clear
();
}
if
(
!
cur_path
.
empty
())
{
auto
last_real_path_pair
=
IsCudaRealPath
(
cur_path
);
if
(
last_real_path_pair
.
second
)
{
res
.
push_back
(
last_real_path_pair
.
first
);
}
}
return
res
;
}
std
::
pair
<
std
::
string
,
bool
>
CudaEnvChecker
::
IsCudaRealPath
(
const
std
::
string
&
path
)
const
{
std
::
string
real_path
=
path
;
bool
valid_path
=
false
;
// 8: string length of kCudaSoftLinkPath
if
(
real_path
.
size
()
<
8
)
{
return
{
""
,
false
};
(
void
)
paths
->
insert
(
cur_path
);
}
// remove redundance space in path
auto
front_space_pos
=
real_path
.
find_first_not_of
(
' '
);
if
(
front_space_pos
!=
0
)
{
real_path
.
erase
(
0
,
front_space_pos
);
}
auto
back_space_pos
=
real_path
.
find_last_not_of
(
' '
);
if
(
back_space_pos
!=
real_path
.
size
()
-
1
)
{
real_path
.
erase
(
back_space_pos
+
1
);
}
auto
cuda_softlink_path_pos
=
real_path
.
rfind
(
kCudaSoftLinkPath
);
auto
cuda_real_path_pos
=
real_path
.
rfind
(
kCudaRealPath
);
auto
start
=
(
cuda_softlink_path_pos
==
std
::
string
::
npos
||
cuda_real_path_pos
==
std
::
string
::
npos
)
?
std
::
min
(
cuda_softlink_path_pos
,
cuda_real_path_pos
)
:
std
::
max
(
cuda_softlink_path_pos
,
cuda_real_path_pos
);
if
(
start
==
std
::
string
::
npos
)
{
return
{
""
,
false
};
}
auto
end
=
real_path
.
find
(
'n'
,
start
);
valid_path
=
(
end
==
real_path
.
size
()
-
1
)
?
true
:
((
end
==
real_path
.
size
()
-
2
)
&&
(
real_path
.
back
()
==
'/'
));
return
{
real_path
.
substr
(
0
,
end
+
1
),
valid_path
};
}
}
// namespace gpu
}
// namespace device
...
...
mindspore/ccsrc/runtime/device/gpu/cuda_env_checker.h
浏览文件 @
aeb833f2
...
...
@@ -16,9 +16,8 @@
#ifndef MINDSPORE_CCSRC_RUNTIME_DEVICE_GPU_CUDA_ENV_CHECKER_H_
#define MINDSPORE_CCSRC_RUNTIME_DEVICE_GPU_CUDA_ENV_CHECKER_H_
#include <
vector
>
#include <
set
>
#include <string>
#include <utility>
namespace
mindspore
{
namespace
device
{
...
...
@@ -38,15 +37,12 @@ class CudaEnvChecker {
CudaEnvChecker
(
const
CudaEnvChecker
&
);
CudaEnvChecker
&
operator
=
(
const
CudaEnvChecker
&
);
std
::
vector
<
std
::
string
>
GetCudaRealPaths
()
const
;
std
::
pair
<
std
::
string
,
bool
>
IsCudaRealPath
(
const
std
::
string
&
path
)
const
;
void
GetRealPaths
(
std
::
set
<
std
::
string
>
*
paths
)
const
;
bool
already_check_nvcc_
=
false
;
bool
find_nvcc_
=
false
;
static
constexpr
auto
kPathEnv
=
"PATH"
;
static
constexpr
auto
kNvcc
=
"nvcc"
;
static
constexpr
auto
kCudaSoftLinkPath
=
"cuda/bin"
;
static
constexpr
auto
kCudaRealPath
=
"cuda-10.1/bin"
;
};
}
// namespace gpu
}
// namespace device
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录