►
From YouTube: 11 - Python at NERSC
Description
Part of the NERSC New User Training on September 28, 2022.
Please see https://www.nersc.gov/users/training/events/new-user-training-sept2022/ for the training day agenda and presentation slides.
A
A
A
On
gpus
and
I
know
we
have
the
Q
a
doc,
but
there
might
be
a
time
for
a
question
or
two
at
the
end,
as
well
so
not
covered
in
this
talk
is
using
Jupiter,
which
is
a
very
popular
way
of
using
python
at
nurse.
For
that
you'll
have
to
wait
for
the
next
presentation
so
using
python.
So
at
nurse
we
provide
an
anaconda
python
distribution
for
users,
so
we
provide
that
through
the
python
module.
A
So
when
you
log
into
promoter,
you
can
type
module
load
python
and
then
now
the
python
that's
available
is
going
to
be
the
one
that
we've
provided
for
you
so
kind
of
demonstrate.
Those
commands
here,
type
module,
load,
Python
and
you
can
enter
the
interactive
Python
reple
and
then
you
can
start
using
python
at
nurse.
A
If
you
look
at
these
slides
later
on,
I've
included
links
to
in
our
documentation
and
a
lot
of
the
slides.
So
if
you
want
to
reference,
you
can
find
more
detail
or
find
out
where
you
should
look
in
our
documentation.
You
can
find
these
slides
on
the
event
page
later
on
and
use
the
URLs
and
slides
so
a
little
more
about
the
python
module
that
python
module
actually
provides
conda.
A
So
if
you
want
to
use
a
your
own
conda
environment
or
use
the
one
that
we
provide,
there's
a
lot
more
in
there,
so
it's
after
you
module
load
python.
You
see
that
you
should
have
conda
available
and
we
also
initialize
conda
for
you.
So
sometimes,
when
you
first
set
up
conda
on
your
laptop
or
a
workstation
or
something
you
it'll,
typically
prompt
you
to
run
a
command
like
conda
init,
which
modifies
your
shell
startup
files
and
nurse
you
do
not
need
to
do
that.
That's
all
provided
in
the
python
module.
A
A
We
also
have
two
like
a
lazy,
H5
pie
and
another
one
called
lazy
MPI
for
pi,
which
kind
of
demonstrate
a
basic
conda
environment,
using
kind
of
parallel
versions
of
those
special
libraries
for
use
on
on
their
system.
So
there's
more
information
about
that
in
our
docs.
We
don't
have
enough
time
to
really
cover
that
here.
A
So
the
kind
of
the
next
steps
you
can
take
are
creating
your
own
conda
environment,
so
I'm
highlighting
here
the
commands
you
module,
load
python.
We
provide
Honda,
so
you
can
just
use
a
typical
condo,
create
name
your
environment
and
then
tell
it
which
packages
you
want
to
install
and
then
you
can
use
con
to
activate
and
then
now
you're
using
your
own
custom
environment.
A
You
can
also
use
shifter,
so
there'll
be
a
talk
about
shifter
later
on
as
well.
So
that's
another
good
way
to
use
Python
is
to.
If
you
have
all
of
your
all
of
your
software
and
its
dependencies
in
a
container,
you
could
use
u-shifter
to
launch
python
within
that
container.
So
on
the
right
here.
I
also
I'm
highlighting
this
XXX.
This
is
not
the
python
you're
looking
for.
A
So,
if
you
do
not
load,
do
this
module
load
python
when
you
log
into
promoter,
if
you
type
which
python
it'll
show
you
this
python
under
user
bin.
So
this
is
the
system
Python
and
it's
probably
best
to
avoid
this.
This
is
usually
not
the
python
that
you
want
to
use.
A
Some
tips
for
installing
packages
so
for
the
most
part,
just
using
conda,
install
package
or
pip
install
package
should
work
some
things
to
be
aware
of,
because
when
you're
using
conda
those
packages
come
from
different
conda
channels,
the
two
common
ones
are
defaults
and
condo
Forge.
It's
usually
okay,
to
mix
packages
from
these
different
channels,
but
sometimes
the
kind
of
dependencies.
Some
of
some
packages
require
different
versions
of
each
other
and
you
could
get
into
trouble.
A
Some
packages
need
to
be
compiled,
compiled
with
the
compiler
wrappers
that
you
may
have
heard
about
and
talks
earlier
today,
for
example,
MPI
for
pi
and
H5
Pi
should
be
compiled
with
the
compiler
wrappers
on
nurse
and
another
gotcha
to
be
aware
of
on
Pro
Mudder
is
Cuda
toolkit,
so
more
and
more
users
want
to
use
GPU
kind
of
enabled
code
in
their
python
packages,
and
one
sort
of
tricky
thing
is
that
by
default,
there's
a
Cuda
toolkit
module,
that's
loaded
in
your
environment
when
you
log
into
promoter
and
if
you're
installing
packages
from
condo
Forge,
sometimes
condo
Forge,
will
install
Cuda
toolkit
as
well,
depending
on
how
the
package
that
you're
installing
specifies
its
dependencies.
A
Another
thing
to
be
aware
of
with
Pip,
but
a
common
issue
that
we
see
happen
is
that
you
know
pip
will
try
to
cash
packages.
So
you
want
to
watch
out
for
that,
like
if
you're
trying
to
reinstall
a
new
version
of
a
package
you're
interactively
developing
some
some
package,
you
have
to
be
aware
that
sometimes
tip
will
cache
what
you're
trying
to
install
so
there's
a
couple
commands
like
this.
No
Caster
or
four
Street
install
that
kind
of
help.
A
Pip
help
you
tell
pip
to,
like
you
know,
really
reinstall
the
package
from
scratch.
You
also
want
to
watch
out
for
this
pip
install
dash
dash
user,
because
that
will
install
a
package
kind
of
outside
of
your
conda
environment
in
this
kind
of
a
directory.
That's
under
your
home
directory,
but
it's
kind
of
outside
of
it's
not
your
package
will
no
longer
be
kind
of
sandboxed
to
your
conda
environment.
So
if
you,
you
know
work
on
something
else
and
you
switch
over
to
that
other
content
environment.
A
You
might
be
picking
up
this
other
package
you
installed,
because
that
package
lives
outside
of
the
condo
environments.
So
that's
something
to
watch
out
for
with
pimp.
A
A
A
Yes,
a
reminder
to
use
the
compiler
wrappers
for
especially
for
building
MPI
for
pi,
and
maybe
some
other
packages
yeah
okay,
so
that's
kind
of
the
quick
overview
of
python
at
nurse.
So
then
very
quick
introduction
to
python
on
gpus.
So
if
you're
just
getting
started
with
gpus
from
python,
it's
important.
You
kind
of
realize
that
that
numpy
and
sci-fi,
which
are
two
of
the
most
common
popular
scientific
packages
in
Python,
they
can't
really
make
use
of
the
GPU
right
out
of
the
box.
A
So
there
are
a
lot
of
we're
on
python
GPU
Frameworks
out
there.
So
if
you're,
just
looking
for
kind
of
replacements
for
existing
code
that
you
already
written
with
numpy
or
scipy
or
pandas
or
scikit-learn,
then
the
coupon
or
the
the
Rapids
ecosystem
packages
provide
a
lot
of
similar
functions
that
can
use
the
gpus
if
you're
doing
a
lot
of
machine
learning,
you're,
probably
already
using
pi,
torch
and
tensorflow,
and
maybe
even
JAX
on
the
CPU
and
those
libraries
also
can
Target
the
GPU
as
well.
A
A
And
then,
if
you're
interested
in
kind
of,
how
do
you
scale
out
your
python
code
to
use?
Maybe
multiple
gpus
or
multiple
nodes,
then
MPI
for
pi,
plus
whatever
GPU
package
you're
already
using,
is
a
way
of
kind
of
spreading
out
to
multiple
nodes
or
or
desk?
Is
another
popular
tool
for
distributed
on
python
and
then
couldn't
Americas
also
is
from
new
Nvidia
and
may
provide
another
way
of
scaling
out
to
multiple
nodes.
Although
that
one's
a
bit
more
experimental
at
the
moment.
A
So
what
is
I
a
a
condo
environment
with
some
GPU
packages?
Look
like
so
here,
I've
kind
of
just
demonstrated
creating
a
basic
content
environment
where
we
install
coupon.
So
we
can
do
some
work
on
our
gpus,
so
we
module
with
python.
Do
our
content
create
and
we
install
python,
numpy,
sci-fi,
activate
our
environment,
and
then
we
install
coupai
using
pip
and
then
I'll
just
I
want
to
call
out
here
that
a
lot
of
these
GPU
packages
there
is
kind
of
a
tight
coupling
between
the
Cuda
toolkit
and
its
version.
A
A
A
So
there's
one
added
complication,
though
it's
kind
of
moving
data
between
the
CPU
or
host
and
the
GPU
and
device.
So
they
have
a
couple
extra
functions
to
kind
of
move,
move
that
data
around
between
the
CPU
and
the
GPU.
A
You
can
also
combine
some
of
these
different
Frameworks,
there's
kind
of
like
a
a
common
protocol
that
many
of
these
python
libraries
use
to
kind
of
specify
the
the
GPU
memory
that
their
objects
use.
So
you
can
kind
of
move
data
you
can
so
here,
I'm,
demonstrating
kind
of
what
a
Cuda
kernel
looks
like
written
in
number,
Cuda
and
I'm.
Also
on
the
right
here.
A
I
show
kind
of
creating
an
array
using
coupon,
passing
that
array
to
the
number
kernel
and
then
yeah,
so
you
can
kind
of
pass
these
GPU
objects
between
these
Frameworks
and
then
a
cool
feature
as
well.
If
you're
kind
of
worried
about
having,
like
you
know,
a
CPU
code
path
and
a
GPU
code
path,
they're
kind
of
you
can
probably
reuse
a
lot
of
the
same
code.
You've
already
written
because
of
this
kind
of
cool
array
function.
A
A
After
doing
a
lot
of
CPU
programming
is,
is
my
code,
a
good
fit
for
the
GPU,
and
so
so
typically,
you
know,
what's
good
on
the
GPU
is
performing
computation
on
large
arrays
or
matrices
or
images,
and
so
some
concerns
often
are
you
know:
does
your
data
set
fit
in
the
GPU
memory
so
on
Pro
matter,
each
GPU
has
40
gigabytes
of
memory,
which
is
different
than
like
a
the
CPU
nodes
have
512
gigabytes
of
memory,
and
then
you
also
want
to
make
sure
that
I
O
is
not
the
biggest
bottleneck
of
your
application
as
well
and
on
the
right.
A
It
kind
of
just
demonstrate
a
comparison
between
just
multiplying
taking
the
dot
product
between
two
two-dimensional
matrices
and
numpy
and
coupon.
So
for
very
small
array,
sizes
or
Matrix
sizes.
Numpy
is
actually
significant,
significantly
faster,
so
it
only
becomes
worth
it
to
really
move
that
computation
onto
the
GPU
at
larger
array
sizes,
so
kind
of
every
every
function
or
algorithm
will
kind
of
a
different
turnover
point
where
it
becomes
worth
it
to
move
that
over
to
the
GPU.
A
But
there
is
some
overhead
for
kind
of
doing
computation
on
the
GPU.
So
if
your
problem
sizes
aren't
large
enough,
then
you
won't
see
much
of
a
speed
up.
A
Hey
so
yeah
in
summary
or
yeah
just
to
wrap
up.
We
have
a
ton
of
documentation
on
the
nurse
docs
and
if
you
ever
have
any
questions
just
feel
free
to
reach
out
and
open
a
ticket.
I
think
that's
all
I
have.
So
if
you
have
any
questions,
I
haven't
been
looking
at
the
dots
or
anyone
wants
to
ask
the
question
now:
that's
all
I
have.