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
efbf256e
Commit
efbf256e
authored
Nov 06, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix multiprocess datasetpredictor
parent
95b6437a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
tensorpack/predict/concurrency.py
tensorpack/predict/concurrency.py
+2
-2
tensorpack/predict/dataset.py
tensorpack/predict/dataset.py
+4
-2
tensorpack/utils/gpu.py
tensorpack/utils/gpu.py
+4
-1
No files found.
tensorpack/predict/concurrency.py
View file @
efbf256e
...
...
@@ -59,8 +59,8 @@ class MultiProcessQueuePredictWorker(MultiProcessPredictWorker):
super
(
MultiProcessQueuePredictWorker
,
self
)
.
__init__
(
idx
,
config
)
self
.
inqueue
=
inqueue
self
.
outqueue
=
outqueue
assert
isinstance
(
self
.
inqueue
,
multiprocessing
.
Queue
)
assert
isinstance
(
self
.
outqueue
,
multiprocessing
.
Queue
)
assert
isinstance
(
self
.
inqueue
,
multiprocessing
.
queues
.
Queue
)
assert
isinstance
(
self
.
outqueue
,
multiprocessing
.
queues
.
Queue
)
def
run
(
self
):
self
.
_init_runtime
()
...
...
tensorpack/predict/dataset.py
View file @
efbf256e
...
...
@@ -12,6 +12,8 @@ import os
from
..dataflow
import
DataFlow
,
BatchData
from
..dataflow.dftools
import
dataflow_to_process_queue
from
..utils.concurrency
import
ensure_proc_terminate
,
OrderedResultGatherProc
,
DIE
from
..utils
import
logger
from
..utils.gpu
import
change_gpu
from
.concurrency
import
MultiProcessQueuePredictWorker
from
.common
import
PredictConfig
...
...
@@ -89,9 +91,9 @@ class MultiProcessDatasetPredictor(DatasetPredictorBase):
# TODO number of GPUs not checked
gpus
=
list
(
range
(
self
.
nr_proc
))
else
:
gpus
=
[
''
]
*
self
.
nr_proc
gpus
=
[
'
-1
'
]
*
self
.
nr_proc
self
.
workers
=
[
MultiProcessQueuePredictWorker
(
i
,
gpus
[
i
],
self
.
inqueue
,
self
.
outqueue
,
self
.
config
)
i
,
self
.
inqueue
,
self
.
outqueue
,
self
.
config
)
for
i
in
range
(
self
.
nr_proc
)]
self
.
result_queue
=
OrderedResultGatherProc
(
self
.
outqueue
,
nr_producer
=
self
.
nr_proc
)
...
...
tensorpack/utils/gpu.py
View file @
efbf256e
...
...
@@ -9,7 +9,10 @@ from .utils import change_env
__all__
=
[
'change_gpu'
,
'get_nr_gpu'
,
'get_gpus'
]
def
change_gpu
(
val
):
return
change_env
(
'CUDA_VISIBLE_DEVICES'
,
str
(
val
))
val
=
str
(
val
)
if
val
==
'-1'
:
val
=
''
return
change_env
(
'CUDA_VISIBLE_DEVICES'
,
val
)
def
get_nr_gpu
():
env
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
,
None
)
...
...
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