Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to invoke nproc alias #2

Closed
bradhowes opened this issue Aug 27, 2019 · 1 comment · Fixed by #6
Closed

Failed to invoke nproc alias #2

bradhowes opened this issue Aug 27, 2019 · 1 comment · Fixed by #6

Comments

@bradhowes
Copy link
Contributor

(venv) howes% ./open_spiel/scripts/build_and_run_tests.sh
++ CXX=g++
++ [[ darwin18 == \d\a\r\w\i\n* ]]
++ alias 'nproc=sysctl -n hw.physicalcpu'
++ CXX=/usr/local/bin/g++-7
+++ nproc
./open_spiel/scripts/build_and_run_tests.sh: line 37: nproc: command not found
++ MAKE_NUM_PROCS=

Apparently nproc alias is not expanded in the build_and_run_tests.sh script in the $(nproc) expression. My fix:

diff --git a/open_spiel/scripts/build_and_run_tests.sh b/open_spiel/scripts/build_and_run_tests.sh
index ba0ec84..a4a64ab 100755
--- a/open_spiel/scripts/build_and_run_tests.sh
+++ b/open_spiel/scripts/build_and_run_tests.sh
@@ -29,13 +29,14 @@ set -e  # exit when any command fails
 set -x
 
 CXX=g++
+NPROC=nproc
 if [[ "$OSTYPE" == "darwin"* ]]; then  # Mac OSX
-  alias nproc="sysctl -n hw.physicalcpu"
+  NPROC="sysctl -n hw.physicalcpu"
   CXX=/usr/local/bin/g++-7
 fi
 
-MAKE_NUM_PROCS=$(nproc)
-let TEST_NUM_PROCS=4*$(nproc)
+MAKE_NUM_PROCS=$(${NPROC})
+let TEST_NUM_PROCS=4*${MAKE_NUM_PROCS}
 
 PYVERSION=$(python3 -c 'import sys; print(sys.version.split(" ")[0])')
 PY_VERSION_MAJOR=$(python3 -c 'import sys; print(sys.version_info.major)')
@lanctot
Copy link
Collaborator

lanctot commented Aug 28, 2019

Ah, thanks for this! We indeed have not tested on MacOS yet, so this is quite informative, thanks! Feel free to turn your change into a pull request.

@lanctot lanctot closed this as completed Aug 28, 2019
OpenSpiel pushed a commit that referenced this issue Sep 23, 2019
OpenSpiel pushed a commit that referenced this issue Dec 2, 2019
merge official repo into fork
OpenSpiel pushed a commit that referenced this issue Apr 26, 2021
Merge original repo to the fork
lanctot pushed a commit that referenced this issue May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants