Skip to content

Commit 6c8bb39

Browse files
committed
separate init
1 parent 6d9020c commit 6c8bb39

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

run_distributed_examples.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,24 @@
1111
# Expects pytorch, torchvision to be installed.
1212

1313
BASE_DIR="$(pwd)/$(dirname $0)"
14-
source $BASE_DIR/init_examples.sh
14+
source $BASE_DIR/utils.sh
15+
16+
USE_CUDA=$(python -c "import torch; print(torch.cuda.is_available())")
17+
case $USE_CUDA in
18+
"True")
19+
echo "using cuda"
20+
CUDA=1
21+
CUDA_FLAG="--cuda"
22+
;;
23+
"False")
24+
echo "not using cuda"
25+
CUDA=0
26+
CUDA_FLAG=""
27+
;;
28+
"")
29+
exit 1;
30+
;;
31+
esac
1532

1633
function distributed() {
1734
start

run_python_examples.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,24 @@
1111
# Expects pytorch, torchvision to be installed.
1212

1313
BASE_DIR="$(pwd)/$(dirname $0)"
14-
source $BASE_DIR/init_examples.sh
14+
source $BASE_DIR/utils.sh
15+
16+
USE_CUDA=$(python -c "import torchvision, torch; print(torch.cuda.is_available())")
17+
case $USE_CUDA in
18+
"True")
19+
echo "using cuda"
20+
CUDA=1
21+
CUDA_FLAG="--cuda"
22+
;;
23+
"False")
24+
echo "not using cuda"
25+
CUDA=0
26+
CUDA_FLAG=""
27+
;;
28+
"")
29+
exit 1;
30+
;;
31+
esac
1532

1633
function dcgan() {
1734
start

init_examples.sh renamed to utils.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,14 @@
22
# This script contains utility functions and initialize exmaple scripts.
33
# Eg: run_python_examples.sh, run_distributed_examples.sh
44

5+
BASE_DIR="$(pwd)/$(dirname $0)"
56
EXAMPLES=$(echo $1 | sed -e 's/ //g')
67

78
# Redirect 'python' calls to 'python3'
89
python() {
910
command python3 "$@"
1011
}
1112

12-
USE_CUDA=$(python -c "import torchvision, torch; print(torch.cuda.is_available())")
13-
case $USE_CUDA in
14-
"True")
15-
echo "using cuda"
16-
CUDA=1
17-
CUDA_FLAG="--cuda"
18-
;;
19-
"False")
20-
echo "not using cuda"
21-
CUDA=0
22-
CUDA_FLAG=""
23-
;;
24-
"")
25-
exit 1;
26-
;;
27-
esac
28-
2913
ERRORS=${ERRORS-""}
3014

3115
function error() {

0 commit comments

Comments
 (0)