1

I'm trying to set a remote environment variable explicitly in an ssh command:

ssh worker-2 "export OPENBLAS_NUM_THREADS=1; echo $OPENBLAS_NUM_THREADS"

Strangely, this prints just a blank line, but when I run the same command locally, it correctly prints 1.

Since I'm setting the variable explicitly, why isn't it working remotely?

1 Answer 1

4

$OPENBLAS_NUM_THREADS is being evaluated locally by bash before it is sent to your remote machine.

You need to either escape the $:

ssh worker-2 "export OPENBLAS_NUM_THREADS=1; echo \$OPENBLAS_NUM_THREADS"

or use single quotes, which inhibit the bash variable evaluation:

ssh worker-2 'export OPENBLAS_NUM_THREADS=1; echo $OPENBLAS_NUM_THREADS'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .