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
3c52b7c1
Commit
3c52b7c1
authored
Jun 23, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use environment variables when args.gpu is not set
parent
dadd971c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
29 deletions
+23
-29
examples/DoReFa-Net/alexnet-dorefa.py
examples/DoReFa-Net/alexnet-dorefa.py
+3
-4
examples/DoReFa-Net/svhn-digit-dorefa.py
examples/DoReFa-Net/svhn-digit-dorefa.py
+1
-2
examples/HED/hed.py
examples/HED/hed.py
+1
-2
examples/ResNet/cifar10-resnet.py
examples/ResNet/cifar10-resnet.py
+1
-2
examples/ResNet/svhn-resnet.py
examples/ResNet/svhn-resnet.py
+1
-2
examples/Saliency/CAM-resnet.py
examples/Saliency/CAM-resnet.py
+3
-3
examples/boilerplate.py
examples/boilerplate.py
+9
-8
examples/cifar-convnet.py
examples/cifar-convnet.py
+2
-4
tensorpack/utils/gpu.py
tensorpack/utils/gpu.py
+2
-2
No files found.
examples/DoReFa-Net/alexnet-dorefa.py
View file @
3c52b7c1
...
@@ -311,13 +311,12 @@ if __name__ == '__main__':
...
@@ -311,13 +311,12 @@ if __name__ == '__main__':
sys
.
exit
()
sys
.
exit
()
assert
args
.
gpu
is
not
None
,
"Need to specify a list of gpu for training!"
assert
args
.
gpu
is
not
None
,
"Need to specify a list of gpu for training!"
NR_GPU
=
len
(
args
.
gpu
.
split
(
','
)
)
nr_tower
=
max
(
get_nr_gpu
(),
1
)
BATCH_SIZE
=
TOTAL_BATCH_SIZE
//
NR_GPU
BATCH_SIZE
=
TOTAL_BATCH_SIZE
//
nr_tower
logger
.
info
(
"Batch per tower: {}"
.
format
(
BATCH_SIZE
))
logger
.
info
(
"Batch per tower: {}"
.
format
(
BATCH_SIZE
))
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
if
args
.
gpu
:
config
.
nr_tower
=
nr_tower
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
examples/DoReFa-Net/svhn-digit-dorefa.py
View file @
3c52b7c1
...
@@ -190,6 +190,5 @@ if __name__ == '__main__':
...
@@ -190,6 +190,5 @@ if __name__ == '__main__':
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
if
args
.
gpu
:
config
.
nr_tower
=
max
(
get_nr_gpu
(),
1
)
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
QueueInputTrainer
(
config
)
.
train
()
QueueInputTrainer
(
config
)
.
train
()
examples/HED/hed.py
View file @
3c52b7c1
...
@@ -226,6 +226,5 @@ if __name__ == '__main__':
...
@@ -226,6 +226,5 @@ if __name__ == '__main__':
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
get_model_loader
(
args
.
load
)
config
.
session_init
=
get_model_loader
(
args
.
load
)
if
args
.
gpu
:
config
.
nr_tower
=
max
(
get_nr_gpu
(),
1
)
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
examples/ResNet/cifar10-resnet.py
View file @
3c52b7c1
...
@@ -175,6 +175,5 @@ if __name__ == '__main__':
...
@@ -175,6 +175,5 @@ if __name__ == '__main__':
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
if
args
.
gpu
:
config
.
nr_tower
=
max
(
get_nr_gpu
(),
1
)
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
examples/ResNet/svhn-resnet.py
View file @
3c52b7c1
...
@@ -93,6 +93,5 @@ if __name__ == '__main__':
...
@@ -93,6 +93,5 @@ if __name__ == '__main__':
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
if
args
.
gpu
:
config
.
nr_tower
=
max
(
get_nr_gpu
(),
1
)
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
examples/Saliency/CAM-resnet.py
View file @
3c52b7c1
...
@@ -256,12 +256,12 @@ if __name__ == '__main__':
...
@@ -256,12 +256,12 @@ if __name__ == '__main__':
viz_cam
(
args
.
load
,
args
.
data
)
viz_cam
(
args
.
load
,
args
.
data
)
sys
.
exit
()
sys
.
exit
()
NR_GPU
=
len
(
args
.
gpu
.
split
(
','
)
)
nr_gpu
=
get_nr_gpu
(
)
BATCH_SIZE
=
TOTAL_BATCH_SIZE
//
NR_GPU
BATCH_SIZE
=
TOTAL_BATCH_SIZE
//
nr_gpu
logger
.
auto_set_dir
()
logger
.
auto_set_dir
()
config
=
get_config
()
config
=
get_config
()
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
get_model_loader
(
args
.
load
)
config
.
session_init
=
get_model_loader
(
args
.
load
)
config
.
nr_tower
=
NR_GPU
config
.
nr_tower
=
nr_gpu
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
examples/boilerplate.py
View file @
3c52b7c1
...
@@ -63,16 +63,17 @@ def get_config():
...
@@ -63,16 +63,17 @@ def get_config():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--gpu'
,
help
=
'comma separated list of GPU(s) to use.'
,
required
=
True
)
parser
.
add_argument
(
'--gpu'
,
help
=
'comma separated list of GPU(s) to use.'
)
parser
.
add_argument
(
'--load'
,
help
=
'load model'
)
parser
.
add_argument
(
'--load'
,
help
=
'load model'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
NR_GPU
=
len
(
args
.
gpu
.
split
(
','
))
if
args
.
gpu
:
with
change_gpu
(
args
.
gpu
):
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
config
=
get_config
()
config
.
nr_tower
=
NR_GPU
if
args
.
load
:
config
=
get_config
()
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
nr_tower
=
get_nr_gpu
(
)
SyncMultiGPUTrainer
(
config
)
.
train
()
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
SyncMultiGPUTrainer
(
config
)
.
train
()
examples/cifar-convnet.py
View file @
3c52b7c1
...
@@ -150,10 +150,8 @@ if __name__ == '__main__':
...
@@ -150,10 +150,8 @@ if __name__ == '__main__':
if
args
.
load
:
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
config
.
session_init
=
SaverRestore
(
args
.
load
)
if
args
.
gpu
:
config
.
nr_tower
=
get_nr_gpu
()
config
.
nr_tower
=
len
(
args
.
gpu
.
split
(
','
))
if
config
.
nr_tower
<=
1
:
nr_gpu
=
get_nr_gpu
()
if
nr_gpu
<=
1
:
QueueInputTrainer
(
config
)
.
train
()
QueueInputTrainer
(
config
)
.
train
()
else
:
else
:
SyncMultiGPUTrainer
(
config
)
.
train
()
SyncMultiGPUTrainer
(
config
)
.
train
()
tensorpack/utils/gpu.py
View file @
3c52b7c1
...
@@ -24,12 +24,12 @@ def change_gpu(val):
...
@@ -24,12 +24,12 @@ def change_gpu(val):
def
get_nr_gpu
():
def
get_nr_gpu
():
"""
"""
Returns:
Returns:
int:
the number of GPU from ``CUDA_VISIBLE_DEVICES``
.
int:
#available GPUs in CUDA_VISIBLE_DEVICES, or in the system
.
"""
"""
env
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
,
None
)
env
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
,
None
)
if
env
is
not
None
:
if
env
is
not
None
:
return
len
(
env
.
split
(
','
))
return
len
(
env
.
split
(
','
))
logger
.
info
(
"Loading
local
devices by TensorFlow ..."
)
logger
.
info
(
"Loading devices by TensorFlow ..."
)
from
tensorflow.python.client
import
device_lib
from
tensorflow.python.client
import
device_lib
device_protos
=
device_lib
.
list_local_devices
()
device_protos
=
device_lib
.
list_local_devices
()
gpus
=
[
x
.
name
for
x
in
device_protos
if
x
.
device_type
==
'GPU'
]
gpus
=
[
x
.
name
for
x
in
device_protos
if
x
.
device_type
==
'GPU'
]
...
...
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