Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
High Performance Computing
Examples
Commits
7be20fb3
Commit
7be20fb3
authored
7 months ago
by
Jannis Klinkenberg
Browse files
Options
Downloads
Patches
Plain Diff
unified scripts for single GPU usage
parent
d046cc6e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tensorflow/cifar10/train_model.py
+11
-2
11 additions, 2 deletions
tensorflow/cifar10/train_model.py
with
11 additions
and
2 deletions
tensorflow/cifar10/train_model.py
+
11
−
2
View file @
7be20fb3
from
__future__
import
print_function
import
numpy
as
np
import
os
,
sys
import
random
import
argparse
import
datetime
import
tensorflow
as
tf
...
...
@@ -79,12 +80,14 @@ def setup(args):
if
args
.
num_interop_threads
:
tf
.
config
.
threading
.
set_inter_op_parallelism_threads
(
args
.
num_interop_threads
)
gpu_devices
=
[]
if
args
.
device
==
"
cpu
"
else
tf
.
config
.
list_physical_devices
(
"
GPU
"
)
print
(
f
"
Tensorflow get_intra_op_parallelism_threads:
{
tf
.
config
.
threading
.
get_intra_op_parallelism_threads
()
}
"
)
print
(
f
"
Tensorflow get_inter_op_parallelism_threads:
{
tf
.
config
.
threading
.
get_inter_op_parallelism_threads
()
}
"
)
l_gpu_devices
=
[]
if
args
.
device
==
"
cpu
"
else
tf
.
config
.
list_physical_devices
(
"
GPU
"
)
print
(
"
List of GPU devices found:
"
)
for
dev
in
l_
gpu_devices
:
for
dev
in
gpu_devices
:
print
(
str
(
dev
.
device_type
)
+
"
:
"
+
dev
.
name
)
print
(
""
)
sys
.
stdout
.
flush
()
...
...
@@ -93,6 +96,11 @@ def setup(args):
tf
.
config
.
optimizer
.
set_jit
(
True
)
def
main
():
# always use the same seed
random
.
seed
(
42
)
tf
.
random
.
set_seed
(
42
)
np
.
random
.
seed
(
42
)
# parse command line arguments
args
=
parse_command_line
()
...
...
@@ -107,6 +115,7 @@ def main():
model
=
applications
.
ResNet50
(
weights
=
None
,
input_shape
=
train_shape
[
1
:],
classes
=
args
.
num_classes
)
# model.summary() # display the model architecture
cur_optimizer
=
Adam
(
0.001
)
model
.
compile
(
loss
=
"
categorical_crossentropy
"
,
optimizer
=
cur_optimizer
,
metrics
=
[
"
accuracy
"
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment