Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
c420730d
Commit
c420730d
authored
Jun 14, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check protoc version
parent
b912c32a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
tensorpack/utils/concurrency.py
tensorpack/utils/concurrency.py
+7
-1
tensorpack/utils/loadcaffe.py
tensorpack/utils/loadcaffe.py
+16
-0
No files found.
tensorpack/utils/concurrency.py
View file @
c420730d
...
@@ -193,21 +193,27 @@ def start_proc_mask_signal(proc):
...
@@ -193,21 +193,27 @@ def start_proc_mask_signal(proc):
def
subproc_call
(
cmd
,
timeout
=
None
):
def
subproc_call
(
cmd
,
timeout
=
None
):
"""
"""
Execute a command with timeout, and return both STDOUT/STDERR.
Execute a command with timeout, and return both STDOUT/STDERR.
Args:
Args:
cmd(str): the command to execute.
cmd(str): the command to execute.
timeout(float): timeout in seconds.
timeout(float): timeout in seconds.
Returns:
output(str), retcode(int). If timeout, retcode is -1.
"""
"""
try
:
try
:
output
=
subprocess
.
check_output
(
output
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
,
cmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
True
,
timeout
=
timeout
)
shell
=
True
,
timeout
=
timeout
)
return
output
return
output
,
0
except
subprocess
.
TimeoutExpired
as
e
:
except
subprocess
.
TimeoutExpired
as
e
:
logger
.
warn
(
"Command timeout!"
)
logger
.
warn
(
"Command timeout!"
)
logger
.
warn
(
e
.
output
)
logger
.
warn
(
e
.
output
)
return
e
.
output
,
-
1
except
subprocess
.
CalledProcessError
as
e
:
except
subprocess
.
CalledProcessError
as
e
:
logger
.
warn
(
"Commnad failed: {}"
.
format
(
e
.
returncode
))
logger
.
warn
(
"Commnad failed: {}"
.
format
(
e
.
returncode
))
logger
.
warn
(
e
.
output
)
logger
.
warn
(
e
.
output
)
return
e
.
output
,
e
.
returncode
class
OrderedContainer
(
object
):
class
OrderedContainer
(
object
):
...
...
tensorpack/utils/loadcaffe.py
View file @
c420730d
...
@@ -3,11 +3,13 @@
...
@@ -3,11 +3,13 @@
# File: loadcaffe.py
# File: loadcaffe.py
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
# Author: Yuxin Wu <ppwwyyxxc@gmail.com>
import
sys
import
numpy
as
np
import
numpy
as
np
import
os
import
os
from
.utils
import
change_env
from
.utils
import
change_env
from
.fs
import
download
,
get_dataset_path
from
.fs
import
download
,
get_dataset_path
from
.concurrency
import
subproc_call
from
.
import
logger
from
.
import
logger
__all__
=
[
'load_caffe'
,
'get_caffe_pb'
]
__all__
=
[
'load_caffe'
,
'get_caffe_pb'
]
...
@@ -123,6 +125,20 @@ def get_caffe_pb():
...
@@ -123,6 +125,20 @@ def get_caffe_pb():
if
not
os
.
path
.
isfile
(
caffe_pb_file
):
if
not
os
.
path
.
isfile
(
caffe_pb_file
):
download
(
CAFFE_PROTO_URL
,
dir
)
download
(
CAFFE_PROTO_URL
,
dir
)
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
dir
,
'caffe.proto'
))
assert
os
.
path
.
isfile
(
os
.
path
.
join
(
dir
,
'caffe.proto'
))
if
sys
.
version_info
.
major
==
3
:
cmd
=
"protoc --version"
version
,
ret
=
subproc_call
(
cmd
,
timeout
=
3
)
if
ret
!=
0
:
sys
.
exit
(
1
)
try
:
version
=
version
.
decode
(
'utf-8'
)
version
=
float
(
'.'
.
join
(
version
.
split
(
' '
)[
1
]
.
split
(
'.'
)[:
2
]))
assert
version
>=
2.7
,
"Require protoc>=2.7 for Python3"
except
:
logger
.
exception
(
"protoc --version gives: "
+
str
(
version
))
raise
cmd
=
'cd {} && protoc caffe.proto --python_out .'
.
format
(
dir
)
cmd
=
'cd {} && protoc caffe.proto --python_out .'
.
format
(
dir
)
ret
=
os
.
system
(
cmd
)
ret
=
os
.
system
(
cmd
)
assert
ret
==
0
,
\
assert
ret
==
0
,
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment